Fresh IDE . Check-in [765802a720]
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 the syntax highlighter. Fixed the text rendering with a syntax highlight.
Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:765802a7200723441d3f801092b58f759a2a091a
User & Date: johnfound 2019-04-30 22:05:27
Context
2019-05-01
07:13
More work on deleting characters and selections. Added backspace. Added handling of the trailing spaces. check-in: 0c75b62fae user: johnfound tags: NoCanvasGUI
2019-04-30
22:05
Work on the syntax highlighter. Fixed the text rendering with a syntax highlight. check-in: 765802a720 user: johnfound tags: NoCanvasGUI
2019-04-29
07:13
Deleting characters. check-in: 22f4724e5a user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to freshlib/gui/TAsmEdit.asm.

    73     73                           ;
    74     74     .             TText
    75     75   ends
    76     76   
    77     77   
    78     78   
    79     79   struct TTextChunk
    80         -  .len   dw ?   ; the length of the text chunk in BYTES (in Utf-8 chars???)
    81         -  .color db ?   ; the high order nibble encode the background, low order nibble encodes the text color.
           80  +  .len   dw ?   ; the length of the text chunk in UTF-8 characters.
           81  +  .color db ?   ; byte, index of the color/background of the text chunk.
    82     82     .flags db ?   ; the text formatting flags. not used, reserved. For example underlining, bold, etc...
    83     83   ends
    84     84   
    85     85   
    86     86   
    87     87   object TAsmEdit, TWindow
    88     88   
................................................................................
   225    225     method .Redo
   226    226   
   227    227   
   228    228   ; Text editing methods
   229    229   
   230    230     method .InsertNewLine, .LineNum
   231    231     method .DeleteLine, .LineNum
   232         -  method .DeleteChars, .LineNum, .From, .To
          232  +  method .DeleteChar
   233    233   
   234         -  method .JoinNextLine, .LineNum
          234  +  method .JoinNextLine, .LineNum        ; if .LineNum < 0; joins the current caret line
   235    235   
   236    236     method .DeleteSelection
   237    237     method .ReplaceSelection, .text
   238    238   
   239    239     method .InsertString, .text
   240    240   
   241    241   ; OS event handlers
................................................................................
  1142   1142   .ins_mask_ok:
  1143   1143           xor     eax, edx
  1144   1144           set     esi, TAsmEdit:Options, eax
  1145   1145           jmp     .endselect
  1146   1146   
  1147   1147   .delkey:
  1148   1148           exec    esi, TAsmEdit:DeleteSelection
  1149         -        jnc     .del_ok
         1149  +        jnc     .del_refresh
  1150   1150   
  1151         -        DebugMsg "No selection - delete the char under the caret."
         1151  +        exec    esi, TAsmEdit:DeleteChar
         1152  +        jnc     .del_refresh
  1152   1153   
  1153         -        exec    esi, TAsmEdit:TextLine, [esi+TAsmEdit._caretPos.y]
  1154         -        jc      .finish
  1155         -
  1156         -        mov     ebx, eax        ; TTextLine
  1157         -
  1158         -        OutputValue "TTextLine length = ", [ebx+TTextLine.ch_len], 16, 8
  1159         -        OutputValue "_caretPos.x = ", [esi+TAsmEdit._caretPos.x], 16, 8
  1160         -
  1161         -        mov     eax, [esi+TAsmEdit._caretPos.x]
  1162         -        inc     eax
  1163         -        cmp     eax, [ebx+TTextLine.ch_len]
  1164         -        jbe     .del_char
  1165         -
  1166         -        DebugMsg "Join the next line."
  1167         -
  1168         -        exec    esi, TAsmEdit:JoinNextLine, [esi+TAsmEdit._caretPos.y]
  1169         -        jmp     .del_refresh
  1170         -
  1171         -.del_char:
  1172         -        OutputValue "Delete char on line: ", [esi+TAsmEdit._caretPos.y], 10, -1
  1173         -        exec    esi, TAsmEdit:DeleteChars, [esi+TAsmEdit._caretPos.y], [esi+TAsmEdit._caretPos.x], eax
         1154  +        exec    esi, TAsmEdit:JoinNextLine, -1
  1174   1155   
  1175   1156   .del_refresh:
  1176   1157   
  1177   1158           and     [esi+TAsmEdit._img_txt_valid], 0
  1178   1159           and     [esi+TAsmEdit._img_margin_valid], 0
  1179   1160   
  1180   1161           exec    esi, TAsmEdit:RectChanged2, 0
  1181   1162           exec    esi, TAsmEdit:UpdateCaretPos
  1182   1163   
  1183         -.del_ok:
  1184   1164           exec    esi, TAsmEdit:SelChangeBegin
  1185   1165           exec    esi, TAsmEdit:SelStartHere
  1186   1166           exec    esi, TAsmEdit:SelEndHere
  1187   1167           exec    esi, TAsmEdit:SelChangeEnd
  1188   1168           jmp     .finish
  1189   1169   
  1190   1170   
................................................................................
  1437   1417           jae     .text_ok
  1438   1418   
  1439   1419           mov     edx, [edi+eax]
  1440   1420           cmp     [edx+TTextLine.syn_array], 0
  1441   1421           jne     .syn_ok
  1442   1422   
  1443   1423           stdcall [esi+TAsmEdit._syntax_proc], edx, [.context]
  1444         -        mov     [.context], eax
  1445   1424   
  1446   1425   .syn_ok:
  1447   1426           stdcall __RenderOneLine, [.pImage], edx, [.recta.left], [.recta.right], [.rectr.left], [.rectr.top]
  1448   1427   
  1449   1428           mov     eax, [edx+TTextLine.syn_context]
  1450   1429           mov     [.context], eax
  1451   1430   
................................................................................
  1688   1667   ; and now, scan for chunks and draw them
  1689   1668   
  1690   1669   .draw_chunk_loop:
  1691   1670   
  1692   1671           mov     ecx, esi              ; the start of the chunk text
  1693   1672   
  1694   1673   .inner_chunk_loop:
         1674  +        sub     [.chlen], 1
         1675  +        jc      .next_chunk           ; CF=1 only once.
  1695   1676   
  1696   1677           dec     [.toChar]
  1697   1678           js      .end_chunk_final      ; draw the final chunk and exits.
  1698   1679   
  1699         -        sub     [.chlen], 1
  1700         -        jc      .next_chunk           ; CF=1 only once.
  1701         -
  1702   1680           cmp     esi, [.gap_end]
  1703   1681           jae     .ofs_ok
  1704   1682   
  1705   1683           cmp     esi, [.gap_start]
  1706   1684           jb      .ofs_ok
  1707   1685   
  1708   1686           call    .draw_current_chunk
................................................................................
  1727   1705           sbb     eax, -2
  1728   1706   
  1729   1707           add     esi, eax
  1730   1708           jmp     .inner_chunk_loop
  1731   1709   
  1732   1710   
  1733   1711   .next_chunk:
  1734         -
  1735   1712           call    .draw_current_chunk
  1736   1713   
  1737   1714           mov     ebx, [.chunk]
  1738   1715           inc     ebx
  1739   1716           cmp     ebx, [edi+TArray.count]
  1740   1717           ja      .default_color
  1741   1718   
  1742   1719           movzx   edx, word [edi+ TArray.array + sizeof.TTextChunk * ebx + TTextChunk.len]
  1743   1720           jmp     .set_color
  1744   1721   
  1745         -
  1746   1722   .end_chunk_final:
  1747         -
  1748   1723           call    .draw_current_chunk
  1749   1724   
  1750   1725   
  1751   1726   .finish:
  1752   1727           popad
  1753   1728           return
  1754   1729   
................................................................................
  2534   2509           idiv    [esi+TAsmEdit._font_width]
  2535   2510           test    edx, edx
  2536   2511           jz      @f
  2537   2512           inc     eax
  2538   2513   @@:
  2539   2514           mov     [esi+TAsmEdit._width_ch], eax
  2540   2515   
  2541         -;        OutputValue "Screen width:", eax, 10, -1
  2542         -
  2543   2516   ; height
  2544   2517           mov     eax, [esi+TAsmEdit._height]
  2545   2518           cdq
  2546   2519   
  2547   2520           idiv    [esi+TAsmEdit._font_height]
  2548   2521           test    edx, edx
  2549   2522           jz      @f
  2550   2523           inc     eax
  2551   2524   @@:
  2552   2525           mov     [esi+TAsmEdit._height_ch], eax
  2553   2526   
  2554         -;        OutputValue "Screen height:", eax, 10, -1
  2555         -
  2556   2527           popad
  2557   2528   
  2558   2529   
  2559   2530   
  2560   2531           return
  2561   2532   endp
  2562   2533   
................................................................................
  2635   2606           xor     ecx, ecx
  2636   2607   
  2637   2608   .line_loop:
  2638   2609           stdcall DecodeUtf8, [edi]
  2639   2610           add     edi, edx
  2640   2611   
  2641   2612           test    eax, eax
  2642         -        jz      .end_text
         2613  +        jz      .cr_ok
  2643   2614   
  2644   2615           cmp     eax, $0d
  2645   2616           je      .new_line
  2646   2617           cmp     eax, $0a
  2647   2618           je      .new_line
  2648   2619   
  2649   2620           stdcall EncodeUtf8, eax
................................................................................
  2657   2628           jmp     .line_loop
  2658   2629   
  2659   2630   .new_line:
  2660   2631           xor     eax, $0d xor $0a
  2661   2632           cmp     [edi], al
  2662   2633           jne     .cr_ok
  2663   2634           inc     edi
         2635  +
  2664   2636   .cr_ok:
         2637  +        push    eax
  2665   2638   
  2666   2639           mov     esi, [esi]
  2667   2640           mov     [esi+TTextLine.ch_len], ecx
  2668   2641           stdcall IncCount, [ebx+TAsmEdit._line_widths], ecx
  2669   2642           mov     [ebx+TAsmEdit._line_widths], edx
  2670   2643   
  2671   2644           stdcall [ebx+TAsmEdit._syntax_proc], esi, [.context]
  2672   2645           mov     [.context], eax
  2673         -        jmp     .text_loop
  2674   2646   
         2647  +        pop     eax
         2648  +        test    eax, eax
         2649  +        jnz     .text_loop
  2675   2650   
  2676   2651   .end_text:
  2677         -
  2678   2652           exec    ebx, TAsmEdit:ComputeLeftMarginWidth
  2679   2653           exec    ebx, TAsmEdit:UpdateScrollBar
  2680   2654   
  2681   2655   
  2682   2656   .finish:
  2683   2657   
  2684   2658           popad
................................................................................
  2805   2779   
  2806   2780           sub     eax, ebx
  2807   2781           jle     .finish
  2808   2782   
  2809   2783           neg     edi
  2810   2784   
  2811   2785   .do_scroll:
  2812         -        DebugMsg "Do scroll."
  2813   2786   
  2814   2787           sub     eax, edi
  2815   2788           add     edx, eax
  2816   2789           cmovs   edx, ecx
  2817   2790   
  2818   2791           set     esi, TAsmEdit:PosY, edx
  2819   2792           exec    esi, TAsmEdit:RectChanged2, ecx
................................................................................
  3354   3327   
  3355   3328   method TAsmEdit.DeleteLine      ;, .LineNum
  3356   3329   begin
  3357   3330           return
  3358   3331   endp
  3359   3332   
  3360   3333   
  3361         -method TAsmEdit.DeleteChars     ;, .LineNum, .From, .To
         3334  +method TAsmEdit.DeleteChar
  3362   3335   begin
  3363   3336           pushad
  3364   3337   
  3365   3338           mov     esi, [.self]
  3366   3339           mov     edi, [esi+TAsmEdit._lines]
  3367         -        mov     ebx, [.LineNum]
         3340  +        mov     ebx, [esi+TAsmEdit._caretPos.y]
  3368   3341   
  3369   3342           shl     ebx, 2
  3370   3343           cmp     ebx, [edi+TText.GapBegin]
  3371   3344           jb      .skip
  3372   3345           add     ebx, [edi+TText.GapEnd]
  3373   3346           sub     ebx, [edi+TText.GapBegin]
  3374   3347   .skip:
  3375   3348           cmp     ebx, [edi+TText.Length]
  3376         -        jae     .finish
         3349  +        jae     .not_deleted
  3377   3350   
  3378   3351           mov     ebx, [edi+ebx]
  3379         -        stdcall TextIndexToPos, ebx, [.From]
  3380         -        jc      .finish
         3352  +        stdcall TextIndexToPos, ebx, [esi+TAsmEdit._caretPos.x]
         3353  +        jc      .not_deleted
  3381   3354   
  3382   3355           stdcall TextMoveGap, ebx, eax
  3383   3356           mov     edx, [ebx+TTextLine.GapEnd]
  3384         -        mov     ecx, [.From]
  3385         -
  3386         -.loop:
  3387         -        cmp     ecx, [.To]
  3388         -        jae     .end_scan
  3389         -
  3390   3357           cmp     edx, [ebx+TTextLine.Length]
  3391   3358           cmova   edx, [ebx+TTextLine.Length]
  3392         -        jae     .end_scan
         3359  +        jae     .not_deleted
  3393   3360   
  3394   3361           movzx   eax, byte [ebx+edx]
  3395   3362   
  3396   3363                                   ; compute the length of the UTF-8 character by its first byte (version without branches) Is it fast?
  3397   3364           not     al              ; utf-8 starts with one of: 0xxxxxxx, 110xxxxx, 1110xxxx, 11110xxx, 111110xx, 1111110x
  3398   3365           bsr     eax, eax        ; eax =                 7,  5,  4,  3,  2,  1
  3399   3366           sub     eax, 7          ; eax =                 0, -2, -3, -4, -5, -6
  3400   3367                                   ; CF  =                 0,  1,  1,  1,  1,  1
  3401   3368           not     eax             ; eax =                -1, +1, +2, +3, +4, +5
  3402   3369           sbb     eax, -2         ; eax = edx + 2 - CF = +1, +2, +3, +4, +5, +6
  3403   3370   
  3404   3371           add     edx, eax
  3405         -        inc     ecx
  3406         -        jmp     .loop
  3407         -
  3408         -.end_scan:
         3372  +        cmp     edx, [ebx+TTextLine.Length]
         3373  +        cmova   edx, [ebx+TTextLine.Length]
  3409   3374           mov     [ebx+TTextLine.GapEnd], edx
  3410         -        sub     ecx, [.From]
         3375  +
         3376  +        stdcall FreeMem, [ebx+TTextLine.syn_array]
         3377  +        and     [ebx+TTextLine.syn_array], 0            ; reset the syntax array of the line...
  3411   3378   
  3412   3379           stdcall DecCount, [esi+TAsmEdit._line_widths], [ebx+TTextLine.ch_len]
  3413         -        sub     [ebx+TTextLine.ch_len], ecx
         3380  +        dec     [ebx+TTextLine.ch_len]
  3414   3381           stdcall IncCount, edx, [ebx+TTextLine.ch_len]
  3415   3382           mov     [esi+TAsmEdit._line_widths], edx
  3416   3383   
  3417   3384           and     [esi+TAsmEdit._img_txt_valid], 0
  3418   3385           and     [esi+TAsmEdit._img_margin_valid], 0
  3419   3386           exec    esi, TAsmEdit:RectChanged2, 0
  3420   3387           exec    esi, TAsmEdit:UpdateCaretPos
  3421   3388   
  3422         -.finish:
         3389  +        clc
         3390  +        popad
         3391  +        return
         3392  +
         3393  +.not_deleted:
         3394  +        stc
  3423   3395           popad
  3424   3396           return
  3425   3397   endp
  3426   3398   
  3427   3399   
  3428         -method TAsmEdit.JoinNextLine    ;, .LineNum
         3400  +method TAsmEdit.JoinNextLine    ; .LineNum
  3429   3401   begin
  3430   3402           pushad
  3431   3403   
  3432   3404           mov     esi, [.self]
  3433   3405           mov     edi, [esi+TAsmEdit._lines]
  3434   3406           mov     ebx, [.LineNum]
         3407  +        test    ebx, ebx
         3408  +        cmovs   ebx, [esi+TAsmEdit._caretPos.y]
  3435   3409   
  3436   3410           shl     ebx, 2
  3437   3411           lea     ecx, [ebx+4]
  3438   3412   
  3439         -        cmp     ebx, [edi+TText.GapBegin]
  3440         -        jb      .skip1
  3441         -        add     ebx, [edi+TText.GapEnd]
  3442         -        sub     ebx, [edi+TText.GapBegin]
  3443         -.skip1:
         3413  +        stdcall TextMoveGap, edi, ecx   ; move the gap between the two lines.
  3444   3414   
  3445         -        cmp     ecx, [edi+TText.GapBegin]
  3446         -        jb      .skip2
         3415  +; here ebx is before the gap and ecx is after!
         3416  +
  3447   3417           add     ecx, [edi+TText.GapEnd]
  3448   3418           sub     ecx, [edi+TText.GapBegin]
  3449         -.skip2:
  3450   3419           cmp     ecx, [edi+TText.Length]
  3451   3420           jae     .finish ; nothing to join
  3452   3421   
  3453   3422           cmp     ebx, [edi+TText.Length]
  3454   3423           jae     .finish
         3424  +
         3425  +        add     [edi+TText.GapEnd], 4   ; free the place of the next line...
  3455   3426   
  3456   3427   ; first fix the new line widths...
  3457   3428   
  3458   3429           mov     edx, [esi+TAsmEdit._line_widths]
  3459   3430   
  3460   3431           mov     eax, [edi+ebx]
  3461   3432           push    [eax+TTextLine.ch_len]
................................................................................
  3476   3447           mov     [esi+TAsmEdit._line_widths], edx
  3477   3448   
  3478   3449   ; then join the texts
  3479   3450   
  3480   3451           stdcall TextAddText, [edi+ebx], -1, [edi+ecx]
  3481   3452           mov     [edi+ebx], edx
  3482   3453   
  3483         -; then delete the next line
         3454  +; then free the next line TTextLine structure...
  3484   3455   
  3485   3456           mov     eax, [edi+ecx]
  3486   3457           stdcall FreeMem, [eax+TTextLine.syn_array]
  3487   3458           stdcall TextFree, eax     ; delete the next line... but what about the debug info and other attributes?
  3488   3459   
  3489         -; reset the syntax coloring of the new line
         3460  +; reset the syntax coloring of the result line
  3490   3461           mov     eax, [edi+ebx]
  3491   3462           stdcall FreeMem, [eax+TTextLine.syn_array]
  3492   3463           and     [eax+TTextLine.syn_array], 0
  3493   3464   
  3494         -        mov     eax, [.LineNum]
  3495         -        lea     eax, [4*eax+4]
  3496         -        stdcall TextMoveGap, edi, eax
  3497         -        add     [edi+TText.GapEnd], 4
  3498         -
  3499   3465   .finish:
  3500   3466           popad
  3501   3467           return
  3502   3468   endp
  3503   3469   
  3504   3470   
  3505   3471   
................................................................................
  3508   3474   .list dd ?
  3509   3475   begin
  3510   3476           pushad
  3511   3477   
  3512   3478           exec    [.self], TAsmEdit:_AddSelRectanglesAbs, 0
  3513   3479           mov     [.list], edx
  3514   3480   
  3515         -        OutputValue "Selection array count: ", [edx+TArray.count], 10, -1
  3516         -
  3517   3481           lea     edi, [edx+TArray.array]
  3518   3482           mov     ecx, [edx+TArray.count]
  3519   3483           test    ecx, ecx
  3520   3484           jz      .exit_empty
  3521   3485   
  3522   3486           mov     eax, ecx
  3523   3487           shl     eax, 4  ; sizeof.RECT
................................................................................
  3525   3489   
  3526   3490   .rect_loop:
  3527   3491   
  3528   3492           sub     edi, sizeof.RECT
  3529   3493           dec     ecx
  3530   3494           js      .finish
  3531   3495   
  3532         -        OutputValue "RECT.left =", [edi+RECT.left], 10, -1
  3533         -        OutputValue "RECT.top =", [edi+RECT.top], 10, -1
  3534         -        OutputValue "RECT.right =", [edi+RECT.right], 10, -1
  3535         -        OutputValue "RECT.bottom =", [edi+RECT.bottom], 10, -1
  3536         -
  3537   3496           mov     ebx, [edi+RECT.bottom]
  3538   3497   
  3539   3498   .y_loop:
  3540   3499           dec     ebx
  3541   3500           cmp     ebx, [edi+RECT.top]
  3542   3501           jl      .rect_loop
  3543   3502   
................................................................................
  3613   3572   .exit:
  3614   3573           stdcall FreeMem, [.list]
  3615   3574           clc
  3616   3575           popad
  3617   3576           return
  3618   3577   
  3619   3578   .exit_empty:
  3620         -        DebugMsg "Exit delete selection EMPTY!"
  3621   3579   
  3622   3580           stdcall FreeMem, [.list]
  3623   3581           stc
  3624   3582           popad
  3625   3583           return
  3626   3584   endp
  3627   3585   

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

    33     33   ;   .pLineInfo - pointer to TTextLine structure.
    34     34   ;   .SynContext - input context of the highligher.
    35     35   ;
    36     36   ; Returns:
    37     37   ;       eax - output context of the highligher.
    38     38   ;
    39     39   proc SyntaxFASM, .pTextLine, .SynContext
    40         -.Quo   rb 4
    41         -.start dd ?
           40  +.Quo   dd ?
           41  +.cnt   dd ?
    42     42   begin
    43     43           pushad
    44     44   
    45     45           mov     esi, [.pTextLine]
    46     46   
    47     47           mov     edi, [esi+TTextLine.syn_array]
    48     48           test    edi, edi
................................................................................
    53     53           mov     [esi+TTextLine.syn_array], eax
    54     54   
    55     55   .array_ok:
    56     56   
    57     57           xor     ebx, ebx                ; the offset inside the line.
    58     58           xor     edx, edx
    59     59   
    60         -        mov     [.Quo], bl
           60  +        mov     [.Quo], ebx
    61     61           mov     [edi+TArray.count], ebx
    62         -        mov     [.start], ebx
           62  +        mov     [.cnt], ebx
           63  +        dec     [.cnt]
    63     64   
    64     65   .loop:
    65     66           add     ebx, edx
           67  +        inc     [.cnt]
    66     68   
    67     69           mov     eax, [esi+TTextLine.GapBegin]
    68     70           cmp     ebx, eax
    69     71           cmovae  eax, [esi+TTextLine.GapEnd]
    70     72           sub     eax, [esi+TTextLine.GapBegin]
    71     73           add     eax, ebx
    72     74   
    73     75           cmp     eax, [esi+TTextLine.Length]
    74     76           jae     .end_of_line
    75     77   
    76     78           stdcall DecodeUtf8, [esi+eax]
    77     79   
           80  +;        OutputValue "Char: ", eax, 16, 8
           81  +
    78     82           cmp     [.SynContext], ciComment
    79         -        je      .endif
           83  +        je      .loop
    80     84   
    81     85           cmp     [.SynContext], ciString
    82     86           jne     .ifnotstr
    83     87   
    84         -        cmp     al,[.Quo]
    85         -        jne     .endif
           88  +        cmp     eax,[.Quo]
           89  +        jne     .loop
    86     90   
    87     91           add     ebx, edx
    88     92           xor     edx, edx
    89     93           call    .end_chunk
    90     94           mov     [.SynContext], ciText
    91     95           jmp     .loop
    92     96   
    93     97   .ifnotstr:
    94         -        cmp     al, ';'
           98  +        cmp     eax, $ff
           99  +        ja      .text
          100  +
          101  +        cmp     eax, ';'
    95    102           jne     .notrem
    96    103   
    97    104           call    .end_chunk
    98    105           mov     [.SynContext], ciComment
    99         -        jmp     .endif
          106  +        jmp     .loop
   100    107   
   101    108   .notrem:
   102         -        cmp     al, '"'
          109  +        cmp     eax, '"'
   103    110           je      .str
   104         -        cmp     al, "'"
          111  +        cmp     eax, "'"
   105    112           jne     .notstr
   106    113   
   107    114   .str:
   108    115           call    .end_chunk
   109    116           mov     [.SynContext], ciString
   110         -        mov     [.Quo], al
   111         -        jmp     .endif
          117  +        mov     [.Quo], eax
          118  +        jmp     .loop
   112    119   
   113    120   .notstr:
   114    121           call    .CharInSymbols
   115    122           jnc     .notsym
          123  +
          124  +        cmp     [.SynContext], ciSymbol
          125  +        je      .loop
   116    126   
   117    127           call    .end_chunk
   118    128           mov     [.SynContext], ciSymbol
   119         -        jmp     .endif
          129  +        jmp     .loop
   120    130   
   121    131   .notsym:
   122    132           cmp     [.SynContext], ciNumber
   123         -        je      .endif
          133  +        je      .loop
   124    134   
   125         -        cmp     ebx, [.start]
          135  +        cmp     [.cnt], 0
   126    136           je      .maybenum
   127    137   
   128    138           cmp     [.SynContext], ciSymbol
   129         -        jne     .endif
          139  +        jne     .text
   130    140   
   131    141   ; The number begins only after ttChar or at the begining of the line.
   132    142   .maybenum:
   133         -        call    .CharInNum
   134         -        jnc     .notnum
          143  +        cmp     al, '$'
          144  +        je      .num_start
   135    145   
          146  +        cmp     al, '-'
          147  +        je      .num_start
          148  +
          149  +        cmp     al, '0'
          150  +        jb      .text
          151  +        cmp     al, '9'
          152  +        ja      .text
          153  +
          154  +.num_start:
   136    155           call    .end_chunk
   137    156           mov     [.SynContext], ciNumber
   138         -        jmp     .endif
          157  +        jmp     .loop
   139    158   
   140         -.notnum:
          159  +.text:
          160  +        cmp     [.SynContext], ciText
          161  +        je      .loop
          162  +
   141    163           call    .end_chunk
   142    164           mov     [.SynContext], ciText
   143         -
   144         -.endif:
   145    165           jmp     .loop
   146    166   
   147    167   
   148    168   .end_of_line:
   149    169           call    .end_chunk
   150    170   
   151    171   ;        mov     eax, [.SynContext]
................................................................................
   157    177           popad
   158    178           return
   159    179   
   160    180   
   161    181   .end_chunk:
   162    182           push    eax ecx edx
   163    183   
   164         -        mov     ecx, ebx
   165         -        sub     ecx, [.start]
          184  +        mov     ecx, [.cnt]
          185  +        test    ecx, ecx
   166    186           jz      .chunk_processed
   167    187   
   168         -        mov     [.start], ebx
          188  +        and     [.cnt], 0
          189  +
   169    190           stdcall AddArrayItems, edi, 1
   170    191           mov     edi, edx
   171    192           jc      .chunk_processed
   172    193   
          194  +;        OutputValue "Chunk length: ", ecx, 16, 8
          195  +
   173    196           mov     [eax+TTextChunk.len], cx
   174    197           mov     ecx, [.SynContext]
   175    198           mov     [eax+TTextChunk.color], cl
          199  +
          200  +;        OutputValue "Chunk color: ", ecx, 16, 8
   176    201   
   177    202   .chunk_processed:
   178    203           pop     edx ecx eax
   179    204           retn
   180    205   
   181    206   
   182    207   .CharInSymbols:
................................................................................
   190    215           stc
   191    216           pop     ecx edi
   192    217           ret
   193    218   @@:
   194    219           clc
   195    220           pop     ecx edi
   196    221           retn
   197         -
   198         -
   199         -.CharInNum:
   200         -        cmp     al, '$'
   201         -        jne     @f
   202         -        stc
   203         -        retn
   204         -
   205         -@@:
   206         -        cmp     al, '0'
   207         -        jb      @f
   208         -        cmp     al, '9'
   209         -        ja      @f
   210         -        stc
   211         -        retn
   212         -@@:
   213         -        clc
   214         -        retn
   215         -
   216    222   
   217    223   .symbol_characters db 27
   218    224                     db 9,0Ah,0Dh,1Ah,20h,'+-/*=<>()[]{}:,|&~#`;\'
   219    225   
   220    226   endp
   221    227   
   222    228   
................................................................................
   249    255   
   250    256           mov     [.Quo], bl
   251    257           mov     [edi+TArray.count], ebx
   252    258           mov     [.start], ebx
   253    259   
   254    260   .loop:
   255    261           add     ebx, edx
   256         -        cmp     ebx, [esi+TTextLine.TextLen]
   257         -        jae     .end_of_line
   258    262   
   259    263           mov     eax, ebx
   260    264           pos2ofs eax, esi
          265  +
          266  +        cmp     eax, [esi+TTextLine.Length]
          267  +        jae     .end_of_line
   261    268   
   262    269           stdcall DecodeUtf8, [esi+eax]
   263    270   
   264    271           cmp     [.SynContext], ciComment
   265    272           je      .endif
   266    273   
   267    274           cmp     [.SynContext], ciString

Changes to freshlib/test_code0/TestAsmEdit.asm.

    94     94                        x = 10, y = 40, width = 200, height = 200, \
    95     95                        SplitCell = SplitTest.cellAsmEdit,         \
    96     96                        Visible = TRUE
    97     97   
    98     98   
    99     99   ;utf8_long file "unicode_test.txt"
   100    100   utf8_long file "test_utf8.asm"
          101  +
          102  +;utf8_long db  "Test one line"
   101    103             dd   0
   102    104   
   103    105   
   104    106   
   105    107   if ThemeGUI eq win_gui
   106    108     getfile imgArrowRight, '_test_images/right2.png'
   107    109   end if