Fresh IDE . Check-in [8a219674f9]
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:The method TAsmEdit:SplitLine implemented.
Timelines: family | ancestors | descendants | both | NoCanvasGUI
Files: files | file ages | folders
SHA1:8a219674f95cee1af68125f16452464d8b9bb31b
User & Date: johnfound 2019-05-02 09:36:11
Context
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
08:08
Undo/Redo operations work at least for delete. More tests needed of course. check-in: f2e6fc9d73 user: johnfound tags: NoCanvasGUI
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/gui/TAsmEdit.asm.

230
231
232
233
234
235
236

237
238
239
240
241
242
243
...
910
911
912
913
914
915
916



917
918
919
920
921
922
923
....
1050
1051
1052
1053
1054
1055
1056









1057
1058
1059
1060
1061
1062
1063
....
3690
3691
3692
3693
3694
3695
3696











































































3697
3698
3699
3700
3701
3702
3703
; 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 .DeleteSelection
  method .ReplaceSelection, .text

  method .InsertString, .text

  method .AddTrailingSpaces, .LineNum, .PosX  ; if the caret is positioned after the line end, fills with spaces
................................................................................

        cmp     eax, 5          ; Ctrl+E
        je      .select_end

        cmp     eax, 8          ; BackSpace
        je      .backspacekey




        jmp     .finish


.copy_to_clipboard:

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

        jmp     .endselect











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

................................................................................
        and     [eax+TTextLine.syn_array], 0

.finish:
        popad
        return
endp














































































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







>







 







>
>
>







 







>
>
>
>
>
>
>
>
>







 







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







230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
...
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
....
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
....
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
; 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.

  method .DeleteSelection
  method .ReplaceSelection, .text

  method .InsertString, .text

  method .AddTrailingSpaces, .LineNum, .PosX  ; if the caret is positioned after the line end, fills with spaces
................................................................................

        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>
        jmp     .finish
................................................................................
        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
        jmp     .finish

................................................................................
        and     [eax+TTextLine.syn_array], 0

.finish:
        popad
        return
endp



method TAsmEdit.SplitLine
begin
        pushad

        mov     esi, [.self]
        mov     ebx, [.LineNum]
        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.

        stdcall TextIndexToPos, ebx, [.PosX]
        jc      .finish                         ; the posX is outside the text, so there is nothing to split!

        push    eax
        exec    esi, TAsmEdit:SaveForUndo, [.LineNum], chopChanged
        pop     eax

        stdcall TextMoveGap, ebx, eax
        stdcall DecCount, [esi+TAsmEdit._line_widths], [ebx+TTextLine.ch_len]
        mov     [esi+TAsmEdit._line_widths], edx

        mov     eax, [ebx+TTextLine.GapEnd]
        mov     ecx, [ebx+TTextLine.Length]
        mov     [ebx+TTextLine.GapEnd], ecx
        sub     ecx, eax
        add     eax, ebx

        push    eax ecx

        stdcall StrLenUtf8, eax, ecx
        push    eax eax

        mov     ecx, [edi]

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

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

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

        pop     eax
        sub     [ebx+TTextLine.ch_len], eax
        stdcall IncCount, edx, [ebx+TTextLine.ch_len]
        mov     [esi+TAsmEdit._line_widths], edx

        pop     ecx eax
        stdcall TextAddBytes, [edi], -1, eax, ecx
        mov     [edi], edx

        exec    esi, TAsmEdit:DelTrailingSpaces, [.LineNum]

.finish:
        inc     [AsmEditUndoGroup]
        popad
        return
endp



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