Fresh IDE . Check-in [fbc1786a73]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Work on TAsmEdit. Simple syntax highlighter working now. The colors are derived from the Tomorrow there.
Timelines: family | ancestors | NoCanvasGUI
Files: files | file ages | folders
SHA1:fbc1786a731491c23c5e850fa01af6b1732d6684
User & Date: johnfound 2018-07-24 07:42:01
Context
2018-07-24
07:42
Work on TAsmEdit. Simple syntax highlighter working now. The colors are derived from the Tomorrow there. Leaf check-in: fbc1786a73 user: johnfound tags: NoCanvasGUI
2018-07-03
12:06
More simple API for the TAsmEdit carete and selections coordinates. check-in: 67022b13a9 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/gui/TAsmEdit.asm.

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
....
1531
1532
1533
1534
1535
1536
1537

1538
1539
1540
1541
1542

1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
....
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
ends



struct TTextChunk
  .len   dw ?   ; the length of the text chunk in BYTES (in Utf-8 chars???)
  .color db ?   ; the high order nibble encode the background, low order nibble encodes the text color.
  .flags db ?   ; the text formatting flags. reserved. For example underlining, bold, etc...
ends



object TAsmEdit, TWindow

; private fields
................................................................................
        jne     .finish

        set     esi, TAsmEdit:PosY, [.value]

.finish:
;        stdcall ProcessSystemEvents
;
        xor     edx, edx
;        mov     [esi+TAsmEdit._img_txt_valid], edx
;        mov     [esi+TAsmEdit._img_margin_valid], edx

        exec    esi, TAsmEdit:RectChanged2, edx
        exec    esi, TAsmEdit:UpdateCaretPos
        popad
        return

.scrollupy:
        xor     edx, edx
        get     eax, esi, TAsmEdit:PosY
................................................................................

        lea     esi, [esi+eax]          ; now esi - the start of the text that have to be drawn

; now loop to the starting TTextChunk

        mov     edx, [.fromChar]
        xor     ebx, ebx


        test    edi, edi
        jz      .default_color

.chunk_loop:

        cmp     ebx, [edi+TArray.count]
        jae     .default_color

        movzx   eax, word [edi + TArray.array + sizeof.TTextChunk * ebx + TTextChunk.len]
        sub     edx, eax

        lea     ebx, [ebx+1]    ; not affecting flags!
        jge     .chunk_loop

        neg     edx     ; the remaining characters of this chunk

.set_color:
; here ebx - the index of the current chunk.
;      edx - the remaining characters from this chunk.
................................................................................

        mov     esi, [esi]
        mov     [esi+TTextLine.line_width], ecx
        mov     [esi+TTextLine.length], ecx
        stdcall IncCount, [ebx+TAsmEdit._line_widths], ecx
        mov     [ebx+TAsmEdit._line_widths], edx

;        stdcall SyntaxFASM, esi, [.context]
;        mov     [.context], eax
        jmp     .text_loop


.end_text:

        exec    ebx, TAsmEdit:ComputeLeftMarginWidth
        exec    ebx, TAsmEdit:UpdateScrollBar







|







 







<
<
<
<
|







 







>





>





<
<







 







|
|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
380
381
382
383
384
385
386




387
388
389
390
391
392
393
394
....
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545


1546
1547
1548
1549
1550
1551
1552
....
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
ends



struct TTextChunk
  .len   dw ?   ; the length of the text chunk in BYTES (in Utf-8 chars???)
  .color db ?   ; the high order nibble encode the background, low order nibble encodes the text color.
  .flags db ?   ; the text formatting flags. not used, reserved. For example underlining, bold, etc...
ends



object TAsmEdit, TWindow

; private fields
................................................................................
        jne     .finish

        set     esi, TAsmEdit:PosY, [.value]

.finish:
;        stdcall ProcessSystemEvents
;




        exec    esi, TAsmEdit:RectChanged2, 0
        exec    esi, TAsmEdit:UpdateCaretPos
        popad
        return

.scrollupy:
        xor     edx, edx
        get     eax, esi, TAsmEdit:PosY
................................................................................

        lea     esi, [esi+eax]          ; now esi - the start of the text that have to be drawn

; now loop to the starting TTextChunk

        mov     edx, [.fromChar]
        xor     ebx, ebx
        dec     ebx

        test    edi, edi
        jz      .default_color

.chunk_loop:
        inc     ebx
        cmp     ebx, [edi+TArray.count]
        jae     .default_color

        movzx   eax, word [edi + TArray.array + sizeof.TTextChunk * ebx + TTextChunk.len]
        sub     edx, eax


        jge     .chunk_loop

        neg     edx     ; the remaining characters of this chunk

.set_color:
; here ebx - the index of the current chunk.
;      edx - the remaining characters from this chunk.
................................................................................

        mov     esi, [esi]
        mov     [esi+TTextLine.line_width], ecx
        mov     [esi+TTextLine.length], ecx
        stdcall IncCount, [ebx+TAsmEdit._line_widths], ecx
        mov     [ebx+TAsmEdit._line_widths], edx

        stdcall SyntaxFASM, esi, [.context]
        mov     [.context], eax
        jmp     .text_loop


.end_text:

        exec    ebx, TAsmEdit:ComputeLeftMarginWidth
        exec    ebx, TAsmEdit:UpdateScrollBar

Changes to freshlib/gui/syntax/SyntaxFASM.asm.

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

57
58




59




60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77



78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

122
123
124
125

126
127
128
129
130
131
132
133
134
135
136
137
138


139
140
141


142
143

144
145
146
147
148





















149
150
151
152
153
154
155
; Arguments:
;   .pLineInfo - pointer to TTextLine structure.
;   .SynContext - input context of the highligher.
;
; Returns:
;       eax - output context of the highligher.
;
proc SyntaxFASM, .pLineInfo, .SynContext
.Quo   rb 4
.start dd ?
begin
        pushad

        mov     esi, [.pLineInfo]
        mov     [.start], esi

        mov     edi, [esi+TTextLine.syn_array]
        test    edi, edi
        jnz     .array_ok

        stdcall CreateArray, sizeof.TTextChunk
        mov     edi, eax
        mov     [esi+TTextLine.syn_array], edi

.array_ok:


        xor     ebx, ebx





.loop:




        mov     eax, ebx
        pos2ofs eax, esi

        stdcall DecodeUtf8, [esi+eax]
        add     ebx, edx

        test    eax, eax
        jz      .end_of_line

        cmp     [.SynContext], ciComment
        je      .endif

        cmp     [.SynContext], ciString
        jne     .ifnotstr

        cmp     al,[.Quo]
        jne     .endif




        mov     [.SynContext], ciText
        mov     eax, ciString
        jmp     .setcolor

.ifnotstr:
        cmp     al, ';'
        jne     .notrem


        mov     [.SynContext], ciComment
        jmp     .endif

.notrem:
        cmp     al, '"'
        je      .str
        cmp     al, "'"
        jne     .notstr

.str:

        mov     [.SynContext], ciString
        mov     [.Quo], al
        jmp     .endif

.notstr:
        call    .CharInSymbols
        jnc     .notsym


        mov     [.SynContext], ciSymbol
        jmp     .endif

.notsym:
        cmp     [.SynContext], ciNumber
        je      .endif

        cmp     esi, [.start]
        je      .maybenum

        cmp     [.SynContext], ciSymbol
        jne     .endif

; The number begins only after ttChar or at the begining of the line.
.maybenum:
        call    .CharInNum
        jnc     .notnum


        mov      [.SynContext], ciNumber
        jmp      .endif

.notnum:

        mov     [.SynContext], ciText

.endif:
        mov     eax, [.SynContext]
        cmp     eax, ciText
        je      .next

.setcolor:
        cmp     [edi+TCharAttr.flags], 0
        jne     .next                           ; the char have protected attributes.

        mov     ecx, [ebx+4*eax-4]
        mov     [edi+TCharAttr.color], ecx



.next:
        jmp     .loop



.end_of_line:

        mov     [esi+TTextLine.syn_context], eax
        mov     [esp+4*regEAX], eax
        popad
        return























.CharInSymbols:
        push    edi ecx

        mov     edi, .symbol_characters+1
        movzx   ecx, byte [edi-1]








|





|
<







|



>
|

>
>
>
>

>
>
>
>




<
<
<
<










>
>
>

<
|





>










>








>







|










>
|
|


>



<
<
|

<
<
<

<
<
>
>

<
<
>
>

<
>





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71




72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139


140
141



142


143
144
145


146
147
148

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
; Arguments:
;   .pLineInfo - pointer to TTextLine structure.
;   .SynContext - input context of the highligher.
;
; Returns:
;       eax - output context of the highligher.
;
proc SyntaxFASM, .pTextLine, .SynContext
.Quo   rb 4
.start dd ?
begin
        pushad

        mov     esi, [.pTextLine]


        mov     edi, [esi+TTextLine.syn_array]
        test    edi, edi
        jnz     .array_ok

        stdcall CreateArray, sizeof.TTextChunk
        mov     edi, eax
        mov     [esi+TTextLine.syn_array], eax

.array_ok:

        xor     ebx, ebx                ; the offset inside the line.
        xor     edx, edx

        mov     [.Quo], bl
        mov     [edi+TArray.count], ebx
        mov     [.start], ebx

.loop:
        add     ebx, edx
        cmp     ebx, [esi+TTextLine.TextLen]
        jae     .end_of_line

        mov     eax, ebx
        pos2ofs eax, esi

        stdcall DecodeUtf8, [esi+eax]





        cmp     [.SynContext], ciComment
        je      .endif

        cmp     [.SynContext], ciString
        jne     .ifnotstr

        cmp     al,[.Quo]
        jne     .endif

        add     ebx, edx
        xor     edx, edx
        call    .end_chunk
        mov     [.SynContext], ciText

        jmp     .loop

.ifnotstr:
        cmp     al, ';'
        jne     .notrem

        call    .end_chunk
        mov     [.SynContext], ciComment
        jmp     .endif

.notrem:
        cmp     al, '"'
        je      .str
        cmp     al, "'"
        jne     .notstr

.str:
        call    .end_chunk
        mov     [.SynContext], ciString
        mov     [.Quo], al
        jmp     .endif

.notstr:
        call    .CharInSymbols
        jnc     .notsym

        call    .end_chunk
        mov     [.SynContext], ciSymbol
        jmp     .endif

.notsym:
        cmp     [.SynContext], ciNumber
        je      .endif

        cmp     ebx, [.start]
        je      .maybenum

        cmp     [.SynContext], ciSymbol
        jne     .endif

; The number begins only after ttChar or at the begining of the line.
.maybenum:
        call    .CharInNum
        jnc     .notnum

        call    .end_chunk
        mov     [.SynContext], ciNumber
        jmp     .endif

.notnum:
        call    .end_chunk
        mov     [.SynContext], ciText

.endif:


        jmp     .loop







.end_of_line:
        call    .end_chunk



;        mov     eax, [.SynContext]
        xor     eax, eax                ; the assembly lines always end with context of 0 ???


        mov     [esi+TTextLine.syn_array], edi
        mov     [esi+TTextLine.syn_context], eax
        mov     [esp+4*regEAX], eax
        popad
        return


.end_chunk:
        push    eax ecx edx

        mov     ecx, ebx
        sub     ecx, [.start]
        jz      .chunk_processed

        mov     [.start], ebx
        stdcall AddArrayItems, edi, 1
        mov     edi, edx
        jc      .chunk_processed

        mov     [eax+TTextChunk.len], cx
        mov     ecx, [.SynContext]
        mov     [eax+TTextChunk.color], cl

.chunk_processed:
        pop     edx ecx eax
        retn


.CharInSymbols:
        push    edi ecx

        mov     edi, .symbol_characters+1
        movzx   ecx, byte [edi-1]

Changes to freshlib/gui/themes/asmedit.asm.

7
8
9
10
11
12
13











14
15
16
17
18
19
20
21
22
23
24
25
26
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;               TAsmEdit components.
;
;  Target OS: Any
;
;  Dependencies:
;_________________________________________________________________________________________












iglobal
        NamedArray      ASM,                                            \
\
\ ; Widgets border colors and width
                clBackground,     HEX, <$ffffffff, $ffe8e8e8, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff>, \
                clText,           HEX, <$ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000>, \
                clProtectedText,  HEX, $ffa0a000,                       \
                clSelection,      HEX, $602980b9,                       \
\
                clLeftMargin,     HEX, $ff404040,                       \
                clLeftMarginEdge, HEX, $ffffffff,                       \
                clLeftMarginText, HEX, $ffffffff,                       \
                clLeftMarginTree, HEX, $ffff0000,                       \
................................................................................
                iconDebugInfo,    PNG, '%lib%/FreshEdit/themes/images/debug_icon.png',                                                                  \
                iconFoldings,     PNG, <'%lib%/FreshEdit/themes/images/unfold.png', '%lib%/FreshEdit/themes/images/fold.png'>,                          \
\
                xspcIconBrkPnts,  NUM, 3,                                                                                                               \
\
\ ; Default mono font
\
                Font,             FONT, "Liberation Mono": 16 : fwNormal : ffMonospaced,      \ ;"Fixedsys Excelsior 3.01": 16 : fwNormal : ffMonospaced,      \
                NumFont,          FONT, "Liberation Mono": 13 : fwLight : 0

        DispSize "ASM theme data", $ - ASM

endg








>
>
>
>
>
>
>
>
>
>
>




|
|







 







|






7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;               TAsmEdit components.
;
;  Target OS: Any
;
;  Dependencies:
;_________________________________________________________________________________________

;ciText         = 0
;ciComment      = 1
;ciString       = 2
;ciNumber       = 3
;ciSymbol       = 4
;ciRegister     = 5
;ciInstruction  = 6
;ciDerective    = 7
;ciPreprocessor = 8
;ciMacro        = 9

iglobal
        NamedArray      ASM,                                            \
\
\ ; Widgets border colors and width
                clBackground,     HEX, <$ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff, $ffffffff>, \
                clText,           HEX, <$ff000000, $ff8E908C, $ff718C00, $ffDE935F, $ff4080a0, $fff5871f, $ffc82829, $ff4271ae, $ff895Fa8, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000, $ff000000>, \
                clProtectedText,  HEX, $ffa0a000,                       \
                clSelection,      HEX, $602980b9,                       \
\
                clLeftMargin,     HEX, $ff404040,                       \
                clLeftMarginEdge, HEX, $ffffffff,                       \
                clLeftMarginText, HEX, $ffffffff,                       \
                clLeftMarginTree, HEX, $ffff0000,                       \
................................................................................
                iconDebugInfo,    PNG, '%lib%/FreshEdit/themes/images/debug_icon.png',                                                                  \
                iconFoldings,     PNG, <'%lib%/FreshEdit/themes/images/unfold.png', '%lib%/FreshEdit/themes/images/fold.png'>,                          \
\
                xspcIconBrkPnts,  NUM, 3,                                                                                                               \
\
\ ; Default mono font
\
                Font,             FONT, "Liberation Mono": 16 : fwNormal : ffMonospaced,      \ ;
                NumFont,          FONT, "Liberation Mono": 13 : fwLight : 0

        DispSize "ASM theme data", $ - ASM

endg

Changes to freshlib/test_code0/TestAsmEdit.asm.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@BinaryType GUI, compact

options.DebugMode = 1
  options.DebugMode.NoTimers = 0
  options.DebugMode.XSync = 0
  options.DebugMode.XErrors =0

  options.DebugMode.ComputeFPS = 0
  options.DebugMode.ShowFPS = 0

options.ShowSizes = 1
options.SkipZeroSizes = 1

ThemeGUI equ flat_gui
;ThemeGUI equ win_gui








|
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@BinaryType GUI, compact

options.DebugMode = 1
  options.DebugMode.NoTimers = 0
  options.DebugMode.XSync = 0
  options.DebugMode.XErrors =0

  options.DebugMode.ComputeFPS = 1
  options.DebugMode.ShowFPS = 1

options.ShowSizes = 1
options.SkipZeroSizes = 1

ThemeGUI equ flat_gui
;ThemeGUI equ win_gui

Changes to freshlib/test_code0/test_utf8.asm.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;    should not be used as a library.
;#F:w
;    Това е тестов файл. Базиран е на strlib.asm но е модифициран и не бива да се използва като библиотека. В този тестов файл се използват форматиращи команди, които са съвместими с FASM и могат да се компилират без проблеми.
;    Αυτό είναι ένα δοκιμαστικό αρχείο. Βασίζεται σε strlib.asm αλλά έχει
;#F:b
;    τροποποιηθεί και δεν πρέπει να χρησιμοποιείται ως βιβλιοθήκη.
;    ეს არის გამოცდა ფაილი. ის ეფუძნება strlib.asm მაგრამ შეიცვალა და არ უნდა
;    იქნას გამოყენებული ბიბლიოთეკაში.
;_________________________________________________________________________________________

            mov  eax, '1234'
            mov  ecx, 1234

__StringLibrary:








|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;    should not be used as a library.
;#F:w
;    Това е тестов файл. Базиран е на strlib.asm но е модифициран и не бива да се използва като библиотека. В този тестов файл се използват форматиращи команди, които са съвместими с FASM и могат да се компилират без проблеми.
;    Αυτό είναι ένα δοκιμαστικό αρχείο. Βασίζεται σε strlib.asm αλλά έχει
;#F:b
;    τροποποιηθεί και δεν πρέπει να χρησιμοποιείται ως βιβλιοθήκη.
;    ეს არის გამოცდა ფაილი. ის ეფუძნება strlib.asm მაგრამ შეიცვალა და არ უნდა
;    იქნას გამოყენებული ბიბლიოთეკაში. 📌
;_________________________________________________________________________________________

            mov  eax, '1234'
            mov  ecx, 1234

__StringLibrary: