Fresh IDE . Check-in [f313647175]
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, related to the text editing.

Work on TMenu - implemented menu template similar to the old CoolMenu and procedure MenuFromTemplate that creates the whole menu tree from the template.

The functions "read" and "write" removed from the pthreads import library, because in conflict with FASM interface procedures. I am not sure why these functions are there, but they are not used after all.

Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:f313647175f797cf9a35888a48c20dfbf0eb9457
User & Date: johnfound 2019-05-03 21:00:04
Context
2019-05-07
21:38
A lot of changes as a result of activated work on Fresh v3.x

TToolbar control implemented. In very primitive state, but works somehow.

New StrNormalizePath2 function, together with the OS dependent path functions IsPathRelative and GetPrefix. They are aimed to provide OS independent way for path processing.

Fixed serious bugs in the GUI part, related to windows nested in more than 2 levels. It turned that the library was never tested with such windows before...

A lot of new functionality and correct behavior in the GUI part. Now the TAction accelerator keys are assigned through the StrToAccelerator function directly from the templates. check-in: 6639367637 user: johnfound tags: NoCanvasGUI

2019-05-03
21:00
Work on TAsmEdit, related to the text editing.

Work on TMenu - implemented menu template similar to the old CoolMenu and procedure MenuFromTemplate that creates the whole menu tree from the template.

The functions "read" and "write" removed from the pthreads import library, because in conflict with FASM interface procedures. I am not sure why these functions are there, but they are not used after all. check-in: f313647175 user: johnfound tags: NoCanvasGUI

2019-05-02
09:36
The method TAsmEdit:SplitLine implemented. check-in: 8a219674f9 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/gui/TAsmEdit.asm.

224
225
226
227
228
229
230


231
232
233
234
235
236
237
...
864
865
866
867
868
869
870


































871
872
873
874
875
876
877
...
887
888
889
890
891
892
893

894
895




896






897
898
899
900
901
902
903
...
911
912
913
914
915
916
917



918
919
920
921
922
923
924
925
926
....
1053
1054
1055
1056
1057
1058
1059






1060













1061
1062
1063
1064




1065
1066
1067





1068
1069
1070
1071
1072
1073
1074
....
1183
1184
1185
1186
1187
1188
1189
1190


1191
1192
1193
1194
1195

1196
1197
1198
1199
1200
1201
1202
....
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
....
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
....
2704
2705
2706
2707
2708
2709
2710


2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731

2732
2733
2734
2735







2736
2737

2738
2739








2740
2741
2742
2743
2744
2745
2746
....
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879

2880
2881
2882
2883
2884
2885
2886
....
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
....
3183
3184
3185
3186
3187
3188
3189




3190
3191
3192
3193
3194
3195
3196
....
3718
3719
3720
3721
3722
3723
3724


3725
3726
3727
3728
3729
3730
3731
....
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
....
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
....
3890
3891
3892
3893
3894
3895
3896

3897
3898
3899
3900
3901
3902
3903
....
3956
3957
3958
3959
3960
3961
3962
3963





3964






3965
3966
3967
3968
3969
3970
3971
....
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026


4027


4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043

  method .SaveForUndo, .LineNum, .operation
  method .Undo
  method .Redo


; Text editing methods



  method .InsertNewLine, .LineNum
  method .DeleteLine, .LineNum
  method .DeleteChar, .LineNum, .CharPos

  method .JoinNextLine, .LineNum        ; if .LineNum < 0; joins the current caret line
  method .SplitLine, .LineNum, .PosX    ; if .LineNum < 0 splits on caret position.
................................................................................

.finish:
        popad
        return
endp





































method TAsmEdit.EventKeyPress
.selCmd dd ?
begin
        pushad

        mov     esi, [.self]
................................................................................
        jb      .ctrl_char

        cmp     eax, $7f
        je      .no_char

; here handle usual typing!



        jmp     .finish












.ctrl_char:

        cmp     eax, 26         ; Ctrl+Z
        je      .do_undo

        cmp     eax, 3          ; Ctrl+C
................................................................................

        cmp     eax, 5          ; Ctrl+E
        je      .select_end

        cmp     eax, 8          ; BackSpace
        je      .backspacekey




        cmp     eax, 13         ; Ctrl+K
        je      .split_line

        jmp     .finish


.copy_to_clipboard:

        stdcall ClipboardWrite, <"This is clipboard test.", 13, 10>
................................................................................
        cmp     eax, keyDelNumpad
        je      .delkey
        cmp     eax, keyDelete
        je      .delkey

        jmp     .endselect





















.split_line:

        exec    esi, TAsmEdit:SplitLine, -1, 0





        and     [esi+TAsmEdit._img_txt_valid], 0
        and     [esi+TAsmEdit._img_margin_valid], 0
        exec    esi, TAsmEdit:RectChanged2, 0





        jmp     .finish

.refresh:
        xor     eax, eax
        mov     [esi+TAsmEdit._img_txt_valid], eax
        mov     [esi+TAsmEdit._img_margin_valid], eax
        exec    esi, TAsmEdit:RectChanged2, eax
................................................................................
.delkey:
        exec    esi, TAsmEdit:DeleteSelection
        jnc     .del_refresh

        exec    esi, TAsmEdit:AddTrailingSpaces, -1, 0

        exec    esi, TAsmEdit:DeleteChar, -1, 0
        jnc     .del_refresh



        test    [esi+TAsmEdit._options], aeoOverwriteMode
        jnz     .finish

        exec    esi, TAsmEdit:JoinNextLine, -1


.del_refresh:
        exec    esi, TAsmEdit:DelTrailingSpaces, -1

        and     [esi+TAsmEdit._img_txt_valid], 0
        and     [esi+TAsmEdit._img_margin_valid], 0

................................................................................
        exec    esi, TAsmEdit:UpdateCaretPos

        exec    esi, TAsmEdit:SelChangeBegin
        exec    esi, TAsmEdit:SelStartHere
        exec    esi, TAsmEdit:SelEndHere
        exec    esi, TAsmEdit:SelChangeEnd

        inc     [AsmEditUndoGroup]
        jmp     .finish

.endselect:
        cmp     [esi+TAsmEdit._selCmd], 0
        je      .finish

        exec    esi, TAsmEdit:SelEndHere
................................................................................

.y_loop:
        dec     ebx
        cmp     ebx, [edi+RECT.top]
        jl      .next_rect

        exec    [.self], TAsmEdit:TextLine, ebx
        mov     esi, eax

        mov     eax, [esi+TTextLine.ch_len]
        cmp     eax, [edi+RECT.right]
        cmova   eax, [edi+RECT.right]

        stdcall TextIndexToPos, esi, eax   ; move the gap after the rectangle right bound.
        push    eax
................................................................................





; Navigation manipulation methods.



method TAsmEdit.TextLine  ; .y
begin
        push    esi

        mov     eax, [.self]
        mov     esi, [eax+TAsmEdit._lines]

        mov     eax, [.y]
        shl     eax, 2

        cmp     eax, [esi+TText.GapBegin]
        jb      @f
        add     eax, [esi+TText.GapEnd]
        sub     eax, [esi+TText.GapBegin]
@@:
        cmp     eax, [esi+TText.Length]
        jae     .error

        mov     eax, [esi+eax]

        clc

        pop     esi
        return

.error:







        xor     eax, eax
        stc

        pop     esi
        return








endp



method TAsmEdit.ScrollToCaretX
begin
        pushad
................................................................................
        jmp     .finish

.leftok:
        test    [esi+TAsmEdit._options], aeoNavXCaretWrap
        jz      .set_pos

        exec    esi, TAsmEdit:TextLine, [esi+TAsmEdit._caretPos.y]
        cmovc   ebx, edx
        jc      .set_pos


        cmp     ebx, [eax+TTextLine.ch_len]
        jbe     .set_pos

        exec    esi, TAsmEdit:CaretUpDown, 1, FALSE
        exec    esi, TAsmEdit:CaretHome
        jmp     .finish

................................................................................

method TAsmEdit.CaretEnd
begin
        push    esi
        mov     esi, [.self]

        exec    esi, TAsmEdit:TextLine, [esi+TAsmEdit._caretPos.y]      ; returns CF=1 and eax=0 on error.
        jc      .set_pos

        mov     eax, [eax+TTextLine.ch_len]

.set_pos:
        mov     [esi+TAsmEdit._caretPos.x], eax
        exec    esi, TAsmEdit:ScrollToCaretX

.finish:
        pop     esi
        return
endp


method TAsmEdit.CaretScrHome
begin
................................................................................
        jz      .add_new

        cmp     [edx+TUndoInfo.line], ebx
        jne     .add_new

        cmp     ecx, chopChanged
        jne     .add_new





        cmp     [edx+TUndoInfo.operation], ecx
        je      .finish                         ; group the chopChanged for the same line.

; add new record in the chain.

.add_new:
................................................................................
        mov     ecx, [.PosX]
        test    ebx, ebx
        cmovs   ebx, [esi+TAsmEdit._caretPos.y]
        cmovs   ecx, [esi+TAsmEdit._caretPos.x]
        mov     [.LineNum], ebx
        mov     [.PosX], ecx



        inc     ebx
        exec    esi, TAsmEdit:InsertNewLine, ebx
        mov     edi, eax
        exec    esi, TAsmEdit:SaveForUndo, ebx, chopInserted

        mov     edx, [esi+TAsmEdit._lines]
        mov     ebx, [edx+4*ebx-4]                ; the gap, after the InsertNewLine is located just after the ebx line.
................................................................................

method TAsmEdit.DeleteSelection
.rect RECT
.list dd ?
begin
        pushad

        inc     [AsmEditUndoGroup]

        exec    [.self], TAsmEdit:_AddSelRectanglesAbs, 0
        mov     [.list], edx

        lea     edi, [edx+TArray.array]
        mov     ecx, [edx+TArray.count]
        test    ecx, ecx
        jz      .exit_empty
................................................................................
        cmp     ebx, [edi+RECT.top]
        jl      .rect_loop

        exec    [.self], TAsmEdit:SaveForUndo, ebx, chopChanged

        exec    [.self], TAsmEdit:AddTrailingSpaces, ebx, [edi+RECT.left]
        exec    [.self], TAsmEdit:TextLine, ebx
        jc      .y_loop
        mov     esi, eax

        stdcall TextIndexToPos, esi, [edi+RECT.left]
        stdcall TextMoveGap, esi, eax

        mov     eax, [esi+TTextLine.ch_len]
        cmp     eax, [edi+RECT.right]
        cmova   eax, [edi+RECT.right]                   ; delete up to the min(length, RECT.right) utf-8 character position!
................................................................................
        exec    esi, TAsmEdit:_RenderTxt, [esi+TAsmEdit._imgText], eax
        exec    esi, TAsmEdit:_RenderLM, [esi+TAsmEdit._imgMargin], [.rect.top], [.rect.bottom]
        exec    esi, TAsmEdit:RectChanged2, 0
        exec    esi, TAsmEdit:ScrollToCaretX
        exec    esi, TAsmEdit:ScrollToCaretY

.exit:

        stdcall FreeMem, [.list]
        clc
        popad
        return

.exit_empty:

................................................................................
        jae     .finish         ; the line is outside the text. Add empty lines???

        mov     edx, [edi+ebx]

        mov     ecx, [.PosX]
        sub     ecx, [edx+TTextLine.ch_len]
        jle     .finish                         ; the caret is inside the line.






        add     [edx+TTextLine.ch_len], ecx






        stdcall TextMoveGap, edx, -1
        stdcall TextSetGapSize, edx, ecx
        mov     [edi+ebx], edx

        mov     edi, edx
        add     edi, [edx+TTextLine.GapBegin]
        add     [edx+TTextLine.GapBegin], ecx
................................................................................
        jb      .skip
        add     ebx, [edi+TText.GapEnd]
        sub     ebx, [edi+TText.GapBegin]
.skip:
        cmp     ebx, [edi+TText.Length]
        jae     .finish         ; the line is outside the text. Add empty lines???

        mov     edx, [edi+ebx]

        stdcall TextMoveGap, edx, -1

        mov     edi, edx
        add     edi, [edx+TTextLine.GapBegin]

; search back the first non-whitespace...

.loop:
        dec     edi
        cmp     edi, edx
        jl      .found

        cmp     byte [edi], ' '
        jbe     .loop

.found:
        inc     edi
        mov     ecx, edi
        sub     ecx, edx

        xchg    ecx, [edx+TTextLine.GapBegin]
        sub     ecx, [edx+TTextLine.GapBegin]


        sub     [edx+TTextLine.ch_len], ecx



        stdcall FreeMem, [edx+TTextLine.syn_array]
        and     [edx+TTextLine.syn_array], 0

.finish:
        popad
        return
endp



endmodule


include "themes/asmedit.asm"
include "syntax/SyntaxFASM.asm"







>
>







 







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







 







>

<
>
>
>
>

>
>
>
>
>
>







 







>
>
>
|
|







 







>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
|



>
>
>
>



>
>
>
>
>







 







|
>
>





>







 







<







 







|







 







>
>


|













|

|

<
>
|


|
>
>
>
>
>
>
>
|
<
>
|
<
>
>
>
>
>
>
>
>







 







<
<

>







 







|
<


<



<







 







>
>
>
>







 







>
>







 







<
<







 







<
|







 







>







 








>
>
>
>
>

>
>
>
>
>
>







 







|

|

|
|




|
|


|



|
|
|

|
|
>
>
|
>
>

|
|













224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
...
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
...
923
924
925
926
927
928
929
930
931

932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
...
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
....
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
....
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
....
1284
1285
1286
1287
1288
1289
1290

1291
1292
1293
1294
1295
1296
1297
....
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
....
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811

2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824

2825
2826

2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
....
2965
2966
2967
2968
2969
2970
2971


2972
2973
2974
2975
2976
2977
2978
2979
2980
....
3059
3060
3061
3062
3063
3064
3065
3066

3067
3068

3069
3070
3071

3072
3073
3074
3075
3076
3077
3078
....
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
....
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
....
3883
3884
3885
3886
3887
3888
3889


3890
3891
3892
3893
3894
3895
3896
....
3912
3913
3914
3915
3916
3917
3918

3919
3920
3921
3922
3923
3924
3925
3926
....
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
....
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
....
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153

  method .SaveForUndo, .LineNum, .operation
  method .Undo
  method .Redo


; Text editing methods

  method .AddChar, .utf8

  method .InsertNewLine, .LineNum
  method .DeleteLine, .LineNum
  method .DeleteChar, .LineNum, .CharPos

  method .JoinNextLine, .LineNum        ; if .LineNum < 0; joins the current caret line
  method .SplitLine, .LineNum, .PosX    ; if .LineNum < 0 splits on caret position.
................................................................................

.finish:
        popad
        return
endp



method TAsmEdit.AddChar ;, .utf8
begin
        pushad

        mov     esi, [.self]
        mov     ebx, [esi+TAsmEdit._caretPos.y]
        exec    esi, TAsmEdit:TextLine, ebx
        mov     edi, eax

        exec    esi, TAsmEdit:SaveForUndo, ebx, chopChanged
        exec    esi, TAsmEdit:AddTrailingSpaces, ebx, [esi+TAsmEdit._caretPos.x]

        stdcall TextMoveGap, [edi], [esi+TAsmEdit._caretPos.x]
        stdcall TextAddChar, [edi], [.utf8]
        mov     [edi], edx

        push    [edx+TTextLine.ch_len]
        inc     [edx+TTextLine.ch_len]
        push    [edx+TTextLine.ch_len]

        stdcall IncCount, [esi+TAsmEdit._line_widths]   ; count from the stack!
        stdcall DecCount, edx                           ; count from the stack!
        mov     [esi+TAsmEdit._line_widths], edx

        exec    esi, TAsmEdit:DelTrailingSpaces, [esi+TAsmEdit._caretPos.y]
        exec    esi, TAsmEdit:CaretLeftRight, 1

        popad
        return
endp




method TAsmEdit.EventKeyPress
.selCmd dd ?
begin
        pushad

        mov     esi, [.self]
................................................................................
        jb      .ctrl_char

        cmp     eax, $7f
        je      .no_char

; here handle usual typing!

        exec    esi, TAsmEdit:AddChar, eax


        exec    esi, TAsmEdit:ComputeLeftMarginWidth
        exec    esi, TAsmEdit:__UpdateImages
        exec    esi, TAsmEdit:UpdateScrollBar
        exec    esi, TAsmEdit:UpdateCaretPos

        xor     eax, eax
        mov     [esi+TAsmEdit._img_txt_valid], eax
        mov     [esi+TAsmEdit._img_margin_valid], eax
        exec    esi, TAsmEdit:RectChanged2, eax

        jmp     .finish

.ctrl_char:

        cmp     eax, 26         ; Ctrl+Z
        je      .do_undo

        cmp     eax, 3          ; Ctrl+C
................................................................................

        cmp     eax, 5          ; Ctrl+E
        je      .select_end

        cmp     eax, 8          ; BackSpace
        je      .backspacekey

        cmp     eax, 9          ; tab
        je      .tabkey

        cmp     eax, 13         ; Enter
        je      .enterkey

        jmp     .finish


.copy_to_clipboard:

        stdcall ClipboardWrite, <"This is clipboard test.", 13, 10>
................................................................................
        cmp     eax, keyDelNumpad
        je      .delkey
        cmp     eax, keyDelete
        je      .delkey

        jmp     .endselect

.tabkey:
        mov     ecx, [esi+TAsmEdit._caretPos.x]
        inc     ecx
        add     ecx, 7
        and     ecx, $fffffff8
        sub     ecx, [esi+TAsmEdit._caretPos.x]

.spadd:
        exec    esi, TAsmEdit:AddChar, ' '
        loop    .spadd

        xor     eax, eax
        mov     [esi+TAsmEdit._img_txt_valid], eax
        mov     [esi+TAsmEdit._img_margin_valid], eax
        exec    esi, TAsmEdit:RectChanged2, eax
        jmp     .finish


.enterkey:
        test    [esi+TAsmEdit._options], aeoOverwriteMode
        jnz     .split_ok

        exec    esi, TAsmEdit:SplitLine, -1, 0

.split_ok:
        exec    esi, TAsmEdit:CaretUpDown, 1, FALSE
        exec    esi, TAsmEdit:CaretHome

        and     [esi+TAsmEdit._img_txt_valid], 0
        and     [esi+TAsmEdit._img_margin_valid], 0
        exec    esi, TAsmEdit:RectChanged2, 0

        exec    esi, TAsmEdit:ComputeLeftMarginWidth
        exec    esi, TAsmEdit:__UpdateImages
        exec    esi, TAsmEdit:UpdateScrollBar
        exec    esi, TAsmEdit:UpdateCaretPos
        jmp     .finish

.refresh:
        xor     eax, eax
        mov     [esi+TAsmEdit._img_txt_valid], eax
        mov     [esi+TAsmEdit._img_margin_valid], eax
        exec    esi, TAsmEdit:RectChanged2, eax
................................................................................
.delkey:
        exec    esi, TAsmEdit:DeleteSelection
        jnc     .del_refresh

        exec    esi, TAsmEdit:AddTrailingSpaces, -1, 0

        exec    esi, TAsmEdit:DeleteChar, -1, 0
        jnc     .del_refresh                            ; notice that the undo/redo group is not increased in order to allow
                                                        ; another change operations on this line to be grouped in one TUndoInfo
                                                        ; structure.

        test    [esi+TAsmEdit._options], aeoOverwriteMode
        jnz     .finish

        exec    esi, TAsmEdit:JoinNextLine, -1
        inc     [AsmEditUndoGroup]

.del_refresh:
        exec    esi, TAsmEdit:DelTrailingSpaces, -1

        and     [esi+TAsmEdit._img_txt_valid], 0
        and     [esi+TAsmEdit._img_margin_valid], 0

................................................................................
        exec    esi, TAsmEdit:UpdateCaretPos

        exec    esi, TAsmEdit:SelChangeBegin
        exec    esi, TAsmEdit:SelStartHere
        exec    esi, TAsmEdit:SelEndHere
        exec    esi, TAsmEdit:SelChangeEnd


        jmp     .finish

.endselect:
        cmp     [esi+TAsmEdit._selCmd], 0
        je      .finish

        exec    esi, TAsmEdit:SelEndHere
................................................................................

.y_loop:
        dec     ebx
        cmp     ebx, [edi+RECT.top]
        jl      .next_rect

        exec    [.self], TAsmEdit:TextLine, ebx
        mov     esi, [eax]

        mov     eax, [esi+TTextLine.ch_len]
        cmp     eax, [edi+RECT.right]
        cmova   eax, [edi+RECT.right]

        stdcall TextIndexToPos, esi, eax   ; move the gap after the rectangle right bound.
        push    eax
................................................................................





; Navigation manipulation methods.

; Returns a pointer to variable where TTextLine with absolute coordinate [.y] is stored.
; If [.y] is outside the text, appends new lines up to [.y] and returns the result.
method TAsmEdit.TextLine  ; .y
begin
        push    esi ebx

        mov     eax, [.self]
        mov     esi, [eax+TAsmEdit._lines]

        mov     eax, [.y]
        shl     eax, 2

        cmp     eax, [esi+TText.GapBegin]
        jb      @f
        add     eax, [esi+TText.GapEnd]
        sub     eax, [esi+TText.GapBegin]
@@:
        cmp     eax, [esi+TText.Length]
        jae     .create_new

        lea     eax, [esi+eax]


.finish:
        pop     ebx esi
        return

.create_new:
        mov     ebx, [esi+TText.Length]
        sub     ebx, [esi+TText.GapEnd]
        add     ebx, [esi+TText.GapBegin]
        shr     ebx, 2

.loop:
        exec    [.self], TAsmEdit:InsertNewLine, ebx
        push    eax

        exec    [.self], TAsmEdit:SaveForUndo, ebx, chopInserted
        pop     eax


        cmp     ebx, [.y]
        lea     ebx, [ebx+1]
        jne     .loop

        inc     [AsmEditUndoGroup]

        jmp     .finish
endp



method TAsmEdit.ScrollToCaretX
begin
        pushad
................................................................................
        jmp     .finish

.leftok:
        test    [esi+TAsmEdit._options], aeoNavXCaretWrap
        jz      .set_pos

        exec    esi, TAsmEdit:TextLine, [esi+TAsmEdit._caretPos.y]



        mov     eax, [eax]
        cmp     ebx, [eax+TTextLine.ch_len]
        jbe     .set_pos

        exec    esi, TAsmEdit:CaretUpDown, 1, FALSE
        exec    esi, TAsmEdit:CaretHome
        jmp     .finish

................................................................................

method TAsmEdit.CaretEnd
begin
        push    esi
        mov     esi, [.self]

        exec    esi, TAsmEdit:TextLine, [esi+TAsmEdit._caretPos.y]      ; returns CF=1 and eax=0 on error.
        mov     eax, [eax]

        mov     eax, [eax+TTextLine.ch_len]


        mov     [esi+TAsmEdit._caretPos.x], eax
        exec    esi, TAsmEdit:ScrollToCaretX


        pop     esi
        return
endp


method TAsmEdit.CaretScrHome
begin
................................................................................
        jz      .add_new

        cmp     [edx+TUndoInfo.line], ebx
        jne     .add_new

        cmp     ecx, chopChanged
        jne     .add_new

        mov     eax, [AsmEditUndoGroup]
        cmp     eax, [edx+TUndoInfo.group]
        jne     .add_new

        cmp     [edx+TUndoInfo.operation], ecx
        je      .finish                         ; group the chopChanged for the same line.

; add new record in the chain.

.add_new:
................................................................................
        mov     ecx, [.PosX]
        test    ebx, ebx
        cmovs   ebx, [esi+TAsmEdit._caretPos.y]
        cmovs   ecx, [esi+TAsmEdit._caretPos.x]
        mov     [.LineNum], ebx
        mov     [.PosX], ecx

        exec    esi, TAsmEdit:TextLine, ebx     ; ensure the line ebx exists.

        inc     ebx
        exec    esi, TAsmEdit:InsertNewLine, ebx
        mov     edi, eax
        exec    esi, TAsmEdit:SaveForUndo, ebx, chopInserted

        mov     edx, [esi+TAsmEdit._lines]
        mov     ebx, [edx+4*ebx-4]                ; the gap, after the InsertNewLine is located just after the ebx line.
................................................................................

method TAsmEdit.DeleteSelection
.rect RECT
.list dd ?
begin
        pushad



        exec    [.self], TAsmEdit:_AddSelRectanglesAbs, 0
        mov     [.list], edx

        lea     edi, [edx+TArray.array]
        mov     ecx, [edx+TArray.count]
        test    ecx, ecx
        jz      .exit_empty
................................................................................
        cmp     ebx, [edi+RECT.top]
        jl      .rect_loop

        exec    [.self], TAsmEdit:SaveForUndo, ebx, chopChanged

        exec    [.self], TAsmEdit:AddTrailingSpaces, ebx, [edi+RECT.left]
        exec    [.self], TAsmEdit:TextLine, ebx

        mov     esi, [eax]

        stdcall TextIndexToPos, esi, [edi+RECT.left]
        stdcall TextMoveGap, esi, eax

        mov     eax, [esi+TTextLine.ch_len]
        cmp     eax, [edi+RECT.right]
        cmova   eax, [edi+RECT.right]                   ; delete up to the min(length, RECT.right) utf-8 character position!
................................................................................
        exec    esi, TAsmEdit:_RenderTxt, [esi+TAsmEdit._imgText], eax
        exec    esi, TAsmEdit:_RenderLM, [esi+TAsmEdit._imgMargin], [.rect.top], [.rect.bottom]
        exec    esi, TAsmEdit:RectChanged2, 0
        exec    esi, TAsmEdit:ScrollToCaretX
        exec    esi, TAsmEdit:ScrollToCaretY

.exit:
        inc     [AsmEditUndoGroup]
        stdcall FreeMem, [.list]
        clc
        popad
        return

.exit_empty:

................................................................................
        jae     .finish         ; the line is outside the text. Add empty lines???

        mov     edx, [edi+ebx]

        mov     ecx, [.PosX]
        sub     ecx, [edx+TTextLine.ch_len]
        jle     .finish                         ; the caret is inside the line.

        push    edx
        stdcall DecCount, [esi+TAsmEdit._line_widths], [edx+TTextLine.ch_len]
        mov     [esi+TAsmEdit._line_widths], edx
        pop     edx

        add     [edx+TTextLine.ch_len], ecx

        push    edx
        stdcall IncCount, [esi+TAsmEdit._line_widths], [edx+TTextLine.ch_len]
        mov     [esi+TAsmEdit._line_widths], edx
        pop     edx

        stdcall TextMoveGap, edx, -1
        stdcall TextSetGapSize, edx, ecx
        mov     [edi+ebx], edx

        mov     edi, edx
        add     edi, [edx+TTextLine.GapBegin]
        add     [edx+TTextLine.GapBegin], ecx
................................................................................
        jb      .skip
        add     ebx, [edi+TText.GapEnd]
        sub     ebx, [edi+TText.GapBegin]
.skip:
        cmp     ebx, [edi+TText.Length]
        jae     .finish         ; the line is outside the text. Add empty lines???

        mov     edi, [edi+ebx]

        stdcall TextMoveGap, edi, -1

        mov     edx, edi
        add     edx, [edi+TTextLine.GapBegin]

; search back the first non-whitespace...

.loop:
        dec     edx
        cmp     edx, edi
        jl      .found

        cmp     byte [edx], ' '
        jbe     .loop

.found:
        inc     edx
        mov     ecx, edx
        sub     ecx, edi

        xchg    ecx, [edi+TTextLine.GapBegin]
        sub     ecx, [edi+TTextLine.GapBegin]

        stdcall DecCount, [esi+TAsmEdit._line_widths], [edi+TTextLine.ch_len]
        sub     [edi+TTextLine.ch_len], ecx
        stdcall IncCount, edx, [edi+TTextLine.ch_len]
        mov     [esi+TAsmEdit._line_widths], edx

        stdcall FreeMem, [edi+TTextLine.syn_array]
        and     [edi+TTextLine.syn_array], 0

.finish:
        popad
        return
endp



endmodule


include "themes/asmedit.asm"
include "syntax/SyntaxFASM.asm"

Changes to freshlib/gui/TMenu.asm.

15
16
17
18
19
20
21

22
23
24
25
26
27
28




































29
30
31
32
33
34
35
...
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692

693
694
695
696
697
698
699
...
761
762
763
764
765
766
767









768
769

770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
...
942
943
944
945
946
947
948
949
950



























































951
952
953


mitSeparator = 0
mitAction    = 1
mitSubmenu   = 2
mitString    = 3        ; contains simple text string can't have accelerator and icons.



struct TMenuItem
  .type   dd ?
  .item   dd ?    ; different for the different types of items: NULL, pointer to TAction, pointer to TMenu, handle of string.
  .height dd ?
ends







































object TMenu, TCanvasWindow
  ._p_items   dd ?
  ._selected  dd ?
  .__caller   dd ?

................................................................................

        stdcall SetMouseCapture, edi

.capture_ok:

        exec    edi, TWindow:ClientToScreenXY, [.x], [.y]

        mov     [esi+TWindow._x], ecx
        mov     [esi+TWindow._y], edx

        mov     [esi+TMenu._selected], 0

        mov     [esi+TMenu.__caller], edi
        mov     [__ActiveMenu], esi

        set     esi, TMenu:Visible, TRUE

        stdcall _RefreshWindowRect, [esi+TWindow.handle], 0, 0, [esi+TWindow._width], [esi+TWindow._height]
;        exec    esi, TMenu:Refresh


        popad
        return
endp




................................................................................

.height_ok:

        mov     eax, ebx
        add     eax, [edi+TMenuItem.height]
        exec    esi, TMenu:RectChanged2, 0;, ebx, [esi+TWindow._width], eax










        cmp     [edi+TMenuItem.type], mitSubmenu
        jne     .hide_old


        get     eax, [edi+TMenuItem.item], TMenu:Enabled
        test    eax, eax
        jz      .finish

        mov     eax, [esi+TMenu._width]
        sub     eax, [GUI.menuIconMargin]

        exec    [edi+TMenuItem.item], TMenu:Show, esi, eax, ebx
        jmp     .finish

.hide_old:
        cmp     [__ActiveMenu], esi
        je      .finish

        set     [__ActiveMenu], TWindow:Visible, FALSE
        mov     [__ActiveMenu], esi

.finish:
        popad
        return
endp


................................................................................




endp































































endmodule









>







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







 







|
<
<
|





<
<
<
<
>







 







>
>
>
>
>
>
>
>
>

<
>









|
|
|
|
|
|
|
|







 









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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
...
710
711
712
713
714
715
716
717


718
719
720
721
722
723




724
725
726
727
728
729
730
731
...
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809

810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
...
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053


mitSeparator = 0
mitAction    = 1
mitSubmenu   = 2
mitString    = 3        ; contains simple text string can't have accelerator and icons.



struct TMenuItem
  .type   dd ?
  .item   dd ?    ; different for the different types of items: NULL, pointer to TAction, pointer to TMenu, handle of string.
  .height dd ?
ends


mitEnd = $80

struct TMenuTplItem
  .Action dd ?
  .Type   dd ?
ends

macro MenuTemplate lblMenu, [Type, Action]  {
  common
    label lblMenu dword

  forward

    if (Type = mitSubmenu) | (Type = mitString)
      local .Text
      dd  .Text
    else
      if Type = mitAction
        dd  Action
      else
        dd  -1
      end if
    end if

    dd  Type

  common
    dd  -2      ; End of MenuTemplate structure.

  forward
    if (Type = mitSubmenu) | (Type = mitString)
      .Text db Action, 0
    end if
}



object TMenu, TCanvasWindow
  ._p_items   dd ?
  ._selected  dd ?
  .__caller   dd ?

................................................................................

        stdcall SetMouseCapture, edi

.capture_ok:

        exec    edi, TWindow:ClientToScreenXY, [.x], [.y]

        mov     [esi+TMenu._x], ecx


        mov     [esi+TMenu._y], edx

        mov     [esi+TMenu.__caller], edi
        mov     [__ActiveMenu], esi

        set     esi, TMenu:Visible, TRUE




        set     esi, TMenu:Selected, 0
        popad
        return
endp




................................................................................

.height_ok:

        mov     eax, ebx
        add     eax, [edi+TMenuItem.height]
        exec    esi, TMenu:RectChanged2, 0;, ebx, [esi+TWindow._width], eax

; hide old menu if active:

        cmp     [__ActiveMenu], esi
        je      .hide_ok

        set     [__ActiveMenu], TWindow:Visible, FALSE
        mov     [__ActiveMenu], esi

.hide_ok:
        cmp     [edi+TMenuItem.type], mitSubmenu

        jne     .finish               ;hide_old

        get     eax, [edi+TMenuItem.item], TMenu:Enabled
        test    eax, eax
        jz      .finish

        mov     eax, [esi+TMenu._width]
        sub     eax, [GUI.menuIconMargin]

        exec    [edi+TMenuItem.item], TMenu:Show, esi, eax, ebx
;        jmp     .finish
;
;.hide_old:
;        cmp     [__ActiveMenu], esi
;        je      .finish
;
;        set     [__ActiveMenu], TWindow:Visible, FALSE
;        mov     [__ActiveMenu], esi

.finish:
        popad
        return
endp


................................................................................




endp





proc ___MenuFromTemplate
begin
        push    ebx ecx edx

        create  ebx, TMenu, 0

.loop:
        mov     edx, [esi+TMenuTplItem.Type]
        cmp     edx, mitEnd
        je      .end_of_menu

        xor     ecx, ecx
        cmp     edx, mitSeparator
        je      .add_item

        mov     ecx, [esi+TMenuTplItem.Action]
        cmp     edx, mitString
        je      .add_item

        cmp     edx, mitAction
        cmove   ecx, [ecx]
        je      .add_item

        cmp     edx, mitSubmenu
        jne     .add_item

        add     esi, sizeof.TMenuTplItem
        call    ___MenuFromTemplate
        set     eax, TMenu:Caption, ecx
        set     eax, TMenu:Enabled, TRUE
        set     eax, TMenu:Visible, FALSE
        mov     ecx, eax

.add_item:
        exec    ebx, TMenu:AddItem, edx, ecx

        add     esi, sizeof.TMenuTplItem
        jmp     .loop

.end_of_menu:
        mov     eax, ebx
        pop     edx ecx ebx
        return
endp



proc MenuFromTemplate, .pTemplate
begin
        push    esi
        mov     esi, [.pTemplate]
        call    ___MenuFromTemplate
        pop     esi
        return
endp



endmodule


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

86
87
88
89
90
91
92

93
94
95
96
97
98
99
        jne     .ifnotstr

        cmp     eax,[.Quo]
        jne     .loop

        add     ebx, edx
        xor     edx, edx

        call    .end_chunk
        mov     [.SynContext], ciText
        jmp     .loop

.ifnotstr:
        cmp     eax, $ff
        ja      .text







>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
        jne     .ifnotstr

        cmp     eax,[.Quo]
        jne     .loop

        add     ebx, edx
        xor     edx, edx
        inc     [.cnt]
        call    .end_chunk
        mov     [.SynContext], ciText
        jmp     .loop

.ifnotstr:
        cmp     eax, $ff
        ja      .text

Changes to freshlib/imports/Linux/pthreads.inc.

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
152
153
154
155
156
157
158
159
160
161
162
163
pthread_testcancel                ,<NONE>,                                      'pthread_testcancel',                    \
pthread_timedjoin_np              ,<NONE>,                                      'pthread_timedjoin_np',                  \
pthread_tryjoin_np                ,<NONE>,                                      'pthread_tryjoin_np',                    \
pthread_yield                     ,<NONE>,                                      'pthread_yield',                         \
pwrite                            ,<NONE>,                                      'pwrite',                                \
pwrite64                          ,<NONE>,                                      'pwrite64',                              \
raise                             ,<NONE>,                                      'raise',                                 \
read                              ,<NONE>,                                      'read',                                  \
recv                              ,<NONE>,                                      'recv',                                  \
recvfrom                          ,<NONE>,                                      'recvfrom',                              \
recvmsg                           ,<NONE>,                                      'recvmsg',                               \
sem_close                         ,<NONE>,                                      'sem_close',                             \
sem_destroy                       ,<NONE>,                                      'sem_destroy',                           \
sem_getvalue                      ,<NONE>,                                      'sem_getvalue',                          \
sem_init                          ,<NONE>,                                      'sem_init',                              \
................................................................................
sendto                            ,<NONE>,                                      'sendto',                                \
sigaction                         ,<NONE>,                                      'sigaction',                             \
siglongjmp                        ,<NONE>,                                      'siglongjmp',                            \
sigwait                           ,<NONE>,                                      'sigwait',                               \
system                            ,<NONE>,                                      'system',                                \
tcdrain                           ,<NONE>,                                      'tcdrain',                               \
vfork                             ,<NONE>,                                      'vfork',                                 \
waitpid                           ,<NONE>,                                      'waitpid',                               \
write                             ,<NONE>,                                      'write'










|







 







|
|



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
152
153
154
155
156
157
158
159
160
161
162
163
pthread_testcancel                ,<NONE>,                                      'pthread_testcancel',                    \
pthread_timedjoin_np              ,<NONE>,                                      'pthread_timedjoin_np',                  \
pthread_tryjoin_np                ,<NONE>,                                      'pthread_tryjoin_np',                    \
pthread_yield                     ,<NONE>,                                      'pthread_yield',                         \
pwrite                            ,<NONE>,                                      'pwrite',                                \
pwrite64                          ,<NONE>,                                      'pwrite64',                              \
raise                             ,<NONE>,                                      'raise',                                 \
\;read                              ,<NONE>,                                      'read',                                  \
recv                              ,<NONE>,                                      'recv',                                  \
recvfrom                          ,<NONE>,                                      'recvfrom',                              \
recvmsg                           ,<NONE>,                                      'recvmsg',                               \
sem_close                         ,<NONE>,                                      'sem_close',                             \
sem_destroy                       ,<NONE>,                                      'sem_destroy',                           \
sem_getvalue                      ,<NONE>,                                      'sem_getvalue',                          \
sem_init                          ,<NONE>,                                      'sem_init',                              \
................................................................................
sendto                            ,<NONE>,                                      'sendto',                                \
sigaction                         ,<NONE>,                                      'sigaction',                             \
siglongjmp                        ,<NONE>,                                      'siglongjmp',                            \
sigwait                           ,<NONE>,                                      'sigwait',                               \
system                            ,<NONE>,                                      'system',                                \
tcdrain                           ,<NONE>,                                      'tcdrain',                               \
vfork                             ,<NONE>,                                      'vfork',                                 \
waitpid                           ,<NONE>,                                      'waitpid';,                               \
\;write                             ,<NONE>,                                      'write'



Changes to freshlib/test_code0/TestAsmEdit.asm.

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
          ObjTemplate  tfChild or tfEnd, TAsmEdit, AsmEdit,     \
                     x = 10, y = 40, width = 200, height = 200, \
                     SplitCell = SplitTest.cellAsmEdit,         \
                     Visible = TRUE


;utf8_long file "unicode_test.txt"
utf8_long file "test_utf8.asm"

;utf8_long db  "Test one line"
          dd   0



if ThemeGUI eq win_gui
  getfile imgArrowRight, '_test_images/right2.png'
end if







|

|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
          ObjTemplate  tfChild or tfEnd, TAsmEdit, AsmEdit,     \
                     x = 10, y = 40, width = 200, height = 200, \
                     SplitCell = SplitTest.cellAsmEdit,         \
                     Visible = TRUE


;utf8_long file "unicode_test.txt"
;utf8_long file "test_utf8.asm"

utf8_long dd 0 ;db  " "
          dd   0



if ThemeGUI eq win_gui
  getfile imgArrowRight, '_test_images/right2.png'
end if