Deleted freshlib/ForthScript/ForthLib.asm.
Deleted freshlib/ForthScript/ForthScript.asm.
Changes to freshlib/FreshEdit/FreshEdit.asm.
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
+
|
; - Word wrap
; - Code folding
; - Associated debug information
; - save with format information (bookmarks and breakpoints)
; - Read-only lines
; - Undo and Redo functions.
; - Adjustable colors, keyboard and behavior.
; - Char, Block and Line selections.
; - Char and Block selections.
; - Syntax highlighters interface for different languages.
; - Interface to visual programming tools and auto source generators.
;_________________________________________________________________________________________
include "FreshEditThemes.asm"
module "TFreshEdit library"
|
︙ | | |
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
|
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
|
+
-
+
-
+
-
+
-
+
+
+
-
+
+
+
+
+
+
-
|
; Line flags
lfBookmark = 1 ; the line have bookmark set.
lfFocused = 2 ; the line is focused until the user press some key.
lfProtected = 4 ; the line can not be edited.
lfWordWrap = 8 ; the line must be word wrapped. After changes, the format have to be updated.
lfHidden = 16 ; this line is hidden
lfBreakpoint = 16 ; set breakpoint in debug mode.
lfBreakpoint = 32 ; set breakpoint in debug mode.
lfFoldHeader = 32 ; this is the first line of foldable part of the text.
struct TEditorLine
.Data dd ? ; pointer to line data.
.flags dd ? ; line flags
.syn_context dd ? ; flags about current syntax highlighter context after processing line.
.syn_context dd ? ; flags about current syntax highlighter context.
.fold_level dd ?
.debugdata dd ? ; pointer to debug data, associated to this line
.fold_level dd ? ; the level of folding.
.subcount dd ? ; count of wrapped sublines
.pSublines dd ? ; pointer to array containing offsets to the sublines inside the line.
.width dd ? ; width of the line text in chars. It is the length of the string for non wrapped lines and maximal subline for wrapped.
align 32
.shift = 5
ends
struct TScreenLine
.IndexLine dd ?
.Subline dd ?
ends
undoInsertText = 0
undoDeleteText = 1
struct TUndoInfo
.operation db ? ; what was changed???
.selMode db ?
align 4
.caretX dd ?
.caretY dd ?
|
︙ | | |
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
-
+
-
+
+
+
+
-
-
+
-
-
+
+
+
-
-
-
+
+
-
+
+
-
-
+
+
-
-
+
-
-
-
-
-
+
+
-
+
-
+
-
-
-
+
+
+
+
-
+
-
-
-
-
-
+
+
-
-
-
+
-
-
-
-
+
-
-
-
+
+
-
-
+
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
|
chgfNoClearSelection = 1
chgfNeedRefresh = 2
chgfFinished = 4
; insert modes
modeInsert = 0
modeInsert = 0
modeOverwrite = 1
; selection modes
selmChar = 0
selmBlock = 1
selmBlock = 1 ; when the editor is in block selection mode, the word wrap
; feature must be switched OFF, because it is not possible
; to select rectangular region, on word wrapped lines.
; flag ReadOnly values
froReadWrite = 0
froReadOnlyWithCaret = 1
froReadOnlyNoCaret = 2
object TFreshEdit, TScrollWindow
._Font dd ? ; font of the editor.
; main editor font sizes
._fontheight dd ? ; in pixels.
._fontwidth dd ? ; in pixels.
._fontdescent dd ? ; in pixels.
; system font sizes (used for additional texts and line numbers)
._fontheight2 dd ? ; in pixels.
._fontwidth2 dd ? ; in pixels.
._fontdescent2 dd ? ; in pixels.
.__LeftMargin dd ? ; width of the left margin field. Auto computed.
.__NumberMargin dd ? ; width of the field for the line number. Auto computed.
._ExtraFont dd ? ;
._cols dd ? ; width of the window in text columns.
._rows dd ? ; height of the window in text rows.
; must to be update on resize and on font change.
; must be updated on resize and on font change.
._pLines dd ? ; pointer to TArray of TEditorLine items.
._pIndex dd ? ; pointer to TArray of dword that contains numbers of TEditorLine for the screen.
._pLengths dd ? ; pointer to TArray with counts of the lines with given length.
._pUndoList dd ? ; pointer to TArray of TUndoInfo
._pRedoList dd ? ; pointer to TArray of TUndoInfo
._pShadow dd ? ; double buffer pointer to TBackBuffer object.
._pShadow dd ? ; pointer to TBackBuffer object.
._fShadowValid dd ? ;
.pScreenIndex dd ? ; pointer to array of TScreenLine structures, containing
; view change fields
._TopLine dd ? ; number of the line that is at the topmost line of the window.
._LeftColumn dd ? ; the column of the text at the leftmost side of the window.
._xCaret dd ? ; horizontal position of the caret inside the current line.
._yCaret dd ? ; vertical position of the caret inside the text.
._xCaret dd ? ; the number of the char the caret resides.
._yCaret dd ? ; the index of the line the caret resides.
._xSelection dd ?
._ySelection dd ?
._fReadOnly dd ?
._SelMode dd ?
._SelMode dd ? ; NOTE: on selmBlock, the word wrap should be OFF
._InsMode dd ?
._TabStop dd ?
; end change fields
._prevTopLine dd ?
._prevTopOffset dd ?
._prevLeftColumn dd ?
._prevxCaret dd ?
._prevyCaret dd ?
._prevCaretChar dd ?
._prevCaretLine dd ?
._prevxDelta dd ?
._prevyDelta dd ?
._prevSelMode dd ?
._prevInsMode dd ?
; end backup fields
._DragButton dd ?
; ._Theme TFETheme
._procSyntax dd ? ; syntax highlighter procedure.
; icons and masks for the left margin
._iconBreakpointA dd ? ; active breakpoint icon.
._iconBreakpointI dd ? ; inactive breakpoint icon.
._iconDebugInfo dd ?
._maskBreakpointA dd ?
._maskBreakpointI dd ?
._maskDebugInfo dd ?
._iconUnfold dd ?
._iconFold dd ?
._maskUnfold dd ?
; Event handlers
.OnControlKey dd ?
; Parameters
param .Selection ; selected text read/write
param .CurrentLine ; TEditorLine where caret resides.
param .Text
param .CurrentLine ; TEditorLine where caret resides. read only
param .Text ; whole text; read/write
param .MaxLineLen
; Methods
; Commands
method .Clear ; clears the text in the editor.
method .Clear
; navigation methods
method .Move, .direction, .count, .force ; moves the caret
method .Left
method .Right
method .Up
method .Down
method .LineBegin
method .LineEnd
method .ScreenBegin
method .ScreenEnd
method .FileBegin
method .FileEnd
; editing methods
method .DeleteSel
method .InsertLine, .index ; index = -1 inserts at current position of the caret.
method .PageUp
method .PageDown
; index = -2 appends the line at the end of the text.
method .DeleteLine, .index ; index = -1 deletes the line on the current position of the caret.
; block processing methods.
method .InsertString, .hString
method .DeleteText, .indexFrom, .charFrom, .indexTo, .charTo
method .GetText, .indexFrom, .charFrom, .indexTo, .charTo
; Undo/Redo functions.
;
method .RegisterForUndo, .operation, .data
method .Undo
method .Redo
method .GetText, .LineFrom, .CharFrom, .LineTo, .CharTo
method .DeleteSel
method .ClearUndo
; Coordinates convertions
; these two methods are flexible, but very slow. .Text parameter seting is fastest way to change whole text of the editor.
method .InsertChar, .char
method .InsertString, .hstring ; inserts a string at the caret position.
; If the string contains formating chars they are processed properly.
method .DelChar ; deletes the char under the caret.
; appearance methods
method .FormatLine, .index
method .PixelToCaret, .xPixel, .yPixel
method .CaretToPixel, .iRow, .xChar
; themes methods
method LoadTheme, .configdb, .directory
endobj
; about .pIndex field:
;
; This array contains the number of text lines that have to be displayed on the
; respective screen lines.
; Not every text line have screen line representation - it means the count of items of [pIntex]
; can be smaller than count of items of [pLines]. This case is when some lines are folded and not visible.
; On the other hand, another variant is also possible - several items of [pIndex] to point to
; one line in [pLines] - when the text line is wraped and displayed on several lines of the screen.
;
;_________________________________________________________________________________________
cDefaultEditorFont text 'Fixedsys Excelsior 3.01'
;cDefaultEditorFont text 'Droid sans mono'
; left margin icons.
;iglobal
getfile iconBreakpointA, 'images/breakpoint.gif'
getfile iconBreakpointI, 'images/breakpoint_inactive.gif'
getfile maskBreakpointA, 'images/breakpoint_mask.gif'
getfile maskBreakpointI, 'images/breakpoint_mask_inactive.gif'
getfile iconDebugInfo, 'images/debug_icon.gif'
getfile maskDebugInfo, 'images/debug_mask.gif'
getfile iconUnfold, 'images/unfold.gif'
getfile iconFold, 'images/fold.gif'
getfile maskUnfold, 'images/unfold_mask.gif'
;endg
proc TFreshEdit.Create, .pobj
begin
push eax edx
push edx
mov ebx, [.pobj]
; Main Font settings.
stdcall FontCreate, cDefaultEditorFont, 0, 0, ffMonospaced
mov [ebx+TFreshEdit._Font], eax
mov [ebx+TFreshEdit._cursor], mcText
stdcall FontGetCharSize, [ebx+TFreshEdit.handle], [ebx+TFreshEdit._Font], __HeightProbeString
test edx, edx
jnz @f
inc edx
@@:
|
︙ | | |
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
-
+
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
-
|
stdcall CreateImageGIF, iconFold, iconFold.size
mov [ebx+TFreshEdit._iconFold], eax
stdcall CreateImageGIF, maskUnfold, maskUnfold.size
mov [ebx+TFreshEdit._maskUnfold], eax
; Init some values.
mov [ebx+TFreshEdit._TabStop], 8
mov [ebx+TFreshEdit._TabStop], 4
mov [eax+TFETheme.WrapPos], 80
mov [eax+TFETheme.UndoLevels], 20
mov [ebx+TFreshEdit._DragButton], -1
stdcall CreateArray, sizeof.TEditorLine
mov [ebx+TFreshEdit._pLines], eax
stdcall CreateArray, 4
mov [ebx+TFreshEdit._pIndex], eax
stdcall CreateArray, 4
mov [ebx+TFreshEdit._pLengths], eax
stdcall CreateArray, sizeof.TUndoInfo
mov [ebx+TFreshEdit._pUndoList], eax
stdcall CreateArray, sizeof.TUndoInfo
mov [ebx+TFreshEdit._pRedoList], eax
stdcall CreateBackBuffer, [ebx+TFreshEdit.handle], 1, 1
mov [ebx+TFreshEdit._pShadow], eax
pop edx eax
pop edx
clc
return
endp
;_________________________________________________________________________________________
proc TFreshEdit.Destroy, .pobj
begin
mov ebx, [.pobj]
; free all text data
execute ebx, TFreshEdit.Clear
stdcall FreeMem, [ebx+TFreshEdit._pLines]
stdcall FreeMem, [ebx+TFreshEdit._pIndex]
; free the allocated buffers
stdcall FreeMem, [ebx+TFreshEdit._pLines]
stdcall FreeMem, [ebx+TFreshEdit._pLengths]
stdcall FreeMem, [ebx+TFreshEdit._pUndoList]
stdcall FreeMem, [ebx+TFreshEdit._pRedoList]
; destroy the shadow buffer.
stdcall DestroyBackBuffer, [ebx+TFreshEdit._pShadow]
; destroy icon images.
stdcall DestroyImage, [ebx+TFreshEdit._iconBreakpointA]
stdcall DestroyImage, [ebx+TFreshEdit._iconBreakpointI]
stdcall DestroyImage, [ebx+TFreshEdit._iconDebugInfo]
stdcall DestroyImage, [ebx+TFreshEdit._maskBreakpointA]
stdcall DestroyImage, [ebx+TFreshEdit._maskBreakpointI]
stdcall DestroyImage, [ebx+TFreshEdit._maskDebugInfo]
stdcall DestroyImage, [ebx+TFreshEdit._iconUnfold]
stdcall DestroyImage, [ebx+TFreshEdit._iconFold]
stdcall DestroyImage, [ebx+TFreshEdit._maskUnfold]
clc
return
endp
;_________________________________________________________________________________________
|
︙ | | |
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
|
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
|
stc
.exit:
return
;................................................................
.get_selection:
push esi
mov esi, [.pobj]
mov ecx, [.pobj]
mov eax, [esi+TFreshEdit._SelMode]
cmp eax, selmChar
je .get_sel_char
cmp eax, selmBlock
je .get_sel_block
execute ecx, TFreshEdit.GetText, [ecx+TFreshEdit._yCaret], [ecx+TFreshEdit._xCaret], \
stc
return
.get_sel_char:
execute esi, TFreshEdit.GetText, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret], \
[esi+TFreshEdit._ySelection], [esi+TFreshEdit._xSelection]
[ecx+TFreshEdit._ySelection], [ecx+TFreshEdit._xSelection], [ecx+TFreshEdit._SelMode]
clc
pop esi
return
.get_sel_block:
xor eax, eax
clc
pop esi
return
;................................................................
.gettext:
push ebx ecx edx esi edi
push ebx edx esi edi
stdcall StrNew
mov ebx, eax
mov edi, [.pobj]
mov esi, [edi+TFreshEdit._pLines]
mov ecx, [esi+TArray.count]
jecxz .text_ready
lea esi, [esi+TArray.array]
.line_loop:
stdcall TFreshEdit.__AddFormatLine, ebx, [esi+TEditorLine.flags]
stdcall StrDup, [esi+TEditorLine.Data]
push eax
push eax
push eax
stdcall StrLen, eax
mov edx, eax
stdcall StrPtr ; from the stack
|
︙ | | |
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
|
-
+
-
+
-
-
-
-
+
+
-
-
-
+
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
inc eax
dec edx
jnz .loop_char
.line_ready:
stdcall StrCat, ebx ; from the stack.
stdcall StrDel ; from the stack
stdcall StrCharCat, ebx, $0a0d
stdcall TFreshEdit.__AddFormatLine, ebx, [esi+TEditorLine.flags]
.next_line:
add esi, sizeof.TEditorLine
loop .line_loop
.text_ready:
mov eax, ebx
pop edi esi edx ecx ebx
pop edi esi edx ebx
clc
return
;................................................................
.currentline:
push ebx edx edi
mov edi, [.pobj]
mov eax, [edi+TFreshEdit._yCaret]
mov ecx, [.pobj]
stdcall GetArrayItem, [ecx+TFreshEdit._pLines], [ecx+TFreshEdit._yCaret]
mov ebx, [edi+TFreshEdit._pIndex]
cmp eax, [ebx+TArray.count]
jae .errorcl
jnc .endgcl
.lineloop:
mov edx, [ebx+TArray.array+4*eax]
cmp edx, -1
jne .found
dec eax
xor eax, eax
jns .lineloop
.endgcl:
.errorcl:
stc
pop edi edx ebx
return
; edx is the number of string in the lines array.
.found:
mov ebx, [edi+TFreshEdit._pLines]
cmp edx, [ebx+TArray.count]
jae .errorcl
shl edx, TEditorLine.shift
lea eax, [ebx+TArray.array+edx]
clc
pop edi edx ebx
return
;................................................................
.maxlinelen:
mov eax, [.pobj]
mov eax, [eax+TFreshEdit._pLengths]
|
︙ | | |
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
|
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
-
-
-
-
-
+
-
+
-
-
-
|
;_________________________________________________________________________________________
proc TFreshEdit.Set, .pobj, .paramID, .value
begin
push eax ebx edx esi edi
mov edi, [.pobj]
mov eax, [.paramID]
cmp eax, TFreshEdit.Text
cmp [.paramID], TFreshEdit.Text
je .settext
cmp eax, TFreshEdit.Selection
cmp [.paramID], TFreshEdit.Selection
je .set_selection
stc
.finish:
pop edi esi edx ebx eax
return
;.........................................................................................
.set_selection:
; delete the old selection
push esi eax edx
mov esi, [.pobj]
|
︙ | | |
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
+
-
+
+
+
-
-
-
-
-
-
-
-
-
|
pop edx eax esi
clc
return
;.........................................................................................
.settext:
locals
.pLine dd ?
.flags dd ?
endl
push eax ebx edx esi edi
mov edi, [.pobj]
execute edi, TFreshEdit.Clear
stdcall StrPtr, [.value]
mov esi, eax
.lineloop:
mov [.flags], 0
stdcall TFreshEdit.__DecodeFormatLine, esi
jc .line_begin
mov [.flags], eax
add esi, ecx
.line_begin:
push esi
.char:
lodsb
test al, al
jz .end_of_line
|
︙ | | |
666
667
668
669
670
671
672
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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
|
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
+
+
+
+
-
+
+
-
+
+
-
|
; because the memory reallocation returns not zero filled memory.
stosb
pop edi esi ecx
; insert text line.
stdcall AddArrayItems, [edi+TFreshEdit._pLines], 1
jc .end_set_text
mov [edi+TFreshEdit._pLines], edx
mov ecx, [edx+TArray.count]
mov [.pLine], eax
mov [eax+TEditorLine.Data], ebx
push [.flags]
pop [eax+TEditorLine.flags]
mov [eax+TEditorLine.syn_context], 0
mov [eax+TEditorLine.debugdata], 0
mov [eax+TEditorLine.width], -1
xor ecx, ecx
mov [eax+TEditorLine.flags], ecx
mov [eax+TEditorLine.syn_context], ecx
mov [eax+TEditorLine.debugdata], ecx
mov [eax+TEditorLine.fold_level], ecx
dec ecx
; mov [eax+TEditorLine.width], ecx
; insert index line.
stdcall AddArrayItems, [edi+TFreshEdit._pIndex], 1
mov [edi+TFreshEdit._pIndex], edx
stdcall StrPtr, ebx
stdcall TFreshEdit.__DecodeFormatLine, eax
jc .format_ok
dec ecx
mov [eax], ecx
mov edx, [.pLine]
mov [edx+TEditorLine.flags], eax
stdcall StrCopyPart, ebx, ebx, 0, ecx
.format_ok:
; format the line
mov ecx, [edx+TArray.count]
dec ecx
execute edi, TFreshEdit.FormatLine, ecx
; execute edi, TFreshEdit.FormatLine, ecx
; goto next line.
cmp byte [esi], 0
jne .lineloop
mov [edi+TFreshEdit._TopLine], 0
mov [edi+TFreshEdit._yCaret], 0
mov eax, [edi+TFreshEdit._pLengths]
stdcall TFreshEdit.__UpdateScrollBars, edi
mov [edi+TFreshEdit._fShadowValid], 0
.end_set_text:
clc
jmp .finish
pop edi esi edx ebx eax
return
endp
;_________________________________________________________________________________________
; move commands
mvcMoveX = 1
mvcMoveY = 2
|
︙ | | |
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
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
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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
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
914
915
916
917
918
919
920
921
922
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
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
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
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
|
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
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
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
|
je .movecaret
cmp [.method], TFreshEdit.LineBegin
je .linebegin
cmp [.method], TFreshEdit.LineEnd
je .lineend
cmp [.method], TFreshEdit.FileBegin
je .filebegin
cmp [.method], TFreshEdit.FileEnd
je .fileend
cmp [.method], TFreshEdit.ScreenBegin
je .pagebegin
cmp [.method], TFreshEdit.ScreenEnd
je .pageend
cmp [.method], TFreshEdit.DeleteSel
je .delete_selection
cmp [.method], TFreshEdit.DeleteText
je .delete_text
cmp [.method], TFreshEdit.GetText
je .get_text
cmp [.method], TFreshEdit.InsertText
je .insert_text
cmp [.method], TFreshEdit.DeleteLine
je .delete_line
cmp [.method], TFreshEdit.InsertChar
je .insert_char
cmp [.method], TFreshEdit.InsertString
je .insert_string
cmp [.method], TFreshEdit.InsertLine
je .insert_line
cmp [.method], TFreshEdit.FormatLine
je .format_line
cmp [.method], TFreshEdit.DelChar
je .del_char
cmp [.method], TFreshEdit.DelChar
je .del_char
cmp [.method], TFreshEdit.PixelToCaret
je .pixel_to_caret
cmp [.method], TFreshEdit.CaretToPixel
je .caret_to_pixel
stc
return
;.........................................................................................
.refresh:
mov eax, [.self]
mov [eax+TFreshEdit._fShadowValid], 0
mov ecx, [.self]
mov [ecx+TFreshEdit._fShadowValid], 0
stc
return
;.........................................................................................
; formats some line of the text, depending on the flags. Also, fix the index items for
; this line.
.format_line:
virtual at ebx
.index dd ?
end virtual
; first get the line pointer
locals
.imin dd ?
.imax dd ?
.start_count dd ?
.rows dd ?
.caret_ofs dd ?
.wrap_here dd ?
.retval dd ? ; correction count on tab-expansion
endl
push ecx esi edi
mov esi, [.self]
mov edi, [esi+TFreshEdit._pIndex]
mov ecx, [.index]
cmp ecx, [edi+TArray.count]
jae .error_format
.loop_end:
inc ecx
cmp ecx, [edi+TArray.count]
jae .end_found
cmp [edi+TArray.array+4*ecx], -1
je .loop_end
.end_found:
dec ecx
mov [.imax], ecx
mov ecx, [.index]
inc ecx
.loop_start:
dec ecx
js .error_format
cmp [edi+TArray.array+4*ecx], -1
je .loop_start
mov [.imin], ecx
mov [.rows], 1 ; how many lines are withit the line
mov ecx, [edi+TArray.array+4*ecx] ; index in _pLines array.
shl ecx, TEditorLine.shift
add ecx, [esi+TFreshEdit._pLines]
lea edi, [ecx+TArray.array] ; edi points to TEditorLine structure.
; begin of formating
stdcall StrClipSpacesR, [edi+TEditorLine.Data]
stdcall ExpandTabs, [edi+TEditorLine.Data], [esi+TFreshEdit._TabStop]
mov [.retval], eax
stdcall StrLen, [edi+TEditorLine.Data]
mov ecx, eax
mov [.start_count], eax
jecxz .wrap_ok
stdcall StrPtr, [edi+TEditorLine.Data]
mov edx, eax
; first replace $01 with $20 (wrap char to space)
push edx ecx
.spc_loop:
cmp byte [edx], $01
jne @f
mov byte [edx], $20
@@:
inc edx
loop .spc_loop
pop ecx edx
; word wrap?
test [edi+TEditorLine.flags], lfWordWrap
jz .wrap_ok
push edi
mov edi, edx
.wrap_outer:
mov ecx, [FreshEditTheme.WrapPos]
inc ecx
mov [.wrap_here], -1
xor edx, edx
.wrap_loop:
add edi, edx
stdcall DecodeUtf8, [edi]
test eax, eax
jz .wrap_ready
cmp eax, ' '
jne @f
mov [.wrap_here], edi
@@:
loop .wrap_loop
cmp [.wrap_here], -1
jne .do_wrap
.forward:
add edi, edx
stdcall DecodeUtf8, [edi]
test eax, eax
jz .wrap_ready
cmp eax, ' '
jne .forward
mov [.wrap_here], edi
.do_wrap:
mov edi, [.wrap_here]
mov byte [edi], $01 ; wrap the line.
inc edi
inc [.rows]
jmp .wrap_outer
.wrap_ready:
; ready, so fix the index.
pop edi
.wrap_ok:
mov eax, [.imin]
inc eax
mov ecx, [.imax]
sub ecx, [.imin]
inc ecx
sub ecx, [.rows] ; ecx>0 means some rows from the index must be deleted
; ecx<0 means some rows must be added.
; ecx=0 means the index is ok
jz .index_ok
js .add_more_index
stdcall DeleteArrayItems, [esi+TFreshEdit._pIndex], eax, ecx
mov [esi+TFreshEdit._pIndex], edx
jmp .index_ok
.add_more_index:
neg ecx
stdcall InsertArrayItems, [esi+TFreshEdit._pIndex], eax, ecx
mov [esi+TFreshEdit._pIndex], edx
.fill_new_items:
mov dword [eax], -1
lea eax, [eax+4]
loop .fill_new_items
.index_ok:
stdcall TFreshEdit.__LineWidth, [edi+TEditorLine.Data]
xchg eax, [edi+TEditorLine.width]
stdcall TFreshEdit.__FixLength, esi, [edi+TEditorLine.width], eax
clc
mov eax, [.retval]
mov edx, [.imin]
pop edi esi ecx
return
.error_format:
int3
mov eax, -1
clc
pop edi esi ecx
return
;.........................................................................................
.delete_line:
virtual at ebx
.del_index dd ?
.del_index dd ?
end virtual
push edx esi edi
push edx esi
mov esi, [.self]
mov eax, [.del_index]
cmp eax, -1
jne @f
mov eax, [esi+TFreshEdit._yCaret]
@@:
mov edi, [esi+TFreshEdit._pIndex]
cmp eax, [edi+TArray.count]
mov edx, [esi+TFreshEdit._pLines]
cmp eax, [edx+TArray.count]
jae .end_del_line
.beg_search:
cmp [edi+TArray.array+4*eax], -1 ; word wrap
shl eax, TEditorLine.shift
lea ecx, [edx+TArray.array+eax]
jne .do_del
dec eax
shr eax, TEditorLine.shift
jnz .beg_search
.do_del:
mov ecx, [edi+TArray.array+4*eax]
shl ecx, TEditorLine.shift
add ecx, TArray.array
add ecx, [esi+TFreshEdit._pLines]
stdcall StrDel, [ecx+TEditorLine.Data]
stdcall TFreshEdit.__FixLength, esi, -1, [ecx+TEditorLine.width]
stdcall DeleteArrayItems, [esi+TFreshEdit._pLines], [edi+TArray.array+4*eax], 1
mov [esi+TFreshEdit._pLines], edx
.del_index2:
stdcall DeleteArrayItems, edi, eax, 1
stdcall DeleteArrayItems, edx, eax, 1
mov edi, edx
cmp eax, [edi+TArray.count]
jae .end_del_index2
cmp [edi+TArray.array+4*eax], -1
je .del_index2
.end_del_index2:
mov [esi+TFreshEdit._pIndex], edi
mov [esi+TFreshEdit._pLines], edx
push eax
; fix the index to the end:
.fix_index_del:
cmp eax, [edi+TArray.count]
jae .end_fix_index
; delete the wrapped line (if any)
cmp [edi+TArray.array+4*eax], -1
je @f
dec [edi+TArray.array+4*eax]
@@:
inc eax
jmp .fix_index_del
.end_fix_index:
pop eax
.end_del_line:
clc
pop edi esi edx
pop esi edx
return
;.........................................................................................
.get_text:
; have the same arguments and local variables as .delete_text
virtual at ebx ; arguments
.indexFrom dd ?
.charFrom dd ?
.indexTo dd ?
.charTo dd ?
.BlockKind dd ?
end virtual
locals
.final_str dd ?
.final_flags dd ?
.final_level dd ?
.fromline dd ?
.toline dd ?
.ret_str dd ?
endl
pushad
mov [.ret_str], 0
; sort the "from" and "To" in order to have "From" < "To"
mov eax, [.indexFrom]
mov ecx, [.charFrom]
cmp eax, [.indexTo]
jne @f
cmp ecx, [.charTo]
@@:
je .finish_get ; from == to so nothing to return
jb @f
xchg eax, [.indexTo]
xchg ecx, [.charTo]
mov [.indexFrom], eax
mov [.charFrom], ecx
@@:
mov esi, [.self]
; last line processing
stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexTo]
jc .error_get
stdcall TFreshEdit.__PosToPointer, [.self], [.charTo], [.indexTo]
mov [.toline], edx
stdcall StrExtract, [edx+TEditorLine.Data], 0, eax
mov [.toline], eax
mov edx, eax
stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charTo]
stdcall StrExtract, [edx+TEditorLine.Data], 0, eax
mov [.final_str], eax
; first line processing
stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexFrom]
jc .error_get
stdcall TFreshEdit.__PosToPointer, [.self], [.charFrom], [.indexFrom]
mov [.fromline], edx
mov [.fromline], eax
mov edx, eax
stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charFrom]
mov edi, [edx+TEditorLine.Data]
cmp edx, [.toline]
jne .dup_first
mov edi, [.final_str]
.dup_first:
push eax
stdcall StrDup, edi
mov edi, eax
pop eax
jecxz .get_splitit
|
︙ | | |
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
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
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
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
|
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
914
915
916
917
918
919
920
921
922
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
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
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
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
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
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
+
+
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
+
+
+
-
-
-
+
-
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
+
-
+
-
-
-
-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
+
+
+
-
-
-
-
-
-
+
+
-
-
-
+
-
-
-
-
+
+
+
+
+
-
+
+
+
-
+
-
-
+
+
-
-
+
-
-
+
-
+
-
-
+
+
+
+
+
-
-
+
+
+
-
+
-
-
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
-
-
-
-
+
-
-
-
+
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
.finish_get:
clc
popad
mov eax, [.ret_str]
return
.error_get:
clc
popad
xor eax, eax
return
;.........................................................................................
; method .InsertText, .lineFrom, .charFrom, .hString, .fInsert
.insert_text:
virtual at ebx
.lineFrom2 dd ?
.charFrom2 dd ?
.hString2 dd ?
.fInsert dd ?
end virtual
locals
.suffix dd ?
.end_ptr dd ?
.current_line dd ?
.current_char dd ?
.ptr_line dd ?
.char_count dd ?
endl
pushad
mov esi, [.self]
.search_line:
stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.lineFrom2]
jnc .linefound
execute esi, TFreshEdit.InsertLine, -2
jmp .search_line
.linefound:
mov edi, eax
mov eax, [.lineFrom2]
mov [.current_line], eax
mov [.suffix], 0
stdcall StrOffsUtf8, [edi+TEditorLine.Data], [.charFrom2]
test ecx, ecx
jnz .add_spaces
stdcall StrSplit, [edi+TEditorLine.Data], eax
mov [.suffix], eax
jmp .do_insertion
.add_spaces:
stdcall StrCharCat, [edi+TEditorLine.Data], ' '
dec ecx
jnz .add_spaces
.do_insertion:
stdcall StrPtr, [.hString2]
mov esi, eax
stdcall StrLen, [.hString2]
lea eax, [esi+eax]
mov [.end_ptr], eax
stdcall StrLen, [edi+TEditorLine.Data]
mov ecx, eax
stdcall StrLen, [.hString2]
add ecx, eax
.loop_lines:
mov [.ptr_line], edi
stdcall StrSetCapacity, [edi+TEditorLine.Data], ecx
mov edi, eax
lea ecx, [edi+string.len]
add edi, [ecx] ; append the string to the end...
mov [.char_count], 0
.append_loop:
stdcall DecodeUtf8, [esi]
test eax, eax
jz .end_of_string
cmp eax, $0d
je .new_line
cmp eax, $0a
je .new_line
mov eax, [esi]
mov [edi], eax
add esi, edx
add edi, edx
add [ecx], edx
inc [.char_count]
jmp .append_loop
.new_line:
xor al, $0d xor $0a
inc esi
cmp [esi], al
jne @f
inc esi
@@:
call .finish_current_line
inc [.current_line]
execute [.self], TFreshEdit.InsertLine, [.current_line]
mov edi, eax
mov ecx, [.end_ptr]
sub ecx, esi
jmp .loop_lines
.finish_current_line:
xor eax, eax
stosd
cmp [.fInsert], modeInsert
je .overwrite_ok
cmp [.suffix], 0
je .overwrite_ok
stdcall StrOffsUtf8, [.suffix], [.char_count]
jecxz .split_suffix
stdcall StrDel, [.suffix]
mov [.suffix], 0
retn
.split_suffix:
stdcall StrSplit, [.suffix], eax
xchg [.suffix], eax
stdcall StrDel, eax
.overwrite_ok:
retn
.end_of_string:
call .finish_current_line
mov edi, [.ptr_line]
stdcall StrLenUtf8, [edi+TEditorLine.Data], -1
mov [.current_char], eax
cmp [.suffix], 0
je .last_ok
stdcall StrCat, [edi+TEditorLine.Data], [.suffix]
stdcall StrDel, [.suffix]
.last_ok:
.finish_ins_text:
popad
mov eax, [.current_line]
mov edx, [.current_char]
clc
return
;.........................................................................................
.delete_text:
virtual at ebx ; arguments
; have the same arguments and local variables as .get_text
.indexFrom dd ?
.charFrom dd ?
.indexTo dd ?
.charTo dd ?
end virtual
locals
.final_str dd ?
.final_flags dd ?
.final_level dd ?
.fromline dd ?
.toline dd ?
.ret_str dd ?
endl
pushad
; sort the "from" and "To" in order to have "From" < "To"
mov eax, [.indexFrom]
mov ecx, [.charFrom]
cmp eax, [.indexTo]
jne @f
cmp ecx, [.charTo]
@@:
je .nothing_to_delete ; from == to so nothing to delete.
je .finish_delete ; from == to so nothing to delete.
jb @f
xchg eax, [.indexTo]
xchg ecx, [.charTo]
mov [.indexFrom], eax
mov [.charFrom], ecx
@@:
mov esi, [.self]
; last line processing
stdcall TFreshEdit.__PosToPointer, [.self], [.charTo], [.indexTo]
stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexTo]
jc .finish_delete
mov edx, eax
stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charTo]
stdcall StrSplit, [edx+TEditorLine.Data], eax
mov [.final_str], eax
mov eax, [edx+TEditorLine.flags]
mov ecx, [edx+TEditorLine.fold_level]
mov [.final_flags], eax
mov [.final_level], ecx
; first line processing
stdcall TFreshEdit.__PosToPointer, [.self], [.charFrom], [.indexFrom]
mov [.fromline], edx
stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexFrom]
jc .finish_delete
mov edx, eax
mov [.fromline], eax
stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charFrom]
stdcall StrTrim, [edx+TEditorLine.Data], eax
jecxz .splitit
add eax, ecx
.addspc:
stdcall StrCharCat, [edx+TEditorLine.Data], ' '
dec ecx
js .catit
stdcall StrCharCat, [edx+TEditorLine.Data], ' ', eax
jnz .addspc
jmp .addspc
.splitit:
.catit:
stdcall StrSplit, [edx+TEditorLine.Data], eax
stdcall StrDel, eax
stdcall StrCat, [edx+TEditorLine.Data], [.final_str]
stdcall StrDel, [.final_str]
mov eax, [.final_level]
mov ecx, [.final_flags]
mov [edx+TEditorLine.fold_level], eax
or [edx+TEditorLine.flags], ecx
; now delete all lines except the first.
mov edi, [.indexTo]
mov eax, [.indexFrom]
mov ecx, [.indexTo]
sub ecx, eax
.del_loop:
stdcall TFreshEdit.__PosToPointer, [.self], -1, edi
cmp edx, [.fromline]
inc eax
je .delete_ok
stdcall DeleteArrayItems, [esi+TFreshEdit._pLines], eax, ecx
execute [.self], TFreshEdit.DeleteLine, edi
mov edi, eax
dec edi
jmp .del_loop
mov [esi+TFreshEdit._pLines], edx
.delete_ok:
.finish_delete:
execute [.self], TFreshEdit.FormatLine, [.indexFrom]
clc
popad
mov eax, [.indexFrom]
mov edx, [.charFrom]
return
.nothing_to_delete:
clc
popad
xor eax, eax
dec eax
return
;.........................................................................................
; delete the selection
.delete_selection:
mov esi, [.self]
mov ecx, [.self]
mov eax, [esi+TFreshEdit._SelMode]
cmp eax, selmChar
je .del_sel_char
cmp eax, selmBlock
je .del_sel_block
execute ecx, TFreshEdit.DeleteText, [ecx+TFreshEdit._yCaret], [ecx+TFreshEdit._xCaret], \
stc
return
.del_sel_char:
execute esi, TFreshEdit.DeleteText, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret], \
[esi+TFreshEdit._ySelection], [esi+TFreshEdit._xSelection]
[ecx+TFreshEdit._ySelection], [ecx+TFreshEdit._xSelection], [ecx+TFreshEdit._SelMode]
clc
return
.del_sel_block:
clc
return
;.........................................................................................
.insert_line:
virtual at ebx
.ins_index dd ?
end virtual
push esi edi
push edx esi
mov esi, [.self]
; first where to search. The next line is OK, but if the line is wrapped...
cmp [.ins_index], -1
jne @f
mov eax, [esi+TFreshEdit._yCaret]
mov [.ins_index], eax
mov esi, [.self]
@@:
mov edi, [esi+TFreshEdit._pIndex]
mov edx, [.ins_index]
mov edx, [esi+TFreshEdit._pLines]
cmp edx, [edi+TArray.count]
jb .search_begin
; insert as a last line
mov edx, [edi+TArray.count]
mov ecx, -1
mov ecx, [.ins_index]
jmp .ins_here
; if the line is wrapped, search for the begin.
.search_begin:
mov ecx, [edi+TArray.array+4*edx]
cmp ecx, -1 ; wrapped line?
jne .ins_here
dec edx
jns .search_begin
jmp .err_ins_line
; ...insert index item.
; edx contains the index in _pIndex where the new line have to be inserted.
; ecx contains the index in _pLines where the new line have to be inserted.
.ins_here:
push edx
stdcall InsertArrayItems, [esi+TFreshEdit._pIndex], edx, 1
mov [esi+TFreshEdit._pIndex], edx
mov edi, edx
pop edx
jc .err_ins_line
cmp ecx, -1
jne .storeline
jne @f
mov ecx, [esi+TFreshEdit._pLines]
mov ecx, [esi+TFreshEdit._yCaret]
mov ecx, [ecx+TArray.count]
.storeline:
mov [eax], ecx
; ...then fix the index to the end.
sub edx, [edi+TArray.count]
neg edx
dec edx
inc ecx
jle .index_fixed
@@:
.inc_index:
lea eax, [eax+4]
cmp dword [eax], -1
je @f
inc dword [eax]
cmp ecx, [edx+TArray.count]
jb @f
mov ecx, [edx+TArray.count]
@@:
dec edx
jnz .inc_index
.index_fixed:
; then insert new line
stdcall InsertArrayItems, [esi+TFreshEdit._pLines], ecx, 1
stdcall InsertArrayItems, edx, ecx, 1
mov [esi+TFreshEdit._pLines], edx
jc .err_ins_line
mov ebx, eax
mov edx, eax
stdcall StrNew
mov [edx+TEditorLine.Data], eax
mov [ebx+TEditorLine.Data], eax
xor eax, eax
mov [edx+TEditorLine.flags], eax
mov [edx+TEditorLine.syn_context], eax
mov [edx+TEditorLine.debugdata], eax
mov [edx+TEditorLine.width], eax
mov [ebx+TEditorLine.flags], eax
mov [ebx+TEditorLine.syn_context], eax
mov [ebx+TEditorLine.debugdata], eax
mov [ebx+TEditorLine.fold_level], eax
mov [ebx+TEditorLine.width], eax
mov eax, edx
stdcall TFreshEdit.__FixLength, esi, 0, -1
mov eax, ebx
.finish_ins_line:
pop edi esi
pop esi edx
clc
return
.err_ins_line:
pop edi esi
stc
xor eax, eax
jmp .finish_ins_line
return
;.........................................................................................
.del_char:
locals
.del_char_line dd ?
.del_char_to_line dd ?
.del_line_index dd ?
.byte_offs dd ?
.del_char_to_char dd ?
endl
push ecx edx esi edi
push eax ecx edx esi
mov esi, [.self]
stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
jc .end_del_char
mov eax, [esi+TFreshEdit._xCaret]
mov ecx, [esi+TFreshEdit._yCaret]
mov [.del_char_to_char], eax
mov [.del_char_to_line], ecx
inc [.del_char_to_char]
test [edx+TEditorLine.flags], lfProtected
jnz .end_del_char
stdcall GetArrayItem, [esi+TFreshEdit._pLines], ecx
jc .do_del_char
stdcall StrOffsUtf8, [eax+TEditorLine.Data], [.del_char_to_char]
jecxz .do_del_char
.del_pad_spc:
mov [.del_char_to_char], 0
stdcall StrCharInsert, [edx+TEditorLine.Data], ' ', eax
inc eax
inc [.del_char_to_line]
loop .del_pad_spc
.do_del_char:
mov [.byte_offs], eax
mov [.del_char_line], edx
mov ebx, eax
stdcall StrLen, [edx+TEditorLine.Data]
cmp ebx, eax
je .join_next_line
execute esi, TFreshEdit.DeleteText, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret], [.del_char_to_line], [.del_char_to_char], selmChar
mov ecx, eax
sub ecx, ebx
stdcall StrPtr, [edx+TEditorLine.Data]
mov edi, eax
stdcall DecodeUtf8, [edi+ebx]
lea esi, [edi+edx]
sub [edi+string.len], edx
add esi, ebx
add edi, ebx
cld
rep movsb
.end_del_char:
mov eax, [.byte_offs]
pop edi esi edx ecx
pop esi edx ecx eax
clc
return
.join_next_line:
mov eax, [.del_char_line]
mov edx, [esi+TFreshEdit._pLines]
sub eax, edx
sub eax, TArray.array
shr eax, TEditorLine.shift
inc eax
cmp eax, [edx+TArray.count]
jae .end_del_char
mov [.del_line_index], eax
mov edx, [.del_char_line]
mov ebx, edx
add edx, sizeof.TEditorLine
test [edx+TEditorLine.flags], lfProtected
jz .do_join
stdcall StrLen, [ebx+TEditorLine.Data]
test eax, eax
jnz .end_del_char
.do_join:
stdcall StrCat, [ebx+TEditorLine.Data], [edx+TEditorLine.Data]
mov eax, [edx+TEditorLine.flags]
or [ebx+TEditorLine.flags], eax
; now delete the line
stdcall TFreshEdit.__FixLength, esi, -1, [edx+TEditorLine.width]
stdcall StrDel, [edx+TEditorLine.Data]
stdcall DeleteArrayItems, [esi+TFreshEdit._pLines], [.del_line_index], 1
mov [esi+TFreshEdit._pLines], edx
; then fix the index.
mov edi, [esi+TFreshEdit._pIndex]
mov eax, [esi+TFreshEdit._yCaret]
mov edx, [.del_line_index]
inc eax
.char_fix_index:
cmp eax, [edi+TArray.count]
jae .end_del_char
cmp [edi+TArray.array+4*eax], -1
je .next_line_fix
cmp [edi+TArray.array+4*eax], edx
je .del_index_elements
dec [edi+TArray.array+4*eax]
.next_line_fix:
inc eax
jmp .char_fix_index
.del_index_elements:
mov ecx, eax
.char_scan_loop:
inc ecx
cmp ecx, [edi+TArray.count]
jae .end_char_scan
cmp [edi+TArray.array+4*ecx], -1
je .char_scan_loop
.end_char_scan:
sub ecx, eax
stdcall DeleteArrayItems, edi, eax, ecx
mov [esi+TFreshEdit._pIndex], edx
mov edi, edx
mov edx, [.del_line_index]
jmp .char_fix_index
;.........................................................................................
.insert_char:
; arguments
virtual at ebx
.ins_char dd ?
end virtual
push ecx edx esi edi
mov esi, [.self]
.ins_loop:
stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
jnc .line_found
execute [.self], TFreshEdit.InsertLine, -2
jnc .ins_loop ; possible hang!
xor edx, edx
jmp .end_ins_char
.line_found:
test [edx+TEditorLine.flags], lfProtected
jz .not_protected
lea edx, [eax+ecx]
jmp .end_ins_char
.not_protected:
cmp [.ins_char], $0d
je .split_here
cmp [.ins_char], $0a
je .split_here
jecxz .spaces_ok
.addspc2:
stdcall StrCharInsert, [edx+TEditorLine.Data], ' ', eax
inc eax
loop .addspc2
.spaces_ok:
.do_ins_char:
stdcall StrCharInsert, [edx+TEditorLine.Data], [.ins_char], eax
mov esi, eax
stdcall DecodeUtf8, [.ins_char]
add edx, esi
jmp .end_ins_char
.split_here:
push eax edx
mov eax, [esi+TFreshEdit._yCaret]
inc eax
execute [.self], TFreshEdit.InsertLine, eax
mov edi, eax
pop edx eax
stdcall StrSplit, [edx+TEditorLine.Data], eax
stdcall StrDel, [edi+TEditorLine.Data]
mov [edi+TEditorLine.Data], eax
mov eax, [esi+TFreshEdit._yCaret]
inc eax
execute esi, TFreshEdit.FormatLine, eax
execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
.split_ok:
execute esi, TFreshEdit.LineBegin
execute esi, TFreshEdit.Move, mvcMoveY, 1, TRUE
xor edx, edx
.end_ins_char:
push edx
mov esi, [.self]
stdcall TFreshEdit.__PointerToPos, [.self], [esi+TFreshEdit._yCaret], edx
mov [esi+TFreshEdit._xCaret], edx
mov [esi+TFreshEdit._yCaret], eax
pop eax
clc
pop edi esi edx ecx
return
;.........................................................................................
.insert_string:
; arguments
virtual at ebx
.hstring dd ?
end virtual
push ecx edx esi
push eax edx
stdcall StrPtr, [.hstring]
mov esi, eax
mov ecx, [.self]
.char_loop:
stdcall DecodeUtf8, [esi]
jc .end_ins_str
execute ecx, TFreshEdit.InsertText, [ecx+TFreshEdit._yCaret], [ecx+TFreshEdit._xCaret], [.hstring], [ecx+TFreshEdit._InsMode]
mov eax, [esi]
add esi, edx
mov [ecx+TFreshEdit._yCaret], eax
lea ecx, [8*edx]
mov edx, 1
mov [ecx+TFreshEdit._xCaret], edx
shl edx, cl
dec edx
and eax, edx
cmp eax, 0
pop edx eax
je .end_ins_str
cmp eax, $0d
je .ins_cr
cmp eax, $0a
jne .ins_it
.ins_cr:
xor al, $0d xor $0a
cmp al, [esi]
je .char_loop
.ins_it:
execute [.self], TFreshEdit.InsertChar, eax
jmp .char_loop
.end_ins_str:
clc
pop esi edx ecx
return
;.........................................................................................
.linebegin:
stdcall TFreshEdit.__FitCaretInWindow, [.self]
jnz .endlb
mov eax, [.self]
mov [eax+TFreshEdit._xCaret], 0
mov [eax+TFreshEdit._LeftColumn], 0
.endlb:
clc
return
;.........................................................................................
.lineend:
push ecx edx esi edi
push edx esi edi
mov esi, [.self]
stdcall TFreshEdit.__FitCaretInWindow, esi
jnz .endle
mov esi, [.self]
mov ecx, [esi+TFreshEdit._yCaret]
mov ebx, [esi+TFreshEdit._pIndex]
stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
mov ebx, eax
stdcall GetArrayItem, [esi+TFreshEdit._pLines], [esi+TFreshEdit._yCaret]
jnc .inline
stdcall StrPtr, [edx+TEditorLine.Data]
mov edi, eax
mov [esi+TFreshEdit._xCaret], 0
; search the end of the current line
.el_loop:
stdcall DecodeUtf8, [edi+ebx]
test eax, eax
jz .el_found
cmp eax, $01
je .el_found
add ebx, edx
jmp .el_loop
jmp .endle
.el_found:
.inline:
stdcall TFreshEdit.__PointerToPos, esi, [esi+TFreshEdit._yCaret], ebx
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
mov eax, [eax+TEditorLine.width]
mov [esi+TFreshEdit._xCaret], eax
.endle:
pop edi esi edx
clc
return
;.........................................................................................
.filebegin:
mov ecx, [.self]
stdcall TFreshEdit.__FitCaretInWindow, esi
pop edi esi edx ecx
stdcall TFreshEdit.__FitCaretInWindow, ecx
jnz .endfb
mov [ecx+TFreshEdit._TopLine], 0
mov [ecx+TFreshEdit._yCaret], 0
mov [ecx+TFreshEdit._ySelection], 0
.endfb:
clc
return
;.........................................................................................
.fileend:
mov ecx, [.self]
stdcall TFreshEdit.__FitCaretInWindow, ecx
jnz .endfe
mov eax, [ecx+TFreshEdit._pLines]
mov eax, [eax+TArray.count]
dec eax
jns @f
inc eax
@@:
mov [ecx+TFreshEdit._yCaret], eax
mov [ecx+TFreshEdit._ySelection], eax
inc eax
sub eax, [ecx+TFreshEdit._rows]
jns @f
xor eax, eax
@@:
mov [ecx+TFreshEdit._TopLine], eax
.endfe:
clc
return
;.........................................................................................
.pagebegin:
mov ecx, [.self]
stdcall TFreshEdit.__FitCaretInWindow, ecx
jnz .endpb
mov eax, [ecx+TFreshEdit._TopLine]
mov [ecx+TFreshEdit._yCaret], eax
mov [ecx+TFreshEdit._ySelection], eax
.endpb:
clc
return
;.........................................................................................
.pageend:
push edx
mov ecx, [.self]
stdcall TFreshEdit.__FitCaretInWindow, ecx
jnz .endpe
mov eax, [ecx+TFreshEdit._TopLine]
add eax, [ecx+TFreshEdit._rows]
dec eax
jns @f
xor eax, eax
@@:
mov edx, [ecx+TFreshEdit._pLines]
cmp eax, [edx+TArray.count]
jb @f
mov eax, [edx+TArray.count]
dec eax
@@:
mov [ecx+TFreshEdit._yCaret], eax
mov [ecx+TFreshEdit._ySelection], eax
.endpe:
pop edx
clc
return
;.........................................................................................
; The method TFreshEdit.Move moves the caret towards given direction and on
; the given count of steps.
;
.movecaret:
virtual at ebx
|
︙ | | |
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
|
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
|
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
-
-
-
+
+
+
-
-
-
+
-
+
|
test [.direction], mvcMoveX or mvcMoveY
jz .fitok
cmp [.force], 0
jne .fitok
stdcall TFreshEdit.__FitCaretInWindow, esi
test eax, eax
jnz .endmove
.fitok:
test [.direction], mvcMoveX or mvcMoveY or mvcScrollX or mvcScrollY
jz .endmove
test [.direction], mvcMoveX or mvcScrollX
jnz .move_horizontal
test [.direction], mvcMoveY or mvcScrollY
jnz .move_vertical
.endmove:
clc
pop edi esi edx
return
.move_horizontal:
test [.direction], mvcMoveX
jz .xcaretok
mov ecx, [esi+TFreshEdit._xCaret]
add ecx, [.count]
jns @f
mov ecx, [.count]
add [esi+TFreshEdit._xCaret], ecx
jns .xcaretok
xor ecx, ecx
@@:
mov [esi+TFreshEdit._xCaret], ecx
mov [esi+TFreshEdit._xCaret], 0
.xcaretok:
test [.direction], mvcScrollX
jz .leftcolok
mov ecx, [esi+TFreshEdit._LeftColumn]
add ecx, [.count]
jns @f
mov ecx, [.count]
add [esi+TFreshEdit._LeftColumn], ecx
jns .leftcolok
xor ecx, ecx
@@:
mov [esi+TFreshEdit._LeftColumn], ecx
mov [esi+TFreshEdit._LeftColumn], 0
.leftcolok:
mov ecx, [esi+TFreshEdit._xCaret]
mov edx, [esi+TFreshEdit._LeftColumn]
cmp ecx, edx
jb .hscroll
add edx, [esi+TFreshEdit._cols]
cmp ecx, edx
jb .endmove
.hscroll:
mov ecx, [esi+TFreshEdit._cols]
mov eax, [.count]
|
︙ | | |
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
|
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
|
-
-
-
+
+
+
-
-
-
+
-
-
+
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
-
-
+
+
+
+
|
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.move_vertical:
test [.direction], mvcMoveY
jz .ycaretok
mov ecx, [esi+TFreshEdit._yCaret]
add ecx, [.count]
jns @f
mov ecx, [.count]
add [esi+TFreshEdit._yCaret], ecx
jns .ycaretok
xor ecx, ecx
@@:
mov [esi+TFreshEdit._yCaret], ecx
mov [esi+TFreshEdit._yCaret], 0
.ycaretok:
test [.direction], mvcScrollY
jz .toplineok
mov ecx, [esi+TFreshEdit._TopLine]
add ecx, [.count]
mov ecx, [.count]
jns @f
xor ecx, ecx
@@:
mov edx, [esi+TFreshEdit._pIndex]
mov edx, [edx+TArray.count]
sub edx, [esi+TFreshEdit._rows]
jns @f
add [esi+TFreshEdit._TopLine], ecx
jns .toplineok
xor edx, edx
@@:
cmp ecx, edx
jl @f
mov ecx, edx
@@:
mov [esi+TFreshEdit._TopLine], ecx
mov [esi+TFreshEdit._TopLine], 0
.toplineok:
mov ecx, [esi+TFreshEdit._yCaret]
mov eax, [esi+TFreshEdit._pIndex]
mov eax, [esi+TFreshEdit._pLines]
mov eax, [eax+TArray.count]
cmp ecx, eax
jb @f
lea ecx, [eax-1]
@@:
mov [esi+TFreshEdit._yCaret], ecx
mov edx, [esi+TFreshEdit._TopLine]
cmp ecx, edx
jb .vscroll
add edx, [esi+TFreshEdit._rows]
cmp edx, eax
jae .vscroll
cmp ecx, edx
jb .endmove
.vscroll:
test [.direction], mvcMoveX or mvcMoveY
jz .endmove ; it is only scroll, so don't care about caret.
|
︙ | | |
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
|
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
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
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
|
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
mov [ebx+TEditorLine.Data], 0
add ebx, sizeof.TEditorLine
dec ecx
jmp .clrloop
.endclr:
mov ebx, [.self]
stdcall FreeMem, [ebx+TFreshEdit._pIndex]
stdcall FreeMem, [ebx+TFreshEdit._pLines]
stdcall FreeMem, [ebx+TFreshEdit._pLengths]
stdcall CreateArray, 4
mov [ebx+TFreshEdit._pIndex], eax
stdcall CreateArray, sizeof.TEditorLine
mov [ebx+TFreshEdit._pLines], eax
stdcall CreateArray, 4
mov [ebx+TFreshEdit._pLengths], eax
xor eax, eax
mov [ebx+TFreshEdit._fShadowValid], eax
mov [ebx+TFreshEdit._xCaret], eax
mov [ebx+TFreshEdit._yCaret], eax
mov [ebx+TFreshEdit._xSelection], eax
mov [ebx+TFreshEdit._ySelection], eax
execute ebx, TFreshEdit.Refresh
stdcall TFreshEdit.__UpdateScrollBars, ebx
clc
return
;.........................................................................................
; method .PixelToCaret, .xPixel, .yPixel
; .xPixel, .yPixel - coordinates of pixel related to the editor window.
; Returns:
; eax - index of the text line in TFreshEdit._pLines array.
; edx - character in the line.
.pixel_to_caret:
virtual at ebx
.xPixel dd ?
.yPixel dd ?
end virtual
mov esi, [.self]
mov ecx, [.xPixel]
mov eax, [.yPixel]
mov edi, [esi+TFreshEdit._FreeArea.x]
mov edx, [esi+TFreshEdit._FreeArea.y]
cmp ecx, edi
jl .pixel_outside
cmp eax, edx
jl .pixel_outside
add edi, [esi+TFreshEdit._FreeArea.width]
add edx, [esi+TFreshEdit._FreeArea.height]
cmp ecx, edi
jge .pixel_outside
cmp eax, edx
jge .pixel_outside
sub ecx, [esi+TFreshEdit.__LeftMargin]
jge @f
xor ecx, ecx
@@:
cdq
idiv [esi+TFreshEdit._fontheight]
add eax, [esi+TFreshEdit._TopOffset]
mov [.yPixel], eax
mov eax, ecx
cdq
idiv [esi+TFreshEdit._fontwidth]
add eax, [esi+TFreshEdit._LeftColumn]
mov [.xPixel], eax
; search the line and char
; first the line:
mov edi, [esi+TFreshEdit._TopLine]
stdcall GetArrayItem, [esi+TFreshEdit._pLines], edi
test [eax+TEditorLine.flags], lfWordWrap
mov edx, [.xPixel]
mov eax, [.yPixel]
clc
return
.pixel_outside:
xor eax, eax
dec eax
clc
return
;.........................................................................................
; method .CaretToPixel, .iRow, .xChar
.caret_to_pixel:
endp
;_________________________________________________________________________________________
proc TFreshEdit.SysEventHandler, .pobj, .pEvent
.changes dd ?
begin
push eax ebx ecx edx esi edi
push eax ebx edx esi edi
mov [.changes], 0
mov ebx, [.pEvent]
mov esi, [.pobj]
mov eax, [ebx+TSysEvent.event]
|
︙ | | |
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
|
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
|
-
-
+
-
+
+
+
+
+
|
cmp [ebx+TSysEvent.event], seMouseBtnRelease
je .mousebtnrelease
cmp [ebx+TSysEvent.event], seMouseMove
je .mousemove
.continue:
stc
.finish:
pop edi esi edx ecx ebx eax
pop edi esi edx ebx eax
return
;.........................................................................................
.mousemove:
mov ecx, mcText
mov eax, [ebx+TMouseMoveEvent.x]
cmp eax, [esi+TFreshEdit.__LeftMargin]
ja @f
mov ecx, mcArrow
@@:
mov [esi+TFreshEdit._cursor], ecx
cmp [esi+TFreshEdit._DragButton], mbLeft
jne .continue
stdcall TFreshEdit.__MoveCaretToPixel, esi, [ebx+TMouseMoveEvent.x], [ebx+TMouseMoveEvent.y]
stdcall TFreshEdit.__PixelToCaretPos, esi, [ebx+TMouseMoveEvent.x], [ebx+TMouseMoveEvent.y]
jc .continue
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
jmp .refresh
;.........................................................................................
.mousebtnrelease:
mov eax, [ebx+TMouseButtonEvent.Button]
cmp eax, [esi+TFreshEdit._DragButton]
jne .continue
|
︙ | | |
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
|
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
|
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
stdcall MouseCapture, [esi+TWindow.handle]
mov eax, [ebx+TMouseButtonEvent.Button]
mov [esi+TFreshEdit._DragButton], eax
cmp [ebx+TMouseButtonEvent.Button], mbLeft
jne .continue
stdcall TFreshEdit.__MoveCaretToPixel, esi, [ebx+TMouseButtonEvent.x], [ebx+TMouseButtonEvent.y]
stdcall TFreshEdit.__PixelToCaretPos, esi, [ebx+TMouseButtonEvent.x], [ebx+TMouseButtonEvent.y]
jc .continue
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
jmp .refresh
.left_margin_process:
sub edx, 16
cmp ecx, edx
jl .continue ; number or breakpoint click
; Fold/unfold click
; check for the fold/unfold icon under the cursor
xor edx, edx
div [esi+TFreshEdit._fontheight]
add eax, [esi+TFreshEdit._TopLine]
mov edx, [esi+TFreshEdit._pIndex]
cmp eax, [edx+TArray.count]
jae .continue
mov ecx, [edx+TArray.array+4*eax]
cmp ecx, -1
je .continue ; it is not fold icon row.
shl ecx, TEditorLine.shift
add ecx, [esi+TFreshEdit._pLines]
add ecx, TArray.array ; pointer to TEditorLine
test [ecx+TEditorLine.flags], lfFoldHeader
jz .continue
; determine what is the current state folded or expanded
locals
.current dd ?
.next dd ?
endl
mov [.current], eax ; current line index
mov ecx, [edx+TArray.array+4*eax]
inc ecx
.next_loop:
inc eax
cmp eax, [edx+TArray.count]
jae .folded
cmp [edx+TArray.array+4*eax], -1
je .next_loop
mov [.next], eax
cmp ecx, [edx+TArray.array+4*eax] ; the next index == current+1 -> expanded
jne .folded
; so, fold it...
stdcall TFreshEdit.__FoldZoneLen, esi, [.current]
mov ecx, [.next]
sub ecx, [.current]
inc ecx
cmp eax, ecx
jbe .continue ; nothing to fold
sub eax, ecx
stdcall DeleteArrayItems, [esi+TFreshEdit._pIndex], [.next], eax
mov [esi+TFreshEdit._pIndex], edx
stdcall TFreshEdit.__UpdateScrollBars, esi
or [.changes], chgfNeedRefresh
jmp .refresh
.folded:
; the zone is folded, so restore the index items.
stdcall TFreshEdit.__RestoreIndex, esi, [.current], [.next]
stdcall TFreshEdit.__UpdateScrollBars, esi
or [.changes], chgfNeedRefresh
; sub edx, 16
; cmp ecx, edx
; jl .continue ; number or breakpoint click
;
;; Fold/unfold click
;; check for the fold/unfold icon under the cursor
; xor edx, edx
; div [esi+TFreshEdit._fontheight]
; add eax, [esi+TFreshEdit._TopLine]
;
; mov edx, [esi+TFreshEdit._pIndex]
; cmp eax, [edx+TArray.count]
; jae .continue
;
; mov ecx, [edx+TArray.array+4*eax]
; cmp ecx, -1
; je .continue ; it is not fold icon row.
;
; shl ecx, TEditorLine.shift
; add ecx, [esi+TFreshEdit._pLines]
; add ecx, TArray.array ; pointer to TEditorLine
;
; test [ecx+TEditorLine.flags], lfFoldHeader
; jz .continue
;
;; determine what is the current state folded or expanded
;locals
; .current dd ?
; .next dd ?
;endl
; mov [.current], eax ; current line index
; mov ecx, [edx+TArray.array+4*eax]
; inc ecx
;
;.next_loop:
; inc eax
; cmp eax, [edx+TArray.count]
; jae .folded
;
; cmp [edx+TArray.array+4*eax], -1
; je .next_loop
;
; mov [.next], eax
; cmp ecx, [edx+TArray.array+4*eax] ; the next index == current+1 -> expanded
; jne .folded
;
;; so, fold it...
; stdcall TFreshEdit.__FoldZoneLen, esi, [.current]
;
; mov ecx, [.next]
; sub ecx, [.current]
; inc ecx
;
; cmp eax, ecx
; jbe .continue ; nothing to fold
;
; sub eax, ecx
; stdcall DeleteArrayItems, [esi+TFreshEdit._pIndex], [.next], eax
; mov [esi+TFreshEdit._pIndex], edx
;
; stdcall TFreshEdit.__UpdateScrollBars, esi
; or [.changes], chgfNeedRefresh
; jmp .refresh
;
;.folded:
;; the zone is folded, so restore the index items.
; stdcall TFreshEdit.__RestoreIndex, esi, [.current], [.next]
; stdcall TFreshEdit.__UpdateScrollBars, esi
; or [.changes], chgfNeedRefresh
jmp .refresh
;.........................................................................................
.scroll:
cmp [ebx+TScrollEvent.ScrollBar], scrollX
je .xscroll
|
︙ | | |
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
|
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
|
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
|
locals
.byte_offs dd ?
endl
cmp [esi+TFreshEdit._fReadOnly], froReadWrite
jne .refresh
execute esi, TFreshEdit.DeleteSel
test eax, eax
js @f
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
@@:
execute esi, TFreshEdit.InsertChar, [ebx+TKeyboardEvent.key]
mov [.byte_offs], eax
stdcall StrNew
push eax
stdcall StrCharCat, eax, [ebx+TKeyboardEvent.key]
execute esi, TFreshEdit.InsertString, eax
stdcall StrDel ; from the stack
mov [.byte_offs], 0
; is it necessary???
execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
add [.byte_offs], eax
stdcall TFreshEdit.__PointerToPos, esi, [esi+TFreshEdit._yCaret], [.byte_offs]
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
; execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
; add [.byte_offs], eax
;
; stdcall GetArrayItem, [esi+TFreshEdit._pLines], [esi+TFreshEdit._yCaret]
;
; stdcall StrCharUtf8, [eax+TEditorLine.Data], [.byte_offs]
; mov [esi+TFreshEdit._xCaret], eax
stdcall TFreshEdit.__UpdateScrollBars, esi
stdcall TFreshEdit.__FitCaretInWindow, esi
or [.changes], chgfNeedRefresh
jmp .refresh
|
︙ | | |
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
|
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
|
-
|
.handler_pgdn:
mov eax, [esi+TFreshEdit._rows]
dec eax
mov ecx, mvcMoveY or mvcScrollY
jmp .moveit
.moveit:
test [ebx+TKeyboardEvent.kbdStatus], maskScrLk
jnz .scroll_override
cmp [esi+TFreshEdit._fReadOnly], froReadOnlyNoCaret
jne .scroll_override_ok
|
︙ | | |
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
|
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
|
+
+
+
+
-
-
-
+
+
+
+
+
+
-
+
-
-
+
-
+
+
-
+
-
-
+
+
-
-
-
+
-
-
+
-
-
+
+
-
-
+
-
-
+
+
-
+
+
+
+
-
+
+
|
.handler_end:
execute esi, TFreshEdit.LineEnd
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_pgbeg:
execute esi, TFreshEdit.ScreenBegin
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_pgend:
execute esi, TFreshEdit.ScreenEnd
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_txtbeg:
execute esi, TFreshEdit.FileBegin
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_txtend:
execute esi, TFreshEdit.FileEnd
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_wordleft:
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_wordright:
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_delete:
locals
.byte_offs2 dd ?
endl
cmp [esi+TFreshEdit._fReadOnly], froReadWrite
jne .refresh
execute esi, TFreshEdit.DeleteSel
test eax, eax
jns .deleted
mov eax, [esi+TFreshEdit._yCaret]
mov ecx, [esi+TFreshEdit._xCaret]
cmp eax, [esi+TFreshEdit._ySelection]
jne .havesel
cmp ecx, [esi+TFreshEdit._xSelection]
jne .havesel
execute esi, TFreshEdit.DelChar
mov [.byte_offs2], eax
jmp .end_del
execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
stdcall TFreshEdit.__PointerToPos, esi, edx, [.byte_offs2]
.havesel:
.deleted:
execute esi, TFreshEdit.DeleteSel
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
.end_del:
stdcall TFreshEdit.__FitCaretInWindow, esi
stdcall TFreshEdit.__UpdateScrollBars, esi
or [.changes], chgfNeedRefresh
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
; BUG: it does not works as expected, but I don't have anough patience to fix it just now.....
; BUG: it does not works as expected, but I don't have enough patience to fix it just now.....
.handler_backspc:
cmp [esi+TFreshEdit._fReadOnly], froReadWrite
jne .refresh
push [esi+TFreshEdit._xCaret] [esi+TFreshEdit._yCaret]
execute esi, TFreshEdit.Move, mvcMoveX, -1, FALSE
mov edx, [esi+TFreshEdit._yCaret]
mov ecx, [esi+TFreshEdit._xCaret]
pop edx eax
cmp eax, [esi+TFreshEdit._xCaret]
jne .do_del
dec ecx
cmp edx, [esi+TFreshEdit._yCaret]
je .refresh
jns .posok
.do_del:
stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
dec edx
stdcall GetArrayItem, [esi+TFreshEdit._pLines], edx
test ecx, ecx
jnz .refresh
jc .refresh
stdcall StrLen, [edx+TEditorLine.Data]
cmp ecx, eax
stdcall StrLenUtf8, [eax+TEditorLine.Data], -1
mov ecx, eax
jae .refresh
.posok:
execute esi, TFreshEdit.DeleteText, edx, ecx, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret]
mov [esi+TFreshEdit._yCaret], eax
mov [esi+TFreshEdit._xCaret], edx
jmp .handler_delete
jmp .end_del
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_linedel:
cmp [esi+TFreshEdit._fReadOnly], froReadWrite
jne .refresh
execute esi, TFreshEdit.DeleteLine, [esi+TFreshEdit._yCaret]
|
︙ | | |
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
|
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
|
-
|
cmp [esi+TFreshEdit._fReadOnly], froReadWrite
jne .refresh
stdcall Get, esi, TFreshEdit.CurrentLine
jc .refresh
xor [eax+TEditorLine.flags], lfWordWrap
execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
stdcall TFreshEdit.__UpdateScrollBars, esi
or [.changes], chgfNeedRefresh
jmp .refresh
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_bookmark:
|
︙ | | |
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
|
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
|
-
+
-
+
|
or [.changes], chgfNeedRefresh
jmp .caretmoved
.scrollerok:
mov eax, [esi+TFreshEdit._xCaret]
mov ecx, [esi+TFreshEdit._yCaret]
mov edx, [esi+TFreshEdit._InsMode]
cmp eax, [esi+TFreshEdit._prevxCaret]
cmp eax, [esi+TFreshEdit._prevCaretChar]
jne .caretmoved
cmp ecx, [esi+TFreshEdit._prevyCaret]
cmp ecx, [esi+TFreshEdit._prevCaretLine]
jne .caretmoved
cmp edx, [esi+TFreshEdit._prevInsMode]
je .caretposok
.caretmoved:
stdcall TFreshEdit.__UpdateCaretPosition, esi
|
︙ | | |
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
|
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
|
-
-
+
+
|
mov ecx, [esi+TFreshEdit._LeftColumn]
mov [esi+TFreshEdit._prevTopLine], eax
mov [esi+TFreshEdit._prevLeftColumn], ecx
mov eax, [esi+TFreshEdit._xCaret]
mov ecx, [esi+TFreshEdit._yCaret]
mov edx, [esi+TFreshEdit._InsMode]
mov [esi+TFreshEdit._prevxCaret], eax
mov [esi+TFreshEdit._prevyCaret], ecx
mov [esi+TFreshEdit._prevCaretChar], eax
mov [esi+TFreshEdit._prevCaretLine], ecx
mov [esi+TFreshEdit._prevInsMode], edx
mov eax, [esi+TFreshEdit._xSelection]
mov ecx, [esi+TFreshEdit._ySelection]
sub eax, [esi+TFreshEdit._xCaret]
sub ecx, [esi+TFreshEdit._yCaret]
mov edx, [esi+TFreshEdit._SelMode]
|
︙ | | |
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
|
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
.finish_event:
test [.changes], chgfFinished
jz .continue
clc
jmp .finish
;.........................................................................................
uglobal
Prevtime dd ?
endg
.paint:
if defined options.DebugMode and options.DebugMode
stdcall GetTimestamp
xchg eax, [Prevtime]
sub eax, [Prevtime]
neg eax
OutputRegister regEAX, 10
end if
cmp [esi+TFreshEdit._fShadowValid], 0
jne @f
stdcall TFreshEdit.__DrawShadow, esi
@@:
stdcall SetClipRectangle, [ebx+TPaintEvent.context], 0
stdcall TScrollWindow.SysEventHandler, [.pobj], [.pEvent]
stdcall DrawBackBuffer, [ebx+TPaintEvent.context], [esi+TFreshEdit._pShadow], 0, 0
; debug mode of autoscroll with maximal speed.
; execute esi, TFreshEdit.Move, mvcMoveY or mvcScrollY, 2, TRUE
; execute esi, TFreshEdit.Refresh
; stdcall TFreshEdit.__UpdateScrollBars, esi
clc
jmp .finish
;.........................................................................................
.moveresize:
stdcall Get, esi, TFreshEdit.FreeArea
|
︙ | | |
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
|
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
mov [esi+TFreshEdit._fShadowValid], 0
jmp .continue
endp
;_________________________________________________________________________________________
proc TFreshEdit.__MoveCaretToPixel, .editor, .x, .y
begin
push ecx edx esi
xor ecx, ecx
mov esi, [.editor]
; x
mov eax, [.y]
mov edx, [esi+TFreshEdit._FreeArea.y]
cmp eax, edx
jl .nomove
add edx, [esi+TFreshEdit._FreeArea.height]
cmp eax, edx
jge .nomove
mov eax, [.x]
mov edx, [esi+TFreshEdit._FreeArea.x]
cmp eax, edx
jl .nomove
add edx, [esi+TFreshEdit._FreeArea.width]
cmp eax, edx
jge .nomove
sub eax, [esi+TFreshEdit.__LeftMargin]
jge @f
xor eax, eax
@@:
cdq
idiv [esi+TFreshEdit._fontwidth]
add eax, [esi+TFreshEdit._LeftColumn]
cmp [esi+TFreshEdit._xCaret], eax
je @f
test eax, eax
js @f
mov [esi+TFreshEdit._xCaret], eax
@@:
; y
mov eax, [.y]
cdq
idiv [esi+TFreshEdit._fontheight]
add eax, [esi+TFreshEdit._TopLine]
cmp [esi+TFreshEdit._yCaret], eax
je @f
test eax, eax
js @f
mov [esi+TFreshEdit._yCaret], eax
@@:
mov eax, ecx
clc
.finish:
pop esi edx ecx
return
.nomove:
stc
jmp .finish
endp
proc TFreshEdit.__DrawShadow, .editor
.context dd ?
.latest dd ?
.color dd ?
|
︙ | | |
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
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
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
|
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
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
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
|
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
-
-
+
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
-
-
+
-
-
-
-
+
+
-
-
-
-
-
+
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
+
+
+
-
-
-
+
+
-
-
-
-
-
+
-
-
+
+
-
-
+
-
-
-
+
|
cmp eax, [edi+TBackBuffer.width]
jge .wrapok
stdcall SetSimpleLine, [.context], [FreshEditTheme.clWrapColumn]
stdcall DrawLine, [.context], eax, 0, eax, [edi+TBackBuffer.height]
.wrapok:
; ebx is pointer to the index array.
mov ebx, [esi+TFreshEdit._pIndex]
mov ebx, [esi+TFreshEdit._pLines]
; edx is the number of the line in [pIndex]
mov edx, [esi+TFreshEdit._TopLine]
; ecx is the y coordinate of the line.
mov ecx, [esi+TFreshEdit._fontheight]
sub ecx, [esi+TFreshEdit._fontdescent]
; sub ecx, 3 ; this is not good.
; check the first line
.searchbegin:
cmp [ebx+TArray.array+4*edx], -1
jne .lineloop
sub ecx, [esi+TFreshEdit._fontheight]
dec edx
xor ecx, ecx
jnz .searchbegin
; so draw the lines.
.lineloop:
mov eax, ecx
sub eax, [esi+TFreshEdit._fontheight]
add eax, [esi+TFreshEdit._fontdescent]
cmp eax, [edi+TBackBuffer.height]
cmp ecx, [edi+TBackBuffer.height]
jge .endlines
cmp edx, [ebx+TArray.count]
jae .endlines
; call the TFreshEditLineType.procDraw for the current line type.
stdcall TFreshEdit.__DrawLine, esi, [.context], edx, ecx
add ecx, [esi+TFreshEdit._fontheight]
inc edx
jmp .lineloop
.endlines:
; fix the left line border to the end of the windows.
add ecx, [esi+TFreshEdit._fontdescent]
mov eax, [esi+TFreshEdit.__LeftMargin]
sub ecx, [esi+TFreshEdit._fontheight]
sub eax, 2
stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMarginBorder]
stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMargin]
dec eax
stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
dec eax
stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
stdcall ReleaseContext, [.context]
.finish:
mov [esi+TFreshEdit._fShadowValid], 1
popad
return
endp
; y is the coordinate of the top of the line!
; returns the height of the line in characters.
; if the line is not drawn (because is hidden) returns 0
proc TFreshEdit.__DrawLine, .editor, .context, .indexLine, .y
proc TFreshEdit.__DrawLine, .editor, .context, .iLine, .y
.line dd ?
.last_line dd ?
.attr dd ?
.ysel0 dd ?
.xsel0 dd ?
.ysel1 dd ?
.xsel1 dd ?
.unfold dd ?
.next dd ?
.markh dd ?
.linenumber dd ?
.fold_icon dd ?
.fold_line dd ?
begin
pushad
mov edi, [.editor]
mov esi, [.editor]
mov [.line], -1
mov [.unfold], 0
mov eax, [.indexLine]
mov eax, [.iLine]
lea ecx, [eax+1]
mov edx, [edi+TFreshEdit._pIndex]
.nextloop:
cmp ecx, [edx+TArray.count]
jae .unfoldok
cmp [edx+TArray.array+4*ecx], -1
jne @f
inc ecx
jmp .nextloop
@@:
push ecx
mov ecx, [edx+TArray.array+4*ecx]
dec ecx
cmp ecx, [edx+TArray.array+4*eax]
pop ecx
je .unfoldok
mov [.unfold], 1
.unfoldok:
mov [.next], ecx
; if the line is part of the word-wrapped line, don't draw the text, because it is already OK.
mov edx, [edx+TArray.array+4*eax] ; index in pLines
mov [.linenumber], edx
inc [.linenumber] ; count it from 1
cmp edx, -1
je .end_draw_text ; wrapped line.
mov eax, [edi+TFreshEdit._pLines]
mov edi, [esi+TFreshEdit._pLines]
mov [.last_line], 0
mov eax, [eax+TArray.count]
dec eax
cmp eax, edx
jne @f
inc [.last_line] ; flag that this line is the last line.
@@:
shl edx, TEditorLine.shift
shl eax, TEditorLine.shift
add edx, [edi+TFreshEdit._pLines]
add edx, TArray.array
lea edi, [edi+TArray.array+eax]
mov [.line], edx ; pointer to TEditorLines
; draw the text of the line
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stdcall StrLen, [edx+TEditorLine.Data]
test eax, eax
jz .empty_string
mov ecx, eax
shl eax, 4 ; sizeof.TCharAttr = 16
stdcall GetMem, eax ; attr array.
mov [.attr], eax
mov esi, eax
mov ebx, [FreshEditTheme.clSimpleText]
test [edx+TEditorLine.flags], lfProtected
jz @f
mov ebx, [FreshEditTheme.clProtectedText]
@@:
mov edx, [edi+TFreshEdit._Font]
; fill the attribute array with the default values.
.attrloop:
mov [esi+TCharAttr.color], ebx
mov [esi+TCharAttr.font], edx
lea esi, [esi+sizeof.TCharAttr]
loop .attrloop
mov edx, [.line]
test [edx+TEditorLine.flags], lfProtected
jnz .syntaxok
; Call the syntax highlighter if any:
xor ecx, ecx
cmp [.indexLine], ecx
je @f
mov ecx, [edx-sizeof.TEditorLine+TEditorLine.syn_context]
@@:
cmp [edi+TFreshEdit._procSyntax], 0
je .syntaxok
push edi edx
stdcall [edi+TFreshEdit._procSyntax], [edx+TEditorLine.Data], [.attr], ecx
pop edx edi
mov [edx+TEditorLine.syn_context], eax
.syntaxok:
stdcall StrPtr, [edx+TEditorLine.Data]
cmp byte [eax], 0
je .end_draw_text
stdcall DrawColoredString, [.context], eax, [.attr], [eax+string.len], [edi+TFreshEdit.__LeftMargin], \
[.y], [edi+TFreshEdit._LeftColumn], [edi+TFreshEdit._fontwidth], [edi+TFreshEdit._fontheight]
stdcall FreeMem, [.attr]
.end_draw_text:
; draw left margin graphics:
stdcall TFreshEdit.__DrawLeftMargin, edi, [.context], [.indexLine]
; now draw transparent selection
; selection bounds.
mov eax, [edi+TFreshEdit._xSelection]
mov ecx, [edi+TFreshEdit._ySelection]
mov ebx, [edi+TFreshEdit._xCaret]
mov edx, [edi+TFreshEdit._yCaret]
mov eax, [esi+TFreshEdit._xSelection]
mov ecx, [esi+TFreshEdit._ySelection]
mov ebx, [esi+TFreshEdit._xCaret]
mov edx, [esi+TFreshEdit._yCaret]
cmp ecx, edx
jl @f
je .sortx
xchg ecx, edx
cmp [edi+TFreshEdit._SelMode], selmChar
cmp [esi+TFreshEdit._SelMode], selmChar
jne @f
xchg eax, ebx
@@:
cmp [edi+TFreshEdit._SelMode], selmChar
cmp [esi+TFreshEdit._SelMode], selmChar
je .endsort
.sortx:
cmp eax, ebx
jle @f
xchg eax, ebx
@@:
.endsort:
mov [.xsel0], eax
mov [.ysel0], ecx
mov [.xsel1], ebx
mov [.ysel1], edx
mov eax, [.indexLine]
mov eax, [.iLine]
cmp eax, [.ysel0]
jl .end_sel
cmp eax, [.ysel1]
jg .end_sel
mov eax, [edi+TFreshEdit._SelMode]
mov eax, [esi+TFreshEdit._SelMode]
cmp eax, selmChar
je .selchar
; sel block
mov eax, [.xsel0]
cmp eax, [.xsel1]
je .end_sel
sub eax, [edi+TFreshEdit._LeftColumn]
sub eax, [esi+TFreshEdit._LeftColumn]
jge @f
xor eax, eax
@@:
imul eax, [edi+TFreshEdit._fontwidth]
add eax, [edi+TFreshEdit.__LeftMargin]
imul eax, [esi+TFreshEdit._fontwidth]
add eax, [esi+TFreshEdit.__LeftMargin]
mov ecx, [.xsel1]
sub ecx, [edi+TFreshEdit._LeftColumn]
sub ecx, [esi+TFreshEdit._LeftColumn]
jge @f
xor ecx, ecx
@@:
imul ecx, [edi+TFreshEdit._fontwidth]
add ecx, [edi+TFreshEdit.__LeftMargin]
imul ecx, [esi+TFreshEdit._fontwidth]
add ecx, [esi+TFreshEdit.__LeftMargin]
sub ecx, eax
jmp .drawsel
.selchar:
xor eax, eax
mov edx, [.indexLine]
mov edx, [.iLine]
cmp edx, [.ysel0]
jne .firstok
mov eax, [.xsel0]
sub eax, [edi+TFreshEdit._LeftColumn]
sub eax, [esi+TFreshEdit._LeftColumn]
jge .firstok
xor eax, eax
.firstok:
imul eax, [edi+TFreshEdit._fontwidth]
add eax, [edi+TFreshEdit.__LeftMargin]
imul eax, [esi+TFreshEdit._fontwidth]
add eax, [esi+TFreshEdit.__LeftMargin]
mov ecx, [edi+TFreshEdit._cols] ; selection is to the end of the line, for the intermediate lines.
mov ecx, [esi+TFreshEdit._cols] ; selection is to the end of the line, for the intermediate lines.
inc ecx
cmp edx, [.ysel1]
jne .lastok
mov ecx, [.xsel1]
sub ecx, [edi+TFreshEdit._LeftColumn]
sub ecx, [esi+TFreshEdit._LeftColumn]
test ecx, ecx
jns .lastok
xor ecx, ecx
.lastok:
imul ecx, [edi+TFreshEdit._fontwidth]
add ecx, [edi+TFreshEdit.__LeftMargin]
imul ecx, [esi+TFreshEdit._fontwidth]
add ecx, [esi+TFreshEdit.__LeftMargin]
sub ecx, eax
.drawsel:
mov edx, [.y]
sub edx, [edi+TFreshEdit._fontheight]
add edx, 3
; sub edx, [esi+TFreshEdit._fontheight]
; add edx, 3
stdcall SetDrawMode, [.context], [FreshEditTheme.clSelMode]
; stdcall SetDrawMode, [.context], [FreshEditTheme.clSelMode]
stdcall DrawFillRect, [.context], eax, edx, ecx, [edi+TFreshEdit._fontheight], [FreshEditTheme.clSelBack]
stdcall SetDrawMode, [.context], cmCopy
stdcall DrawFillRect, [.context], eax, edx, ecx, [esi+TFreshEdit._fontheight], [FreshEditTheme.clSelBack]
.end_sel:
mov eax, [.iLine]
mov edi, [esi+TFreshEdit._pLines]
shl eax, TEditorLine.shift
lea edi, [edi+TArray.array+eax]
; draw the text of the line
; allocate memory for the color data.
stdcall StrLen, [edi+TEditorLine.Data]
test eax, eax
jz .end_draw_text
mov ecx, eax
shl eax, 4 ; sizeof.TCharAttr = 16
stdcall GetMem, eax ; attr array.
mov [.attr], eax
mov edx, eax
mov ebx, [FreshEditTheme.clSimpleText]
test [edi+TEditorLine.flags], lfProtected
jz @f
mov ebx, [FreshEditTheme.clProtectedText]
@@:
mov eax, [esi+TFreshEdit._Font]
; fill the attribute array with the default values.
.attrloop:
mov [edx+TCharAttr.color], ebx
mov [edx+TCharAttr.font], eax
lea edx, [edx+sizeof.TCharAttr]
loop .attrloop
.attrok:
; Call the syntax highlighter if any:
cmp [esi+TFreshEdit._procSyntax], 0
je .syntaxok
; get the syntax context of the previous line:
xor ecx, ecx
cmp [.iLine], ecx
je .prev_ok ; there is no previous line
lea edx, [edi-sizeof.TEditorLine]
mov ecx, [edx+TEditorLine.syn_context]
or ecx, ttNewLine
; ecx contains the syntax context:
.prev_ok:
stdcall [esi+TFreshEdit._procSyntax], [edi+TEditorLine.Data], [.attr], ecx
mov [edi+TEditorLine.syn_context], eax
.syntaxok:
stdcall StrPtr, [edi+TEditorLine.Data]
mov ecx, [.y]
add ecx, [esi+TFreshEdit._fontheight]
sub ecx, [esi+TFreshEdit._fontdescent]
stdcall DrawColoredString, [.context], eax, [.attr], [eax+string.len], [esi+TFreshEdit.__LeftMargin], \
ecx, [esi+TFreshEdit._LeftColumn], [esi+TFreshEdit._fontwidth], [esi+TFreshEdit._fontheight]
stdcall FreeMem, [.attr]
.end_draw_text:
stdcall TFreshEdit.__DrawLeftMargin, esi, [.context], edi, [.y]
.finish_draw_line:
popad
return
.empty_string:
mov eax, [.indexLine]
mov ecx, [FreshEditTheme.clBackground]
cmp eax, [.ysel0]
jb .setback
cmp eax, [.ysel1]
jae .setback
mov ecx, [FreshEditTheme.clSelBack]
.setback:
jmp .end_draw_text
endp
proc TFreshEdit.__DrawLeftMargin, .editor, .context, .indexLine
proc TFreshEdit.__DrawLeftMargin, .editor, .context, .pLine, .y
.x dd ?
.y dd ?
.width dd ?
.height dd ?
.maxptr dd ?
.ytext dd ?
.yicons dd ?
.unfold dd ? ; is the line folded?
.indexNext dd ? ; the index of the next line in TFreshEdit._pIndex
.pNext dd ? ; pointer to the next line.
.ipLines dd ? ; the index of the current line in pLines array.
.ptrLine dd ? ; pointer of the current TEditorLine.
.pPrev dd ? ; pointer to the previous line.
.fold_icon dd ?
.fold_line dd ?
begin
pushad
mov esi, [.editor]
test [FreshEditTheme.Options], eoLeftMargin
jz .finish
stdcall SetDrawMode, [.context], cmCopy
; search for the next line index;
mov ecx, [.indexLine]
mov edx, [esi+TFreshEdit._pIndex]
cmp [edx+TArray.array+4*ecx], -1
je .finish
mov [.unfold], 0
mov edx, [esi+TFreshEdit._pLines]
mov ecx, [edx+TArray.count]
shl ecx, TEditorLine.shift
lea ecx, [edx+TArray.array+ecx]
mov [.maxptr], ecx
xor eax, eax
dec eax
mov ecx, [.pLine]
.nextloop:
inc ecx
cmp ecx, [edx+TArray.count]
sub ecx, sizeof.TEditorLine
cmp ecx, [esi+TFreshEdit._pLines]
jae .found_next
cmp [edx+TArray.array+4*ecx], eax
je .nextloop
ja @f
xor ecx, ecx
.found_next:
mov [.indexNext], ecx
@@:
mov eax, [.indexLine]
mov eax, [edx+TArray.array+4*eax] ; current line - index in pLines
mov [.ipLines], eax
mov [.pPrev], ecx
cmp ecx, [edx+TArray.count]
jae .unfoldok
mov ecx, [edx+TArray.array+4*ecx] ; next line index in pLines
dec ecx
cmp ecx, eax
mov ecx, [.pLine]
add ecx, sizeof.TEditorLine
mov [.pNext], ecx
setne byte [.unfold]
.unfoldok:
mov edx, eax
mov [.unfold], 0
mov edx, [.pLine]
shl edx, TEditorLine.shift
add edx, TArray.array
add edx, [esi+TFreshEdit._pLines]
mov [.ptrLine], edx
; determine the bounds of the drawing
mov ecx, [.indexNext]
sub ecx, [.indexLine]
mov eax, [esi+TFreshEdit.__LeftMargin]
imul ecx, [esi+TFreshEdit._fontheight]
mov ecx, [esi+TFreshEdit._fontheight]
mov [.width], eax
mov [.height], ecx
xor eax, eax
mov [.x], eax
mov eax, [.indexLine]
mov eax, [.y]
sub eax, [esi+TFreshEdit._TopLine]
imul eax, [esi+TFreshEdit._fontheight]
mov [.y], eax ; it can be negative for the word wrapped lines, partially displayed.
add eax, [esi+TFreshEdit._fontheight]
sub eax, [esi+TFreshEdit._fontdescent]
mov [.ytext], eax
mov ecx, [esi+TFreshEdit._iconBreakpointA]
mov eax, [esi+TFreshEdit._fontheight]
sub eax, [ecx+TImage.height]
sar eax, 1
adc eax, [.y]
mov [.yicons], eax
; draw the bookmark background.
test [edx+TEditorLine.flags], lfBookmark
jz .bookmarkok
mov eax, [.width]
sub eax, 4
stdcall DrawFillRect, [.context], [.x], [.y], eax, [.height], [FreshEditTheme.clBookmarkBack]
.bookmarkok:
|
︙ | | |
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
|
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
|
-
-
+
+
+
+
+
-
+
+
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
-
+
-
+
|
dec eax
stdcall DrawLine, [.context], eax, [.y], eax, ecx
jmp .borderok
.wrap_border:
dec ecx
push ecx eax [.y] eax [.context] ; vertical
push [.y] eax [.y] eax [.context] ; upper edge
push ecx eax [.y] eax [.context] ; vertical ye x ys x
push [.y] eax [.y] eax [.context] ; upper edge ys
push ecx eax ecx eax [.context] ; down edge
; down edge
mov ebx, [.pNext]
sub dword [esp+4], 2
sub dword [esp+12], 2
sub dword [esp+16], 2
stdcall DrawLine
sub dword [esp+12], 2
sub dword [esp+4], 2
add dword [esp+16], 2
sub dword [esp+12], 2
stdcall DrawLine
sub dword [esp+4], 2
add dword [esp+8], 2
sub dword [esp+12], 2
sub dword [esp+16], 1
stdcall DrawLine
mov ebx, [FreshEditTheme.clLeftMargin]
test [edx+TEditorLine.flags], lfBookmark
jz @f
mov ebx, [FreshEditTheme.clBookmarkBack]
@@:
stdcall SetSimpleLine, [.context], ebx
push [.y] eax [.y] eax [.context] ; upper edge
push [.y] eax [.y] eax [.context] ; upper edge
push ecx eax ecx eax [.context] ; down corner pixels
push ecx eax ecx eax [.context] ; down corner pixels
mov ebx, [.pNext]
push ecx eax ecx eax [.context] ; down edge
push ecx eax ecx eax [.context] ; down edge
sub dword [esp+4], 2
stdcall DrawLine
sub dword [esp+4], 2
sub dword [esp+8], 1
sub dword [esp+12], 2
stdcall DrawLine
push [.y] eax [.y] eax [.context] ; upper edge
push [.y] eax [.y] eax [.context] ; upper edge
sub dword [esp+4], 2
stdcall DrawLine
sub dword [esp+4], 2
add dword [esp+8], 1
sub dword [esp+12], 2
stdcall DrawLine
.borderok:
; Line number draw
.borderok:
test [FreshEditTheme.Options], eoLineNumbers
jz .line_numbers_ok
mov ecx, [.ipLines]
test ecx, ecx
jl .line_numbers_ok
mov ecx, [.pLine]
sub ecx, [esi+TFreshEdit._pLines]
sub ecx, TArray.array
shr ecx, TEditorLine.shift
inc ecx
stdcall NumToStr, ecx, ntsDec or ntsUnsigned
push eax eax
stdcall StrLen, eax
mov ecx, eax
stdcall StrPtr ; from the stack
mov ebx, eax
stdcall GetTextBounds, [.context], eax, ecx, 0 ; [edi+TFreshEdit._Font]
stdcall GetTextBounds, [.context], eax, ecx, 0
sub eax, [esi+TFreshEdit.__NumberMargin]
neg eax
stdcall DrawString, [.context], ebx, ecx, eax, [.ytext], 0, [FreshEditTheme.clLeftMarginText]
stdcall StrDel ; from the stack
.line_numbers_ok:
; draw icons in the middle
; icon breakpoint
mov edx, [.ptrLine]
mov edx, [.pLine]
test [edx+TEditorLine.flags], lfBreakpoint
jnz .draw_breakpoint
cmp [edx+TEditorLine.debugdata], 0
je .breakpoint_ok
.draw_breakpoint:
|
︙ | | |
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
|
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
|
-
-
+
-
-
-
+
+
-
-
-
+
-
+
+
+
+
+
-
-
+
+
-
-
-
-
+
-
|
mov ecx, [esi+TFreshEdit._iconBreakpointI]
@@:
stdcall DrawMaskedImage, [.context], eax, ecx
.breakpoint_ok:
; draw fold tree.
mov edx, [.ptrLine]
mov edx, [.pLine]
; first, determine, what icon should be set for fold/unfold icon:
xor ecx, ecx
mov ebx, [esi+TFreshEdit._pIndex]
mov eax, [.indexNext]
cmp eax, [ebx+TArray.count]
mov eax, [.pNext]
cmp eax, [.maxptr]
jae @f
mov eax, [ebx+TArray.array+4*eax] ; index in pLines of the next visible line.
shl eax, TEditorLine.shift
mov ecx, [esi+TFreshEdit._pLines]
mov ecx, eax
lea ecx, [ecx+TArray.array+eax]
@@:
cmp [.pPrev], 0
je .fold_fold
mov eax, [.pPrev]
mov eax, [edx-sizeof.TEditorLine+TEditorLine.fold_level]
test [edx+TEditorLine.flags], lfFoldHeader
jnz .fold_fold
cmp eax, [edx+TEditorLine.fold_level]
jb .fold_fold
jecxz .fold_end
mov eax, [ecx+TEditorLine.fold_level]
cmp eax, [edx+TEditorLine.fold_level]
ja .fold_continue
jb .fold_end
test [ecx+TEditorLine.flags], lfFoldHeader
jz .fold_continue
.fold_end:
xor eax, eax
mov ecx, 2 ; 2 means corner up/right
jmp .fold_ok
.fold_fold:
mov ecx, 1 ; 1 means half vertical down
mov eax, [esi+TFreshEdit._iconUnfold]
cmp [.unfold], 0
jne .fold_ok
mov eax, [esi+TFreshEdit._iconFold]
jmp .fold_ok
.fold_continue:
xor eax, eax
xor ecx, ecx ; 0 means full vertical line
|
︙ | | |
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
|
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
|
-
|
.height dd ?
.offset dd ?
begin
push eax ebx edx
mov ebx, [.editor]
mov eax, [ebx+TFreshEdit._fontheight]
mov edx, [ebx+TFreshEdit._fontwidth]
mov [.offset], 0
cmp [ebx+TFreshEdit._InsMode], modeInsert
jne .sizeok
|
︙ | | |
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
|
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
|
-
+
|
proc TFreshEdit.__UpdateScrollBars, .editor
begin
push eax ebx ecx edx
mov ebx, [.editor]
; V scroller
mov eax, [ebx+TFreshEdit._pIndex]
mov eax, [ebx+TFreshEdit._pLines]
mov eax, [eax+TArray.count]
sub eax, [ebx+TFreshEdit._rows]
mov [ebx+TFreshEdit._VScroller.Max], eax
mov eax, [ebx+TFreshEdit._TopLine]
mov [ebx+TFreshEdit._VScroller.Pos], eax
|
︙ | | |
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
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
3792
3793
3794
3795
3796
3797
3798
|
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
+
-
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
+
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
+
+
-
-
-
+
+
+
-
-
-
+
-
-
-
+
-
-
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
+
-
-
+
-
-
+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
-
-
-
+
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
|
.endset:
test eax, eax
pop esi edx ecx ebx
return
endp
; Converts x,y position in the text to memory parameters
; arguments:
; .x, .y - x and y coordinates of the position.
; returns:
; edx - pointer to the TEditorLine
; eax - byte offset inside the string that corresponds with the given position.
; ecx - count of the spaces that have to be inserted on offset eax in the string
; in order to reach the .x coordinate (when the position is beyond the end of the line)
proc TFreshEdit.__PosToPointer, .editor, .x, .y
.pline dd ?
.start dd ?
begin
push ebx esi edi
mov edi, [.editor]
mov eax, [.y]
mov ebx, [edi+TFreshEdit._pIndex]
cmp eax, [ebx+TArray.count]
jae .error
xor ecx, ecx
; Arguments:
.lineloop:
mov edx, [ebx+TArray.array+4*eax]
cmp edx, -1
jne .found
inc ecx
dec eax
jns .lineloop
;
; Returns:
; CF=0
; eax - number of the line
; edx - offset inside the line
; CF=1
.error:
stc
jmp .finish
; the pixel is outside the client area.
.crash_error:
int3
jmp .error
;
; ecx is the wrapped line count.
; edx is the number of string in the lines array.
.found:
mov ebx, [edi+TFreshEdit._pLines]
proc TFreshEdit.__PixelToCaretPos, .editor, .x, .y
cmp edx, [ebx+TArray.count]
jae .crash_error
begin
shl edx, TEditorLine.shift
lea eax, [ebx+TArray.array+edx]
push ebx ecx esi edi
mov [.pline], eax ; handle of the string.
cmp [.x], -1
je .only_line
xor ecx, ecx
stdcall StrPtr, [eax+TEditorLine.Data]
mov esi, eax
mov esi, [.editor]
mov [.start], eax
jecxz .wrapok
.wraploop:
stdcall DecodeUtf8, dword [esi]
add esi, edx
; x
test eax, eax
jz .crash_error
cmp eax, $01 ; line wrap char
jne .wraploop
dec ecx
jnz .wraploop
.wrapok:
mov ecx, [.x]
mov eax, [.y]
jecxz .endofstring
mov edx, [esi+TFreshEdit._FreeArea.y]
.charloop:
stdcall DecodeUtf8, dword [esi]
test eax, eax
jz .endofstring
cmp eax, $01
je .endofstring
cmp eax, edx
jl .nomove
add esi, edx
dec ecx
jnz .charloop
add edx, [esi+TFreshEdit._FreeArea.height]
cmp eax, edx
jge .nomove
.endofstring:
sub esi, [.start]
mov eax, esi
mov eax, [.x]
.only_line:
mov edx, [.pline]
mov edx, [esi+TFreshEdit._FreeArea.x]
clc
.finish:
pop edi esi ebx
cmp eax, edx
return
endp
jl .nomove
; Converts the pointer parameters to caret coordinate.
; arguments:
; .index - index of the line
; .offset - byte offset inside the string.
; returns:
; eax - y coordinate of the caret
; edx - x coordinate of the caret
; ecx - pointer to the current TEditorLine
proc TFreshEdit.__PointerToPos, .editor, .index, .offset
.base dd ?
.x dd ?
begin
push esi edi
mov esi, [.editor]
mov edi, [esi+TFreshEdit._pIndex]
mov ecx, [.index]
add edx, [esi+TFreshEdit._FreeArea.width]
cmp eax, edx
jge .nomove
.line_loop:
cmp [edi+TArray.array+4*ecx], -1
jne .found
dec ecx
sub eax, [esi+TFreshEdit.__LeftMargin]
jge @f
xor eax, eax
jns .line_loop
@@:
.error:
stc
cdq
jmp .finish
idiv [esi+TFreshEdit._fontwidth]
.found:
mov [.base], ecx ; base index
mov [.x], 0
mov ecx, [edi+TArray.array+4*ecx] ; index in pLines
shl ecx, TEditorLine.shift
add ecx, [esi+TFreshEdit._pLines]
add eax, [esi+TFreshEdit._LeftColumn]
add ecx, TArray.array
cmp [.offset], 0
je .ready
push eax
; y
stdcall StrPtr, [ecx+TEditorLine.Data]
mov esi, eax
mov eax, [.y]
cdq
.char_loop:
stdcall DecodeUtf8, [esi]
jc .error
add esi, edx
idiv [esi+TFreshEdit._fontheight]
cmp eax, 1 ; wrap char
jne .no_wrap
inc [.base]
mov [.x], -1
.no_wrap:
inc [.x]
sub [.offset], edx
ja .char_loop
.ready:
mov eax, [.base]
mov edx, [.x]
add eax, [esi+TFreshEdit._TopLine]
pop edx
clc
.finish:
pop edi esi
pop edi esi ecx ebx
return
endp
.nomove:
stc
; .hString - the string containing the line.
;
; returns:
; eax - the width of the line in chars.
; if the line contains wrapped sublines,
; the maximal length will be returned.
proc TFreshEdit.__LineWidth, .hString
.maxlen dd ?
begin
push esi ecx edx
mov [.maxlen], 0
stdcall StrPtr, [.hString]
mov esi, eax
.outer:
xor ecx, ecx
.loop:
stdcall DecodeUtf8, [esi]
jc .error
add esi, edx
test eax, eax
jz .endofline
cmp eax, $01 ; wrap char
je .endofline
inc ecx
jmp .loop
jmp .finish
.endofline:
endp
cmp ecx, [.maxlen]
jbe .maxok
mov [.maxlen], ecx
.maxok:
test eax, eax
jnz .outer
mov eax, [.maxlen]
clc
.error:
pop edx ecx esi
return
endp
proc TFreshEdit.__FixLength, .editor, .newlen, .oldlen
begin
push eax ecx edx esi edi
|
︙ | | |
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
|
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
|
+
|
mov [esi+TFreshEdit._pLengths], edx
pop edi esi edx ecx eax
return
endp
proc TFreshEdit.__ComputeLeftMargin, .editor
begin
pushad
mov esi, [.editor]
xor ebx, ebx
mov [esi+TFreshEdit.__NumberMargin], ebx
|
︙ | | |
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
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
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
|
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
-
-
|
proc TFreshEdit.__FoldZoneLen, .editor, .index
.result dd ?
begin
pushad
mov [.result], 0
mov esi, [.editor]
mov edi, [esi+TFreshEdit._pLines]
mov edx, [esi+TFreshEdit._pIndex]
mov eax, [.index]
cmp eax, [edx+TArray.count]
jae .finish
mov ecx, [edx+TArray.array+4*eax] ; index of the first element.
shl ecx, TEditorLine.shift
mov ebx, [edi+TArray.array+ecx+TEditorLine.fold_level]
.loop:
inc [.result]
inc eax
cmp eax, [edx+TArray.count]
je .finish
mov ecx, [edx+TArray.array+4*eax]
cmp ecx, -1
je .loop
shl ecx, TEditorLine.shift
cmp [edi+TArray.array+ecx+TEditorLine.fold_level], ebx
jb .finish
ja .loop
test [edi+TArray.array+ecx+TEditorLine.flags], lfFoldHeader
jz .loop
; mov esi, [.editor]
; mov edi, [esi+TFreshEdit._pLines]
; mov edx, [esi+TFreshEdit._pIndex]
;
; mov eax, [.index]
; cmp eax, [edx+TArray.count]
; jae .finish
;
; mov ecx, [edx+TArray.array+4*eax] ; index of the first element.
; shl ecx, TEditorLine.shift
; mov ebx, [edi+TArray.array+ecx+TEditorLine.fold_level]
;
;.loop:
; inc [.result]
; inc eax
; cmp eax, [edx+TArray.count]
; je .finish
;
; mov ecx, [edx+TArray.array+4*eax]
; cmp ecx, -1
; je .loop
;
; shl ecx, TEditorLine.shift
;
; cmp [edi+TArray.array+ecx+TEditorLine.fold_level], ebx
; jb .finish
; ja .loop
;
; test [edi+TArray.array+ecx+TEditorLine.flags], lfFoldHeader
; jz .loop
.finish:
popad
mov eax, [.result]
return
endp
proc TFreshEdit.__RestoreIndex, .editor, .start_index, .end_index
begin
pushad
mov esi, [.editor]
mov edi, [esi+TFreshEdit._pIndex]
mov eax, [.start_index]
mov edx, [.end_index]
mov ebx, [edi+TArray.array+4*edx]
mov ecx, [edi+TArray.array+4*eax] ; index of the first element
sub ebx, ecx
dec ebx
jz .finish
stdcall InsertArrayItems, [esi+TFreshEdit._pIndex], edx, ebx
mov [esi+TFreshEdit._pIndex], edx
add [.end_index], ebx
.fill_loop:
inc ecx
mov [eax], ecx
add eax, 4
dec ebx
jnz .fill_loop
mov ecx, [.end_index]
.format_loop:
execute esi, TFreshEdit.FormatLine, ecx
dec ecx
cmp ecx, [.start_index]
jne .format_loop
.finish:
popad
return
endp
proc TFreshEdit.__AddFormatLine, .hstring, .format
begin
test [.format], lfBookmark or lfWordWrap or lfProtected
jz .format_ok
stdcall StrCharCat, [.hstring], ';#F:'
stdcall StrCharCat, [.hstring], ';'
test [.format], lfBookmark
jz @f
stdcall StrCharCat, [.hstring], 'b' ; ctrl-B == Bookmark
@@:
test [.format], lfWordWrap
jz @f
stdcall StrCharCat, [.hstring], 'w' ; ctrl-A == Word wrap
@@:
test [.format], lfProtected
jz @f
stdcall StrCharCat, [.hstring], 'p' ; ctrl-D == Protected
@@:
stdcall StrCharCat, [.hstring], ':F#;'
stdcall StrCharCat, [.hstring], $0a0d
.format_ok:
return
endp
; decodes format line (begining with ';#F:')
; returns:
; CF=0 if the line contains format information.
; eax - format flags
; ecx - format line length;
;
; decodes format line (ending with ':F#;')
; returns:
; CF=0 if the line contains format information.
; eax - format flags
; ecx - format line length;
;
proc TFreshEdit.__DecodeFormatLine, .pString
begin
push ebx esi
std
mov esi, [.pString]
mov ecx, [esi+string.len]
jecxz .not_format
lea esi, [esi+ecx-1]
lodsb
cmp al, ';'
jne .not_format
lodsb
cmp al, '#'
jne .not_format
lodsb
cmp al, 'F'
jne .not_format
lodsb
cmp al, ':'
jne .not_format
xor ebx, ebx
.format_loop:
lodsb
test al, al
jz .not_format
jecxz .eol
cmp al, $0d
cmp al, ';'
je .eol
cmp al, $0a
je .eol
cmp al, 'b'
jne @f
or ebx, lfBookmark
jmp .format_loop
@@:
|
︙ | | |
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
|
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
|
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
|
jmp .format_loop
@@:
.not_format:
xor eax, eax
pop esi ebx
stc
cld
return
.eol:
mov ah, al
xor ah, $0a xor $0d
lodsb
cmp al, ah
je .format_ok
dec esi
.format_ok:
sub esi, [.pString]
mov ecx, esi
mov eax, ebx
pop esi ebx
clc
cld
return
endp
endmodule
|
Added freshlib/FreshEdit/FreshEdit2.asm.