Subversion Repositories Kolibri OS

Rev

Rev 5838 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4274 tserj 1
diff16 'tp-key.asm',0,$
2
 
3
key:
4
	mov	ecx,1
5
	mcall	66,3		; Get status of the control keys
6
	mov	[shi],eax
7
	xor	ebx,ebx
8
	test	al,0x03 	; Left or right shift
9
	jz	@f
10
	or	ebx,KM_SHIFT
11
    @@: test	al,0x0C 	; Left or right control
12
	jz	@f
13
	or	ebx,KM_CTRL
14
    @@: test	al,0x10 	; Left alt
15
	jz	@f
16
	or	ebx,KM_ALT
17
    @@: mov	edx,ebx
18
	test	al,0x03
19
	jz	@f
20
	inc	cl
21
    @@:
22
	mcall	2
23
	cmp	al,0
24
	jne	still.skip_write
25
	shr	eax,8
26
;--------------------------------------
27
; this code for Win-keys, works with
28
; kernel SVN r.3356 or later
29
	test	[shi],0x200	; LWin
30
	jnz	still.skip_write
31
	test	[shi],0x400	; RWin
32
	jnz	still.skip_write
33
;--------------------------------------
34
	cmp	al,224
35
	jne	@f
36
	mov	[ext],0x01
37
	jmp	still.skip_write
38
    @@: cmp	al,225
39
	jne	@f
40
	mov	[ext],0x02
41
	jmp	still.skip_write
42
    @@:
43
	mov	ah,[ext]
44
	mov	[ext],0
45
 
46
	mov	esi,numpad_table_off
47
	test	[shi], 0x00000080 ; NumLock is on?
48
	jz	.num
49
	mov	esi,numpad_table_on
50
  .num: cmp	eax,[esi]
51
	jne	@f
52
	mov	eax,[esi+4]
53
	mov	ebx,eax
54
	or	eax,edx
55
	shr	ebx,8
56
	or	ebx,0x0000FFFF
57
	and	eax,ebx
58
	mov	ecx,eax
59
	shr	ecx,16
60
	and	cl,1
61
	inc	cl
62
	jmp	.lp0
63
    @@: add	esi,8
64
	cmp	dword[esi],0
65
	jne	.num
66
 
67
	or	eax,edx
68
 
69
  .lp0: test	al,0x80
70
	jnz	still.skip_write
71
;--------------------------------------
5838 pathoswith 72
; CAPS LOCK correct processing for chars
4274 tserj 73
	test	[shi], 0x00000040 ; CAPS LOCK is on?
74
	jz	.no_caps_lock
75
	cmp	ecx,1
76
	jnz	@f
77
	inc	ecx
78
	jmp	.no_caps_lock
79
@@:
80
	cmp	ecx,2
81
	jnz	.no_caps_lock
82
	dec	ecx
83
.no_caps_lock:
84
; alt gr pressed?
85
	test	[shi], 0x00000020
86
	jz	.no_alt_gr
87
	mov	ecx, 3
88
  .no_alt_gr:
89
	push	eax
90
	mcall	26,2,,key1
91
	pop	eax
92
 
93
	mov	[chr],eax
94
 
95
	cmp	[bot_mode],0
96
	je	@f
97
	mov	ebx,eax
98
	mov	al,2
99
	call	[bot_dlg_handler]
100
	jmp	still.skip_write
101
    @@:
102
 
103
	mov	esi,accel_table_main
104
  .acc: cmp	eax,[esi]
105
	jne	@f
106
	test	[secure_sel],1
107
	jz	.lp1
108
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
109
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
110
  .lp1: mov	[s_status],0
111
	call	dword[esi+4]
112
	call	editor_check_for_changes
113
	jmp	still
114
    @@: add	esi,8
115
	cmp	dword[esi],0
116
	jne	.acc
117
 
118
	test	[chr],KM_CTRLALT
119
	jnz	still.skip_write
120
 
121
	mov	[s_status],0
122
 
123
	movzx	eax,byte[chr]
124
	movzx	eax,[eax+key0]
125
	or	al,al
126
	jz	still.skip_write
127
	movzx	eax,[eax+key1]
128
	push	eax
129
 
130
	test	[secure_sel],1
131
	jz	.lp2
132
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
133
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
134
	jmp	.put
135
  .lp2: call	delete_selection
136
 
137
	test	[auto_braces],1
138
	jz	.put
139
	cmp	al,'['
140
	jne	@f
141
	mov	al,']'
142
	call	.lp3
143
	dec	[cur_editor.Caret.X]
144
	jmp	.put
145
    @@: cmp	al,'('
146
	jne	@f
147
	mov	al,')'
148
	call	.lp3
149
	dec	[cur_editor.Caret.X]
150
	jmp	.put
151
    @@: cmp	al,'{'
152
	jne	.put
153
	mov	al,'}'
154
	call	.lp3
155
	dec	[cur_editor.Caret.X]
156
 
157
  .put: pop	eax
158
	push	still editor_check_for_changes
159
	inc	[cur_editor.SelStart.X]
160
  .lp3: push	[cur_editor.Caret.X] eax
161
	inc	dword[esp+4]
162
	mov	eax,1
163
	jmp	key.tab.direct
164
 
5838 pathoswith 165
;---------------------------------------------------------------
166
proc key.ctrl_a ;///// SELECT ALL DOCUMENT /////////////////////
167
;---------------------------------------------------------------
4274 tserj 168
	xor	eax,eax
169
	mov	[cur_editor.SelStart.X],eax
170
	mov	[cur_editor.SelStart.Y],eax
171
	mov	ecx,[cur_editor.Lines.Count]
172
	dec	ecx
173
	mov	[cur_editor.Caret.Y],ecx
174
	call	get_line_offset
175
	call	get_real_length
176
	mov	[cur_editor.Caret.X],eax
177
	call	draw_editor
178
	ret
179
endp
180
 
5838 pathoswith 181
;---------------------------------------------------------------
182
proc key.ctrl_o ;///// ENTER OPEN FILENAME /////////////////////
183
;---------------------------------------------------------------
4274 tserj 184
	mov	[bot_mode2],0
185
 
186
  .direct:
187
	cmp	[bot_mode2], 2
188
	je	.ask
189
	mov	[s_status],s_enter_filename
190
	jmp	.ask1
191
 
192
   .ask:
193
	mov	[s_status],s_ask_save
194
  .ask1:
195
	mov	[bot_mode],1
196
	mov	[bot_dlg_height],16*2+4*2-1
197
	mov	[bot_dlg_handler],osdlg_handler
198
	mov	[focused_tb],tb_opensave
199
 
200
    @@: mov	al,[tb_opensave.length]
201
	mov	[tb_opensave.pos.x],al
202
	mov	[tb_opensave.sel.x],0
203
	mov	[tb_casesen],0;1
204
	call	drawwindow
205
	ret
206
endp
207
 
5838 pathoswith 208
;---------------------------------------------------------------
209
proc key.ctrl_s ;///// ENTER SAVE FILENAME /////////////////////
210
;---------------------------------------------------------------
4274 tserj 211
	cmp	[cur_editor.FilePath], 0
212
	je	key.shift_ctrl_s
213
	cmp	[cur_editor.Modified],0
214
	je	.exit
215
	call	save_file
216
	call	drawwindow
217
  .exit:
218
	ret
219
 
220
    key.shift_ctrl_s:
221
	mov	[bot_mode2],1
222
	jmp	key.ctrl_o.direct
223
endp
224
 
5838 pathoswith 225
;---------------------------------------------------------------
226
proc key.ctrl_n ;///// CREATE NEW FILE (TAB) ///////////////////
227
;---------------------------------------------------------------
4274 tserj 228
	call	create_tab
229
	ret
230
endp
231
 
5838 pathoswith 232
;---------------------------------------------------------------
233
proc key.ctrl_f ;///// ENTER KEYWORD TO FIND ///////////////////
234
;---------------------------------------------------------------
4274 tserj 235
	mov	[bot_mode2],0
236
	mov	[bot_dlg_height],16*2+4*2-1
237
 
238
	mov	[s_status],s_enter_text_to_find
239
 
240
  .direct:
241
	mov	[bot_mode],1
242
	mov	[bot_dlg_handler],finddlg_handler
243
	mov	[focused_tb],tb_find
244
 
245
	mov	ecx,[s_search.size]
246
	mov	[tb_find.length],cl
247
	jecxz	@f
248
	mov	esi,s_search
249
	mov	edi,tb_find.text
250
	cld
251
	rep	movsb
252
 
253
    @@: mov	al,[tb_find.length]
254
	mov	[tb_find.pos.x],al
255
	mov	[tb_find.sel.x],0
256
	mov	[tb_casesen],0
257
	call	drawwindow
258
	ret
259
endp
260
 
5838 pathoswith 261
;---------------------------------------------------------------
4274 tserj 262
proc key.ctrl_h
5838 pathoswith 263
;---------------------------------------------------------------
4274 tserj 264
	mov	[bot_mode2],1
265
	mov	[bot_dlg_height],16*3+4*2+1
266
	mov	[s_status],s_enter_text_to_replace
267
	jmp	key.ctrl_f.direct
268
endp
269
 
5838 pathoswith 270
;---------------------------------------------------------------
4274 tserj 271
proc key.ctrl_g
5838 pathoswith 272
;---------------------------------------------------------------
4274 tserj 273
	ret
5838 pathoswith 274
	; mov	[bot_mode2],0
275
	; mov	[bot_dlg_height],16*2+4*2-1
276
	; mov	[bot_mode],1
277
	; mov	[bot_dlg_handler],gotodlg_handler
278
	; mov	[focused_tb],tb_gotorow
279
	; mov	al,[tb_gotorow.length]
280
	; mov	[tb_gotorow.pos.x],al
281
	; mov	[tb_gotorow.sel.x],0
282
	; mov	[tb_casesen],0
283
	; call	drawwindow
284
	; ret
4274 tserj 285
endp
286
 
5838 pathoswith 287
;---------------------------------------------------------------
288
proc key.ctrl_left ;///// GO TO PREVIOUS WORD //////////////////
289
;---------------------------------------------------------------
4274 tserj 290
	call	clear_selection
5838 pathoswith 291
;---------------------------------------------------------------
292
     key.shift_ctrl_left: ; GO TO PREVIOUS WORD, WITH SELECTION
293
;---------------------------------------------------------------
4274 tserj 294
	mov	ebx,[cur_editor.Caret.Y]
295
	mov	edx,[cur_editor.Caret.X]
296
	cld
297
	mov	ecx,ebx
298
	call	get_line_offset
299
  .lp1: cmp	edx,[esi+EDITOR_LINE_DATA.Size]
300
	jle	@f
301
	mov	edx,[esi+EDITOR_LINE_DATA.Size]
302
    @@: dec	edx
303
	jl	.nx1
304
	add	esi,sizeof.EDITOR_LINE_DATA
305
	add	esi,edx
306
	mov	ecx,edx
307
    @@: push	ecx
308
	mov	edi,symbols_ex
309
	mov	ecx,symbols_ex.size+symbols.size
310
	mov	al,[esi]
311
	dec	esi
312
	repne	scasb
313
	pop	ecx
314
	jne	@f
315
	dec	edx
316
	dec	ecx
317
	jnz	@b
318
  .nx1: dec	ebx
319
	js	.exit.2
320
	mov	ecx,ebx
321
	call	get_line_offset
322
	mov	edx,[esi+EDITOR_LINE_DATA.Size]
323
	dec	edx
324
	jmp	.lp1
325
    @@:
326
	mov	ecx,ebx
327
	call	get_line_offset
328
  .lp2: cmp	edx,[esi+EDITOR_LINE_DATA.Size]
329
	jle	@f
330
	mov	edx,[esi+EDITOR_LINE_DATA.Size]
331
    @@: or	edx,edx
332
	jl	.nx2
333
	add	esi,sizeof.EDITOR_LINE_DATA
334
	add	esi,edx
335
    @@: mov	edi,symbols_ex
336
	mov	ecx,symbols_ex.size+symbols.size
337
	mov	al,[esi]
338
	dec	esi
339
	repne	scasb
340
	je	@f
341
	dec	edx
342
	jns	@b
343
	jmp	@f
344
  .nx2: dec	ebx
345
	js	.exit.2
346
	mov	ecx,ebx
347
	call	get_line_offset
348
	mov	edx,[esi+EDITOR_LINE_DATA.Size]
349
	dec	edx
350
	jmp	.lp2
351
    @@:
352
	inc	edx
353
	mov	[cur_editor.Caret.Y],ebx
354
	mov	[cur_editor.Caret.X],edx
355
	test	[chr],KM_SHIFT
356
	jnz	@f
357
	mov	[cur_editor.SelStart.Y],ebx
358
	mov	[cur_editor.SelStart.X],edx
359
    @@: sub	ebx,[cur_editor.TopLeft.Y]
360
	jge	@f
361
	add	[cur_editor.TopLeft.Y],ebx
362
    @@: mov	eax,edx
363
	sub	eax,[cur_editor.TopLeft.X]
364
	cmp	eax,[columns.scr]
365
	jl	@f
366
	sub	eax,[columns.scr]
367
	inc	eax
368
	add	[cur_editor.TopLeft.X],eax
369
	jmp	.exit
370
    @@: cmp	edx,[cur_editor.TopLeft.X]
371
	jge	.exit
372
	mov	[cur_editor.TopLeft.X],edx
373
  .exit:
374
	call	editor_check_for_changes
375
  .exit.2:
376
	ret
377
endp
378
 
5838 pathoswith 379
;---------------------------------------------------------------
380
proc key.ctrl_right ;///// GO TO NEXT WORD /////////////////////
381
;---------------------------------------------------------------
4274 tserj 382
	call	clear_selection
5838 pathoswith 383
;---------------------------------------------------------------
384
     key.shift_ctrl_right: ;/ GO TO NEXT WORD, WITH SELECTION //
385
;---------------------------------------------------------------
4274 tserj 386
	mov	ebx,[cur_editor.Caret.Y]
387
	mov	edx,[cur_editor.Caret.X]
388
	cld
389
  .lp1: mov	ecx,ebx
390
	call	get_line_offset
391
	mov	ecx,[esi+EDITOR_LINE_DATA.Size]
392
	cmp	edx,ecx
393
	jge	.nx1
394
	add	esi,sizeof.EDITOR_LINE_DATA
395
	add	esi,edx
396
	sub	ecx,edx
397
    @@: push	ecx
398
	mov	edi,symbols_ex
399
	mov	ecx,symbols_ex.size+symbols.size
400
	lodsb
401
	repne	scasb
402
	pop	ecx
403
	je	@f
404
	inc	edx
405
	dec	ecx
406
	jnz	@b
407
  .nx1: inc	ebx
408
	cmp	ebx,[cur_editor.Lines.Count]
409
	jge	.exit.2
410
	xor	edx,edx
411
	jmp	.lp1
412
    @@:
413
 
414
  .lp2: mov	ecx,ebx
415
	call	get_line_offset
416
	mov	ecx,[esi+EDITOR_LINE_DATA.Size]
417
	cmp	edx,ecx
418
	jge	.nx2
419
	add	esi,sizeof.EDITOR_LINE_DATA
420
	add	esi,edx
421
	sub	ecx,edx
422
    @@: push	ecx
423
	mov	edi,symbols_ex
424
	mov	ecx,symbols_ex.size+symbols.size
425
	lodsb
426
	repne	scasb
427
	pop	ecx
428
	jne	@f
429
	inc	edx
430
	dec	ecx
431
	jnz	@b
432
  .nx2: inc	ebx
433
	cmp	ebx,[cur_editor.Lines.Count]
434
	jge	.exit.2
435
	xor	edx,edx
436
	jmp	.lp2
437
    @@:
438
	mov	[cur_editor.Caret.Y],ebx
439
	mov	[cur_editor.Caret.X],edx
440
	test	[chr],KM_SHIFT
441
	jnz	@f
442
	mov	[cur_editor.SelStart.Y],ebx
443
	mov	[cur_editor.SelStart.X],edx
444
    @@: sub	ebx,[cur_editor.TopLeft.Y]
445
	cmp	ebx,[lines.scr]
446
	jl	@f
447
	sub	ebx,[lines.scr]
448
	inc	ebx
449
	add	[cur_editor.TopLeft.Y],ebx
450
    @@: mov	eax,edx
451
	sub	eax,[cur_editor.TopLeft.X]
452
	cmp	eax,[columns.scr]
453
	jl	@f
454
	sub	eax,[columns.scr]
455
	inc	eax
456
	add	[cur_editor.TopLeft.X],eax
457
	jmp	.exit
458
    @@: cmp	edx,[cur_editor.TopLeft.X]
459
	jge	.exit
460
	mov	[cur_editor.TopLeft.X],edx
461
  .exit:
462
	call	editor_check_for_changes
463
  .exit.2:
464
	ret
465
endp
466
 
5838 pathoswith 467
;---------------------------------------------------------------
468
proc key.ctrl_x ;///// CUT /////////////////////////////////////
469
;---------------------------------------------------------------
4274 tserj 470
	cmp	[sel.selected],0
471
	je	@f
472
	call	key.ctrl_c
473
	call	key.del
474
	mov	[cur_editor.Modified],1
475
    @@: ret
476
endp
477
 
5838 pathoswith 478
;---------------------------------------------------------------
479
proc key.ctrl_c ;///// COPY ////////////////////////////////////
480
;---------------------------------------------------------------
4487 mario79 481
        mov     [copy_size],0
482
        cmp     [sel.selected],0
483
        je      .exit
4274 tserj 484
 
4487 mario79 485
        call    get_selection_size
486
	push	eax
487
        stdcall mem.ReAlloc,[copy_buf],eax
488
        mov     [copy_buf],eax
489
	pop	eax
490
        stdcall mem.ReAlloc,[clipboard_buf],eax
491
        mov     [clipboard_buf],eax
4274 tserj 492
 
4487 mario79 493
        cld
494
        mov     eax,[sel.begin.y]
495
        cmp     eax,[sel.end.y]
496
        je      .single_line
497
        mov     ecx,[sel.begin.y]
498
        call    get_line_offset
499
        inc     ecx
500
        push    ecx
501
        mov     edi,[copy_buf]
502
        call    get_real_length
503
        sub     eax,[sel.begin.x]
504
        jge     @f
505
        xor     eax,eax
506
    @@: add     esi,[sel.begin.x]
507
        add     esi,sizeof.EDITOR_LINE_DATA
508
        mov     [edi+EDITOR_LINE_DATA.Size],eax
509
        add     edi,sizeof.EDITOR_LINE_DATA
510
        mov     ecx,eax
511
        jecxz   @f
512
        rep     movsb
513
    @@: mov     ecx,[sel.end.y]
514
        call    get_line_offset
515
        pop     ecx
516
        cmp     ecx,[sel.end.y]
517
        je      @f
518
        mov     eax,esi
519
        call    get_line_offset
520
        sub     eax,esi
521
        mov     ecx,eax
522
        rep     movsb
523
        mov     ecx,[sel.end.y]
524
    @@: call    get_line_offset
525
        mov     eax,[esi+EDITOR_LINE_DATA.Size]
526
        add     esi,sizeof.EDITOR_LINE_DATA
527
        cmp     eax,[sel.end.x]
528
        jle     @f
529
        mov     eax,[sel.end.x]
530
    @@: mov     ebx,edi
531
        mov     [edi+EDITOR_LINE_DATA.Size],eax
532
        add     edi,sizeof.EDITOR_LINE_DATA
533
        mov     ecx,eax
534
        jecxz   @f
535
        rep     movsb
536
        sub     eax,[sel.end.x]
537
        jz      @f
538
        neg     eax
539
        mov     ecx,eax
540
        add     [ebx],eax
541
        mov     al,' '
542
        rep     stosb
543
    @@: sub     edi,[copy_buf]
544
        mov     [copy_size],edi
545
        mov     eax,[sel.end.y]
546
        sub     eax,[sel.begin.y]
547
        inc     eax
548
        mov     [copy_count],eax
549
	call	put_to_clipboard
4274 tserj 550
  .exit:
4487 mario79 551
        ret
4274 tserj 552
 
553
  .single_line:
554
	mov	eax,[sel.end.x]
555
	sub	eax,[sel.begin.x]
556
	mov	edi,[copy_buf]
557
	mov	[edi+EDITOR_LINE_DATA.Size],eax
558
	add	edi,sizeof.EDITOR_LINE_DATA
559
	mov	ecx,[sel.begin.y]
560
	call	get_line_offset
561
	mov	ebx,[sel.begin.x]
562
	mov	ecx,[sel.end.x]
563
	cmp	ebx,[esi+EDITOR_LINE_DATA.Size]
564
	jge	.add_spaces
565
	cmp	ecx,[esi+EDITOR_LINE_DATA.Size]
566
	jle	.lp1
567
	mov	ecx,[esi+EDITOR_LINE_DATA.Size]
568
  .lp1: sub	ecx,[sel.begin.x]
569
	sub	eax,ecx
570
	lea	esi,[esi+ebx+sizeof.EDITOR_LINE_DATA]
571
	rep	movsb
572
 
573
  .add_spaces:
574
	mov	ecx,eax
575
	mov	al,' '
576
	jecxz	@b
577
	rep	stosb
578
	jmp	@b
579
endp
580
 
5838 pathoswith 581
;---------------------------------------------------------------
582
proc key.ctrl_v ;///// PASTE ///////////////////////////////////
583
;---------------------------------------------------------------
4490 mario79 584
	cmp	[replace_mode],0
585
	jne	@f
4487 mario79 586
	call	get_from_clipboard
4490 mario79 587
@@:
4274 tserj 588
	cmp	[copy_size],0
5579 Pathoswith 589
	je	.exit_1
4274 tserj 590
	call	delete_selection
591
	mov	eax,[copy_size]
5579 Pathoswith 592
	sub	eax,sizeof.EDITOR_LINE_DATA
4274 tserj 593
	call	editor_realloc_lines
594
	mov	ecx,[cur_editor.Caret.Y]
595
	call	get_line_offset
596
	mov	ecx,[cur_editor.Caret.X]
597
	call	line_add_spaces
5579 Pathoswith 598
	pushd	[esi+EDITOR_LINE_DATA.Size]
599
	push	esi
600
	lea	eax,[esi+ecx+sizeof.EDITOR_LINE_DATA]
601
	mov	edi,[cur_editor.Lines]
602
	add	edi,[cur_editor.Lines.Size]
603
	dec	edi
4274 tserj 604
	mov	ecx,[copy_size]
605
	sub	ecx,sizeof.EDITOR_LINE_DATA
606
	mov	esi,edi
607
	sub	esi,ecx
5579 Pathoswith 608
	neg	eax
609
	lea	ecx,[esi+eax+1]
4274 tserj 610
	std
611
	rep	movsb
612
	cld
613
	pop	edi
614
	mov	esi,[copy_buf]
615
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
616
	add	esi,sizeof.EDITOR_LINE_DATA
5579 Pathoswith 617
	mov	ecx,[copy_count]
618
	dec	ecx
619
	jz	.single_line
4274 tserj 620
 
5579 Pathoswith 621
	add	eax,[cur_editor.Caret.X]
622
	mov	[edi+EDITOR_LINE_DATA.Size],eax
623
	mov	[edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
624
	sub	eax,[cur_editor.Caret.X]
4274 tserj 625
	call	.check_columns
5579 Pathoswith 626
	add	edi,[cur_editor.Caret.X]
627
@@:
628
	push	ecx
4274 tserj 629
	mov	ecx,eax
5579 Pathoswith 630
	add	edi,sizeof.EDITOR_LINE_DATA
4274 tserj 631
	rep	movsb
632
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
633
	add	esi,sizeof.EDITOR_LINE_DATA
634
	mov	[edi+EDITOR_LINE_DATA.Size],eax
635
	mov	[edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
636
	pop	ecx
637
	loop	@b
638
 
639
	pop	ecx
5579 Pathoswith 640
	sub	ecx,[cur_editor.Caret.X]
641
	add	[edi+EDITOR_LINE_DATA.Size],ecx
4274 tserj 642
	call	.check_columns
5579 Pathoswith 643
	add	edi,sizeof.EDITOR_LINE_DATA
4274 tserj 644
	mov	ecx,eax
645
	rep	movsb
4566 mario79 646
.save_cur_editor_values:
4274 tserj 647
	mov	[cur_editor.Caret.X],eax
648
	mov	[cur_editor.SelStart.X],eax
649
	mov	eax,[copy_count]
650
	dec	eax
651
	add	[cur_editor.Caret.Y],eax
652
	add	[cur_editor.SelStart.Y],eax
653
	add	[cur_editor.Lines.Count],eax
654
	mov	[cur_editor.Modified],1
655
	jmp	.exit
656
 
5579 Pathoswith 657
.single_line:
658
	add	[edi+EDITOR_LINE_DATA.Size],eax
659
	mov	[edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
660
	call	.check_columns
4274 tserj 661
	add	edi,sizeof.EDITOR_LINE_DATA
662
	add	edi,[cur_editor.Caret.X]
5579 Pathoswith 663
	pop	ecx
4274 tserj 664
	mov	ecx,eax
665
	rep	movsb
666
	add	[cur_editor.Caret.X],eax
667
	add	[cur_editor.SelStart.X],eax
668
	mov	[cur_editor.Modified],1
5579 Pathoswith 669
.exit:
4490 mario79 670
	cmp	[replace_mode],0
671
	jne	.exit_1
5579 Pathoswith 672
	stdcall	mem.Free,[copy_buf]
4487 mario79 673
	xor	eax,eax
5579 Pathoswith 674
	mov	[copy_buf],eax
4487 mario79 675
	mov	[copy_size],eax
5579 Pathoswith 676
	mov	[copy_count],eax
4487 mario79 677
.exit_1:
4274 tserj 678
	ret
679
 
5579 Pathoswith 680
.check_columns:
4274 tserj 681
	push	eax
5579 Pathoswith 682
	mov	eax,[edi+EDITOR_LINE_DATA.Size]
4274 tserj 683
	cmp	eax,[cur_editor.Columns.Count]
684
	jbe	@f
685
	mov	[cur_editor.Columns.Count],eax
5579 Pathoswith 686
@@:
687
	pop	eax
4274 tserj 688
	ret
689
endp
5838 pathoswith 690
;---------------------------------------------------------------
691
proc key.ctrl_d ;///// INSERT SEPARATOR ////////////////////////
692
;---------------------------------------------------------------
4274 tserj 693
	mov	eax,90+sizeof.EDITOR_LINE_DATA
694
	call	editor_realloc_lines
695
 
696
	mov	ecx,[cur_editor.Caret.Y]
697
	call	get_line_offset
698
	mov	ebx,esi
699
 
700
	mov	ecx,[cur_editor.Lines.Count]
701
	call	get_line_offset
702
	lea	edi,[esi+90+sizeof.EDITOR_LINE_DATA]
703
	lea	ecx,[esi+sizeof.EDITOR_LINE_DATA]
704
	sub	ecx,ebx
705
	std
706
	rep	movsb
707
 
708
	lea	edi,[ebx+sizeof.EDITOR_LINE_DATA+1]
709
	mov	[ebx+EDITOR_LINE_DATA.Size],90
710
	mov	al,ASEPC
711
	mov	ecx,79
712
	cld
713
	rep	stosb
714
	mov	al,' '
715
	mov	ecx,10
716
	rep	stosb
717
	mov	byte[ebx+sizeof.EDITOR_LINE_DATA],';'
718
 
719
	inc	[cur_editor.Lines.Count]
720
	inc	[cur_editor.Caret.Y]
721
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
722
 
723
	mov	[cur_editor.Modified],1
724
 
725
  .exit:
726
	ret
727
endp
728
 
5838 pathoswith 729
;---------------------------------------------------------------
730
proc key.ctrl_y ;///// DELETE CURRENT LINE /////////////////////
731
;---------------------------------------------------------------
4274 tserj 732
	mov	eax,[cur_editor.Caret.Y]
733
	inc	eax
734
	cmp	eax,[cur_editor.Lines.Count]
735
	jge	.exit
736
 
737
	mov	ecx,[cur_editor.Caret.Y]
738
	call	get_line_offset
739
	mov	edi,esi
740
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
741
	lea	esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
742
	push	eax
743
 
744
	dec	[cur_editor.Lines.Count]
745
	mov	ecx,[cur_editor.Lines]
746
	add	ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
747
	sub	ecx,esi
748
	shr	ecx,2
749
	cld
750
	rep	movsd
751
 
752
	pop	eax
753
	add	eax,sizeof.EDITOR_LINE_DATA
754
	neg	eax
755
	call	editor_realloc_lines
756
 
757
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
758
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
759
 
760
	mov	[cur_editor.Modified],1
761
 
762
  .exit:
763
	ret
764
endp
765
 
5838 pathoswith 766
;---------------------------------------------------------------
767
proc key.up ;///// GO TO PREVIOUS LINE /////////////////////////
768
;---------------------------------------------------------------
5579 Pathoswith 769
	call	key.shift_up
770
	jmp	clear_selection
5838 pathoswith 771
 
772
;---------------------------------------------------------------
773
     key.shift_up: ;/// GO TO PREVIOUS LINE, WITH SELECTION ////
774
;---------------------------------------------------------------
5579 Pathoswith 775
	mov	ecx,[cur_editor.Caret.Y]
4274 tserj 776
	dec	ecx
5579 Pathoswith 777
	js	.exit
778
	mov	[cur_editor.Caret.Y],ecx
779
	call	get_line_offset
780
	mov	eax,[esi]
781
	cmp	eax,[cur_editor.Caret.X]
782
	jnc	.exit
783
	mov	[cur_editor.Caret.X],eax
784
.exit:
4274 tserj 785
	ret
786
endp
787
 
5838 pathoswith 788
;---------------------------------------------------------------
789
proc key.down ;///// GO TO NEXT LINE ///////////////////////////
790
;---------------------------------------------------------------
5579 Pathoswith 791
	call	key.shift_down
792
	jmp	clear_selection
5838 pathoswith 793
 
794
;---------------------------------------------------------------
795
     key.shift_down: ;//// GO TO NEXT LINE, WITH SELECTION /////
796
;---------------------------------------------------------------
5579 Pathoswith 797
	mov	ecx,[cur_editor.Caret.Y]
4274 tserj 798
	inc	ecx
5579 Pathoswith 799
	cmp	[cur_editor.Lines.Count],ecx
800
	jz	.exit
801
	mov	[cur_editor.Caret.Y],ecx
802
	call	get_line_offset
803
	mov	eax,[esi]
804
	cmp	eax,[cur_editor.Caret.X]
805
	jnc	.exit
806
	mov	[cur_editor.Caret.X],eax
807
.exit:
4274 tserj 808
	ret
809
endp
810
 
5838 pathoswith 811
;---------------------------------------------------------------
812
proc key.left ;///// GO TO PREVIOUS CHAR ///////////////////////
813
;---------------------------------------------------------------
5579 Pathoswith 814
	call	key.shift_left
815
	jmp	clear_selection
5838 pathoswith 816
 
817
;---------------------------------------------------------------
818
     key.shift_left: ;// GO TO PREVIOUS CHAR, WITH SELECTION ///
819
;---------------------------------------------------------------
4274 tserj 820
	mov	eax,[cur_editor.Caret.X]
821
	dec	eax
822
	jns	@f
5579 Pathoswith 823
	mov	ecx,[cur_editor.Caret.Y]
824
	dec	ecx
825
	js	.exit
826
	mov	[cur_editor.Caret.Y],ecx
827
	call	get_line_offset
828
	mov	eax,[esi]
829
@@:
830
	mov	[cur_editor.Caret.X],eax
831
.exit:
4274 tserj 832
	ret
833
endp
834
 
5838 pathoswith 835
;---------------------------------------------------------------
836
proc key.right ;///// GO TO NEXT CHAR //////////////////////////
837
;---------------------------------------------------------------
5579 Pathoswith 838
	call	key.shift_right
839
	jmp	clear_selection
5838 pathoswith 840
 
841
;---------------------------------------------------------------
842
     key.shift_right: ;//// GO TO NEXT CHAR, WITH SELECTION ////
843
;---------------------------------------------------------------
5579 Pathoswith 844
	mov	ecx,[cur_editor.Caret.Y]
845
	call	get_line_offset
4274 tserj 846
	mov	eax,[cur_editor.Caret.X]
847
	inc	eax
5579 Pathoswith 848
	cmp	[esi],eax
849
	jnc	@f
850
	inc	ecx
851
	cmp	[cur_editor.Lines.Count],ecx
852
	jz	.exit
853
	xor	eax,eax
854
	mov	[cur_editor.Caret.Y],ecx
855
@@:
856
	mov	[cur_editor.Caret.X],eax
857
.exit:
4274 tserj 858
	ret
859
endp
860
 
5838 pathoswith 861
;---------------------------------------------------------------
862
proc key.pgup ;///// GO TO PREVIOUS PAGE ///////////////////////
863
;---------------------------------------------------------------
4274 tserj 864
	call	clear_selection
5838 pathoswith 865
;---------------------------------------------------------------
866
     key.shift_pgup: ;// GO TO PREVIOUS PAGE, WITH SELECTION ///
867
;---------------------------------------------------------------
4274 tserj 868
	mov	edx,[lines.scr]
869
	dec	edx
870
	mov	eax,[cur_editor.Caret.Y]
871
	mov	ecx,[cur_editor.TopLeft.Y]
872
	sub	eax,edx
873
	jns	@f
874
	xor	eax,eax
875
    @@: sub	ecx,edx
876
	jns	@f
877
	xor	ecx,ecx
878
    @@: test	[chr],KM_SHIFT
879
	jnz	@f
880
	mov	[cur_editor.SelStart.Y],eax
881
    @@: mov	[cur_editor.Caret.Y],eax
882
	mov	[cur_editor.TopLeft.Y],ecx
883
 
884
  .exit:
885
	ret
886
endp
887
 
5838 pathoswith 888
;---------------------------------------------------------------
889
proc key.pgdn ;///// GO TO NEXT PAGE ///////////////////////////
890
;---------------------------------------------------------------
4274 tserj 891
	call	clear_selection
5838 pathoswith 892
;---------------------------------------------------------------
893
     key.shift_pgdn: ;//// GO TO NEXT PAGE, WITH SELECTION /////
894
;---------------------------------------------------------------
4274 tserj 895
	mov	edx,[lines.scr]
896
	dec	edx
897
	mov	eax,[cur_editor.Caret.Y]
898
	mov	ecx,[cur_editor.TopLeft.Y]
899
	add	eax,edx
900
	add	ecx,edx
901
	cmp	eax,[cur_editor.Lines.Count]
902
	jb	@f
903
	mov	eax,[cur_editor.Lines.Count]
904
	dec	eax
905
    @@: test	[chr],KM_SHIFT
906
	jnz	@f
907
	mov	[cur_editor.SelStart.Y],eax
908
    @@: mov	[cur_editor.Caret.Y],eax
909
	mov	[cur_editor.TopLeft.Y],ecx
910
 
911
  .exit:
912
	ret
913
endp
914
 
5838 pathoswith 915
;---------------------------------------------------------------
916
proc key.home ;///// GO TO LINE START //////////////////////////
917
;---------------------------------------------------------------
4274 tserj 918
	call	clear_selection
5838 pathoswith 919
;---------------------------------------------------------------
920
     key.shift_home: ;//// GO TO LINE START, WITH SELECTION ////
921
;---------------------------------------------------------------
4274 tserj 922
	mov	[cur_editor.Caret.X],0
923
	test	[chr],KM_SHIFT
924
	jnz	@f
925
	mov	[cur_editor.SelStart.X],0
926
    @@:
927
 
928
  .exit:
929
	ret
930
endp
931
 
5838 pathoswith 932
;---------------------------------------------------------------
933
proc key.end ;///// GO TO LINE END /////////////////////////////
934
;---------------------------------------------------------------
4274 tserj 935
	call	clear_selection
5838 pathoswith 936
;---------------------------------------------------------------
937
     key.shift_end: ;///// GO TO LINE END, WITH SELECTION //////
938
;---------------------------------------------------------------
4274 tserj 939
	mov	ecx,[cur_editor.Caret.Y]
940
	call	get_line_offset
941
	call	get_real_length
942
	mov	[cur_editor.Caret.X],eax
943
	test	[chr],KM_SHIFT
944
	jnz	@f
945
	mov	[cur_editor.SelStart.X],eax
946
    @@:
947
 
948
  .exit:
949
	ret
950
endp
951
 
5838 pathoswith 952
;---------------------------------------------------------------
953
proc key.ctrl_home ;///// GO TO PAGE START /////////////////////
954
;---------------------------------------------------------------
4274 tserj 955
	call	clear_selection
5838 pathoswith 956
;---------------------------------------------------------------
957
     key.shift_ctrl_home: ;/ GO TO PAGE START, WITH SELECTION //
958
;---------------------------------------------------------------
4274 tserj 959
	mov	eax,[cur_editor.TopLeft.Y]
960
	mov	ecx,eax
961
	test	[chr],KM_SHIFT
962
	jnz	@f
963
	mov	[cur_editor.SelStart.Y],eax
964
    @@: mov	[cur_editor.Caret.Y],eax
965
	mov	[cur_editor.TopLeft.Y],ecx
966
 
967
  .exit:
968
	ret
969
endp
970
 
5838 pathoswith 971
;---------------------------------------------------------------
972
proc key.ctrl_end ;///// GO TO PAGE END ////////////////////////
973
;---------------------------------------------------------------
4274 tserj 974
	call	clear_selection
5838 pathoswith 975
;---------------------------------------------------------------
976
     key.shift_ctrl_end: ;/// GO TO PAGE END, WITH SELECTION ///
977
;---------------------------------------------------------------
4274 tserj 978
	mov	ecx,[cur_editor.TopLeft.Y]
979
	mov	eax,[lines.scr]
980
	cmp	eax,[cur_editor.Lines.Count]
981
	jle	@f
982
	mov	eax,[cur_editor.Lines.Count]
983
    @@: add	eax,ecx
984
	dec	eax
985
	test	[chr],KM_SHIFT
986
	jnz	@f
987
	mov	[cur_editor.SelStart.Y],eax
988
    @@: mov	[cur_editor.Caret.Y],eax
989
	mov	[cur_editor.TopLeft.Y],ecx
990
 
991
  .exit:
992
	ret
993
endp
994
 
5838 pathoswith 995
;---------------------------------------------------------------
996
proc key.ctrl_pgup ;///// GO TO DOCUMENT START /////////////////
997
;---------------------------------------------------------------
4274 tserj 998
	call	clear_selection
5838 pathoswith 999
;---------------------------------------------------------------
1000
     key.shift_ctrl_pgup: ; GO TO DOCUMENT START, WITH SELECTION
1001
;---------------------------------------------------------------
4274 tserj 1002
	xor	eax,eax
1003
	mov	[cur_editor.TopLeft.Y],eax
1004
	mov	[cur_editor.Caret.Y],eax
1005
	test	[chr],KM_SHIFT
1006
	jnz	@f
1007
	mov	[cur_editor.SelStart.Y],eax
1008
    @@:
1009
 
1010
  .exit:
1011
	ret
1012
endp
1013
 
5838 pathoswith 1014
;---------------------------------------------------------------
1015
proc key.ctrl_pgdn ;///// GO TO DOCUMENT END ///////////////////
1016
;---------------------------------------------------------------
4274 tserj 1017
	call	clear_selection
5838 pathoswith 1018
;---------------------------------------------------------------
1019
     key.shift_ctrl_pgdn: ; GO TO DOCUMENT END, WITH SELECTION /
1020
;---------------------------------------------------------------
4274 tserj 1021
	mov	eax,[cur_editor.Lines.Count]
1022
	mov	[cur_editor.Caret.Y],eax
1023
	sub	eax,[lines.scr]
1024
	jns	@f
1025
	xor	eax,eax
1026
    @@: mov	[cur_editor.TopLeft.Y],eax
1027
	dec	[cur_editor.Caret.Y]
1028
	test	[chr],KM_SHIFT
1029
	jnz	@f
1030
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
1031
    @@:
1032
 
1033
  .exit:
1034
	ret
1035
endp
1036
 
5838 pathoswith 1037
;---------------------------------------------------------------
1038
proc key.del ;///// DELETE NEXT CHAR OR SELECTION //////////////
1039
;---------------------------------------------------------------
4274 tserj 1040
	call	delete_selection
1041
	jnc	.exit
1042
 
1043
	mov	ecx,[cur_editor.Caret.Y]
1044
	call	get_line_offset
1045
	and	[esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
1046
	or	[esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1047
	lea	ebx,[esi+sizeof.EDITOR_LINE_DATA]
1048
	mov	ebp,esi
1049
 
1050
	call	get_real_length
1051
	or	eax,eax
1052
	je	.line_up
1053
 
1054
	mov	ecx,[cur_editor.Caret.X]
1055
	cmp	ecx,eax
1056
	jae	.line_up
1057
	lea	edi,[ebx+ecx]
1058
	neg	ecx
1059
	mov	eax,[ebp+EDITOR_LINE_DATA.Size]
1060
	add	ecx,eax;[ebp]
1061
	repe	scasb
1062
	je	.line_up
1063
 
1064
	mov	edi,ebx
1065
	mov	ecx,[cur_editor.Caret.X]
1066
	add	edi,ecx
1067
	lea	esi,[edi+1]
1068
	neg	ecx
1069
	mov	eax,[ebp+EDITOR_LINE_DATA.Size]
1070
	add	ecx,eax;[ebp]
1071
	dec	ecx
1072
	rep	movsb
1073
	mov	byte[edi],' '
1074
 
1075
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
1076
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
1077
	mov	[cur_editor.Modified],1
1078
	ret
1079
 
1080
  .line_up:
1081
	mov	eax,[cur_editor.Lines.Count]
1082
	dec	eax
1083
	cmp	eax,[cur_editor.Caret.Y]
1084
	je	.exit
1085
	mov	edi,[temp_buf]
1086
	add	edi,sizeof.EDITOR_LINE_DATA
1087
	mov	esi,ebx
1088
	mov	ecx,[cur_editor.Caret.X]
1089
	rep	movsb
1090
	mov	ecx,[cur_editor.Caret.X]
1091
	mov	eax,[temp_buf]
1092
	mov	[eax+EDITOR_LINE_DATA.Size],ecx
1093
	cmp	ecx,[ebp+EDITOR_LINE_DATA.Size]
1094
	jbe	@f
1095
	mov	eax,[ebp+EDITOR_LINE_DATA.Size]
1096
	sub	ecx,eax
1097
	sub	edi,ecx
1098
	mov	al,' '
1099
	rep	stosb
1100
    @@: lea	esi,[ebx+sizeof.EDITOR_LINE_DATA]
1101
	mov	eax,[ebp+EDITOR_LINE_DATA.Size]
1102
	add	esi,eax
1103
	mov	ecx,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
1104
	mov	eax,[temp_buf]
1105
	add	[eax+EDITOR_LINE_DATA.Size],ecx
1106
	or	[eax+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1107
	rep	movsb
1108
 
1109
	mov	ecx,edi
1110
	sub	ecx,[temp_buf]
1111
 
1112
	mov	esi,[temp_buf]
1113
	call	get_real_length
1114
	cmp	eax,[cur_editor.Columns.Count]
1115
	jbe	@f
1116
	mov	[cur_editor.Columns.Count],eax
1117
    @@:
1118
	push	ecx
1119
	mov	edi,[cur_editor.Lines]
1120
	add	edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
1121
	dec	edi
1122
	lea	esi,[edi+sizeof.EDITOR_LINE_DATA*2] ; !!! CHECK THIS !!!
1123
	sub	esi,ecx
1124
	mov	eax,[ebp+EDITOR_LINE_DATA.Size]
1125
	add	esi,eax
1126
	mov	eax,[ebp+eax+sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
1127
	add	esi,eax
1128
	lea	ecx,[esi-sizeof.EDITOR_LINE_DATA]
1129
	sub	ecx,ebp
1130
	std
1131
	cmp	esi,edi
1132
	jb	@f
1133
	jz	.lp1
1134
	mov	edi,ebp
1135
	add	edi,[esp]
1136
	lea	esi,[ebp+sizeof.EDITOR_LINE_DATA*2] ; !!! CHECK THIS !!!
1137
	mov	eax,[esi-sizeof.EDITOR_LINE_DATA*2+EDITOR_LINE_DATA.Size] ; !!! CHECK THIS !!!
1138
	add	esi,eax
1139
	mov	eax,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size] ; !!! CHECK THIS !!!
1140
	add	esi,eax
1141
	mov	ecx,[cur_editor.Lines]
1142
	add	ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
1143
	sub	ecx,esi
1144
	cld
1145
    @@: rep	movsb
1146
  .lp1: pop	ecx
1147
	mov	esi,[temp_buf]
1148
	mov	edi,ebp
1149
	cld
1150
	rep	movsb
1151
 
1152
  .ok.dec.lines:
1153
	dec	[cur_editor.Lines.Count]
1154
	mov	eax,[cur_editor.Lines.Count]
1155
	cmp	[cur_editor.Caret.Y],eax
1156
	jb	@f
1157
	dec	eax
1158
	mov	[cur_editor.Caret.Y],eax
1159
    @@: m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
1160
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
1161
 
1162
	mov	ecx,[cur_editor.Lines.Count]
1163
	call	get_line_offset
1164
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
1165
	lea	esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
1166
	mov	eax,[cur_editor.Lines]
1167
	add	eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4]
1168
	sub	esi,eax
1169
	lea	eax,[esi+4096]
1170
	call	editor_realloc_lines
1171
 
1172
	mov	[cur_editor.Modified],1
1173
 
1174
  .exit:
1175
	ret
1176
endp
1177
 
5838 pathoswith 1178
;---------------------------------------------------------------
1179
proc key.ins ;///// TOGGLE INSERT/OVERWRITE MODE ///////////////
1180
;---------------------------------------------------------------
4274 tserj 1181
	xor	[ins_mode],1
1182
	mov	eax,[cur_editor.Caret.Y]
1183
	mov	ebx,eax
1184
	call	draw_editor_text.part
1185
	call	draw_editor_caret
1186
	ret
1187
endp
1188
 
5838 pathoswith 1189
;---------------------------------------------------------------
1190
proc key.bkspace ;///// DELETE PREVIOUS CHAR OR SELECTION //////
1191
;---------------------------------------------------------------
4274 tserj 1192
	call	delete_selection
1193
	jnc	key.del.exit
1194
 
1195
	mov	eax,[cur_editor.Caret.X]
1196
	dec	eax
1197
	js	.line_up
1198
 
1199
	dec	[cur_editor.Caret.X]
1200
	mov	ecx,[cur_editor.Caret.Y]
1201
	call	get_line_offset
1202
	and	[esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
1203
	or	[esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1204
 
1205
	mov	ebx,eax
1206
	call	get_real_length
1207
	cmp	eax,[cur_editor.Caret.X]
1208
	jae	@f
1209
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
1210
	mov	[cur_editor.Modified],1
1211
	ret
1212
 
1213
    @@: lea	edi,[esi+sizeof.EDITOR_LINE_DATA+ebx]
1214
	mov	ecx,ebx
1215
	neg	ecx
1216
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
1217
	add	ecx,eax
1218
	dec	ecx
1219
	lea	esi,[edi+1]
1220
	cld
1221
	rep	movsb
1222
	mov	byte[edi],' '
1223
 
1224
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
1225
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
1226
	mov	[cur_editor.Modified],1
1227
	ret
1228
 
1229
  .line_up:
1230
	cmp	[cur_editor.Caret.Y],0
1231
	jne	@f
1232
	ret
1233
    @@: mov	ecx,[cur_editor.Caret.Y]
1234
	dec	ecx
1235
	call	get_line_offset
1236
	and	[esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
1237
	or	[esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1238
 
1239
	mov	ebp,esi
1240
	lea	ebx,[esi+sizeof.EDITOR_LINE_DATA]
1241
	mov	ecx,[ebp+EDITOR_LINE_DATA.Size]
1242
    @@: cmp	byte[ebx+ecx-1],' '
1243
	jne	@f
1244
	dec	ecx
1245
	jg	@b
1246
    @@: mov	[cur_editor.Caret.X],ecx
1247
	dec	[cur_editor.Caret.Y]
1248
	cld
1249
	jmp	key.del.line_up
1250
endp
1251
 
5838 pathoswith 1252
;---------------------------------------------------------------
1253
proc key.tab ;///// TABULATE ///////////////////////////////////
1254
;---------------------------------------------------------------
4274 tserj 1255
	call	delete_selection
1256
	mov	eax,[cur_editor.Caret.X]
1257
 
1258
	mov	ecx,eax
1259
	add	eax,ATABW
1260
	and	eax,not(ATABW-1)
1261
	push	eax ' '
1262
	sub	eax,ecx
1263
  .direct:
1264
	push	eax
1265
	call	editor_realloc_lines
1266
	pop	eax
1267
	mov	ecx,[cur_editor.Caret.Y]
1268
	call	get_line_offset
1269
	and	[esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
1270
	or	[esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1271
 
1272
	xchg	eax,ecx
1273
 
1274
	call	get_real_length
1275
	cmp	eax,[cur_editor.Caret.X]
1276
	jae	@f
1277
	mov	eax,[cur_editor.Caret.X]
1278
    @@: mov	edx,[esi+EDITOR_LINE_DATA.Size]
1279
	sub	edx,eax
1280
	cmp	ecx,edx
1281
	jl	@f
1282
	push	eax
1283
	mov	eax,10
1284
	call	editor_realloc_lines
1285
	add	esi,eax
1286
	pop	eax
1287
	pushad
1288
	mov	ecx,[cur_editor.Lines]
1289
	add	ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
1290
	dec	ecx
1291
	mov	edi,ecx
1292
	add	ecx,-10+1
1293
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
1294
	lea	eax,[esi+eax+sizeof.EDITOR_LINE_DATA]
1295
	sub	ecx,eax
1296
	lea	esi,[edi-10]
1297
	std
1298
	rep	movsb
1299
	mov	ecx,10
1300
	mov	al,' '
1301
	rep	stosb
1302
	popad
1303
	add	[esi+EDITOR_LINE_DATA.Size],10
1304
	jmp	@b
1305
    @@: lea	ebx,[esi+sizeof.EDITOR_LINE_DATA]
1306
	push	ecx
1307
	mov	edi,[esi+EDITOR_LINE_DATA.Size]
1308
	lea	edi,[ebx+edi-1]
1309
	mov	esi,edi
1310
	sub	esi,ecx
1311
	lea	ecx,[esi+1]
1312
	sub	ecx,ebx
1313
	sub	ecx,[cur_editor.Caret.X]
1314
	std
1315
	rep	movsb
1316
  .ok:	pop	ecx
1317
	pop	eax
1318
	rep	stosb
1319
	cld
1320
	pop	[cur_editor.Caret.X]
1321
	lea	esi,[ebx-sizeof.EDITOR_LINE_DATA]
1322
	call	get_real_length
1323
	cmp	eax,[cur_editor.Caret.X]
1324
	jae	@f
1325
	mov	eax,[cur_editor.Caret.X]
1326
    @@: cmp	eax,[cur_editor.Columns.Count]
1327
	jbe	@f
1328
	mov	[cur_editor.Columns.Count],eax
1329
    @@: m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
1330
	m2m	[cur_editor.SelStart.Y],[cur_editor.Caret.Y]
1331
	mov	[cur_editor.Modified],1
1332
 
1333
  .exit:
1334
	ret
1335
endp
1336
 
5838 pathoswith 1337
;---------------------------------------------------------------
1338
proc key.return ;///// CARRIAGE RETURN /////////////////////////
1339
;---------------------------------------------------------------
4274 tserj 1340
	call	delete_selection
4316 mario79 1341
; unknown how many times the user wants to press "Enter",
1342
; so you should do a little more value
1343
	mov	eax,14*100
4274 tserj 1344
	call	editor_realloc_lines
1345
 
1346
	mov	ecx,[cur_editor.Caret.Y]
1347
	call	get_line_offset
1348
 
1349
	mov	ebx,[cur_editor.Caret.X]
1350
	cmp	ebx,[esi+EDITOR_LINE_DATA.Size]
1351
	jb	@f
1352
	mov	ebx,[esi+EDITOR_LINE_DATA.Size]
1353
	dec	ebx
1354
	jns	@f
1355
	xor	ebx,ebx
1356
    @@:
1357
	cld
1358
 
1359
	mov	edi,[temp_buf]
1360
	mov	ebp,esi
1361
	lea	ecx,[ebx+1]
1362
    @@: dec	ecx
1363
	jz	@f
1364
	cmp	byte[esi+ecx+sizeof.EDITOR_LINE_DATA-1],' '
1365
	je	@b
1366
    @@: lea	eax,[ecx+10]
1367
	mov	[edi+EDITOR_LINE_DATA.Size],eax
1368
	mov	[edi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1369
	add	edi,sizeof.EDITOR_LINE_DATA
1370
	jecxz	@f
1371
	push	esi
1372
	add	esi,sizeof.EDITOR_LINE_DATA
1373
	rep	movsb
1374
	pop	esi
1375
    @@: mov	al,' '
1376
	mov	ecx,10
1377
	rep	stosb
1378
 
1379
	mov	ecx,[esi+EDITOR_LINE_DATA.Size]
1380
	sub	ecx,ebx
1381
	add	esi,ebx
1382
	add	esi,sizeof.EDITOR_LINE_DATA
1383
	inc	ecx
1384
    @@: dec	ecx
1385
	jz	@f
1386
	cmp	byte[esi+ecx-1],' '
1387
	je	@b
1388
    @@: jz	.lp1
1389
    @@: cmp	byte[esi],' '
1390
	jne	.lp1
1391
	inc	esi
1392
	loop	@b
1393
  .lp1: test	[auto_indent],1
1394
	jz	.lp2
1395
	push	edi ecx
1396
	mov	ecx,[ebp+EDITOR_LINE_DATA.Size]
1397
	lea	edi,[ebp+sizeof.EDITOR_LINE_DATA]
1398
	mov	al,' '
1399
	repe	scasb
1400
	mov	eax,ecx
1401
	pop	ecx edi
1402
	je	.lp2
1403
	neg	eax
1404
	mov	edx,[ebp+EDITOR_LINE_DATA.Size]
1405
	add	eax,edx;[ebp]
1406
	dec	eax
1407
	jmp	@f
1408
  .lp2: xor	eax,eax
1409
    @@: mov	edx,edi
1410
	add	edi,sizeof.EDITOR_LINE_DATA
1411
	mov	[cur_editor.Caret.X],eax
1412
	jecxz	@f
1413
	push	ecx
1414
	mov	ecx,eax
1415
	mov	al,' '
1416
	rep	stosb
1417
	pop	ecx
1418
    @@: jecxz	@f
1419
	rep	movsb
1420
    @@: mov	ecx,10
1421
	mov	al,' '
1422
	rep	stosb
1423
 
1424
	lea	eax,[edi-sizeof.EDITOR_LINE_DATA]
1425
	sub	eax,edx
1426
	mov	[edx+EDITOR_LINE_DATA.Size],eax
1427
	mov	[edx+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
1428
 
1429
	mov	ecx,edi
1430
	sub	ecx,[temp_buf]
1431
 
1432
	push	ecx
1433
	mov	edi,[cur_editor.Lines]
1434
	add	edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
1435
	dec	edi
1436
	lea	esi,[edi+sizeof.EDITOR_LINE_DATA]
1437
	sub	esi,ecx
1438
	mov	ecx,[ebp+EDITOR_LINE_DATA.Size]
1439
	add	esi,ecx
1440
	lea	ecx,[esi-sizeof.EDITOR_LINE_DATA]
1441
	sub	ecx,ebp
1442
	std
1443
	cmp	esi,edi
1444
	jb	@f
1445
	je	.lp3
1446
	lea	esi,[ebp+sizeof.EDITOR_LINE_DATA]
1447
	mov	eax,[esp]
1448
	lea	edi,[esi+eax-sizeof.EDITOR_LINE_DATA]
1449
	mov	ecx,[ebp+EDITOR_LINE_DATA.Size]
1450
	add	esi,ecx
1451
	mov	ecx,[cur_editor.Lines]
1452
	add	ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
1453
	sub	ecx,esi
1454
	cld
1455
    @@: rep	movsb
1456
  .lp3: pop	ecx
1457
	mov	esi,[temp_buf]
1458
	mov	edi,ebp
1459
	cld
1460
	rep	movsb
1461
 
1462
	inc	[cur_editor.Caret.Y]
1463
	inc	[cur_editor.SelStart.Y]
1464
	inc	[cur_editor.Lines.Count]
1465
 
1466
	m2m	[cur_editor.SelStart.X],[cur_editor.Caret.X]
1467
 
1468
	mov	[cur_editor.Modified],1
1469
 
1470
  .exit:
1471
	ret
1472
endp
1473
 
5838 pathoswith 1474
;---------------------------------------------------------------
1475
proc key.ctrl_tab ;///// SWITCH TO NEXT TAB ////////////////////
1476
;---------------------------------------------------------------
4274 tserj 1477
	cmp	[tab_bar.Items.Count],1
1478
	je	.exit
1479
	xor	eax,eax
1480
	mov	ebp,[tab_bar.Items]
1481
    @@: cmp	ebp,[tab_bar.Current.Ptr]
1482
	je	@f
1483
	inc	eax
1484
	add	ebp,sizeof.TABITEM
1485
	jmp	@b
1486
    @@: add	ebp,sizeof.TABITEM
1487
	inc	eax
1488
	cmp	eax,[tab_bar.Items.Count]
1489
	jb	@f
1490
	mov	ebp,[tab_bar.Items]
1491
    @@: call	set_cur_tab
1492
	call	make_tab_visible
1493
	call	align_editor_in_tab
1494
	call	draw_editor
1495
	call	draw_tabctl
1496
	call	update_caption
1497
  .exit:
1498
	ret
1499
endp
1500
 
5838 pathoswith 1501
;---------------------------------------------------------------
1502
proc key.shift_ctrl_tab ;///// SWITCH TO PREVIOUS TAB //////////
1503
;---------------------------------------------------------------
4274 tserj 1504
	cmp	[tab_bar.Items.Count],1
1505
	je	.exit
1506
	xor	eax,eax
1507
	mov	ebp,[tab_bar.Items]
1508
    @@: cmp	ebp,[tab_bar.Current.Ptr]
1509
	je	@f
1510
	inc	eax
1511
	add	ebp,sizeof.TABITEM
1512
	jmp	@b
1513
    @@: add	ebp,-sizeof.TABITEM
1514
	dec	eax
1515
	jge	@f
1516
	imul	eax,[tab_bar.Items.Count],sizeof.TABITEM
1517
	add	eax,[tab_bar.Items]
1518
	lea	ebp,[eax-sizeof.TABITEM]
1519
    @@: call	set_cur_tab
1520
	call	make_tab_visible
1521
	call	align_editor_in_tab
1522
	call	draw_editor
1523
	call	draw_tabctl
1524
	call	update_caption
1525
  .exit:
1526
	ret
1527
endp
1528
 
5838 pathoswith 1529
;---------------------------------------------------------------
1530
proc key.ctrl_f4 ;///// CLOSE CURRENT TAB //////////////////////
1531
;---------------------------------------------------------------
4274 tserj 1532
	cmp	[cur_editor.Modified],0
1533
	je	.close
1534
	mov	[bot_mode2],2
1535
	jmp	key.ctrl_o.direct
1536
 .close:
1537
	mov	[do_not_draw],1
1538
	push	[tab_bar.Current.Ptr]
1539
	cmp	[tab_bar.Items.Count],1
1540
	jne	@f
1541
	;call    create_tab
1542
	jmp	key.alt_x.close 	; close program
1543
    @@: pop	ebp
1544
	call	delete_tab
1545
	dec	[do_not_draw]
1546
	call	align_editor_in_tab
1547
	call	draw_editor
1548
	call	draw_tabctl
1549
	call	draw_statusbar
1550
	ret
1551
endp
1552
 
5838 pathoswith 1553
;---------------------------------------------------------------
1554
proc key.shift_f9 ;///// SET DEFAULT TAB ///////////////////////
1555
;---------------------------------------------------------------
4274 tserj 1556
	mov	eax,[tab_bar.Current.Ptr]
1557
	cmp	eax,[tab_bar.Default.Ptr]
1558
	jne	@f
1559
	xor	eax,eax
1560
    @@: mov	[tab_bar.Default.Ptr],eax
1561
	mov	ebp,[tab_bar.Current.Ptr]
1562
	call	make_tab_visible
1563
	cmp	[tab_bar.Style],2
1564
	jbe	@f
1565
	call	align_editor_in_tab
1566
	call	draw_editor
1567
    @@: call	draw_tabctl
1568
	ret
1569
endp
1570
 
5838 pathoswith 1571
;---------------------------------------------------------------
1572
proc key.f3 ;///// FIND NEXT MATCH /////////////////////////////
1573
;---------------------------------------------------------------
5579 Pathoswith 1574
	jmp	search
4274 tserj 1575
endp
1576
 
5838 pathoswith 1577
;---------------------------------------------------------------
1578
proc key.ctrl_f9 ;///// COMPILE ////////////////////////////////
1579
;---------------------------------------------------------------
5579 Pathoswith 1580
	mov	bl,0
1581
	jmp	start_fasm
1582
endp
1583
 
5838 pathoswith 1584
;---------------------------------------------------------------
1585
proc key.f9 ;///// COMPILE AND RUN /////////////////////////////
1586
;---------------------------------------------------------------
4274 tserj 1587
	mov	bl,1
5579 Pathoswith 1588
	jmp	start_fasm
4274 tserj 1589
endp
1590
 
5838 pathoswith 1591
;---------------------------------------------------------------
1592
proc key.f10 ;///// COMPILE AND RUN UNDER DEBUG ////////////////
1593
;---------------------------------------------------------------
4274 tserj 1594
	mov	bl,2
5579 Pathoswith 1595
	jmp	start_fasm
4274 tserj 1596
endp
1597
 
5838 pathoswith 1598
;---------------------------------------------------------------
1599
proc key.alt_x ;///// EXIT PROGRAM /////////////////////////////
1600
;---------------------------------------------------------------
4274 tserj 1601
	mov	[main_closing],1
1602
	mov	eax,[tab_bar.Items]
1603
	mov	[exit_tab_item],eax
1604
	mov	eax,[tab_bar.Items.Count]
1605
	mov	[exit_tab_num],eax
1606
  .direct:
1607
	call	try_to_close_tabs
1608
	or	eax,eax
1609
	jz	@f
1610
	mov	[bot_mode2],2
1611
	jmp	key.ctrl_o.direct
1612
 
1613
    @@: stdcall save_settings
1614
 
1615
  .close:
1616
	mov	[main_closed],1
1617
	mcall	-1
1618
endp
1619
 
5838 pathoswith 1620
;---------------------------------------------------------------
1621
proc key.ctrl_plus ;///// ZOOM IN //////////////////////////////
1622
;---------------------------------------------------------------
7996 leency 1623
	cmp	[scale],0x17
5838 pathoswith 1624
	jz	@f
1625
	inc	[scale]
7996 leency 1626
	add	[lineHeight], LINEH
1627
	add	[charWidth], 8
5838 pathoswith 1628
	jmp	draw_editor
1629
endp
1630
 
1631
;---------------------------------------------------------------
1632
proc key.ctrl_minus ;///// ZOOM OUT ////////////////////////////
1633
;---------------------------------------------------------------
7996 leency 1634
	cmp	[scale],0x10
5838 pathoswith 1635
	jz	@f
1636
	dec	[scale]
7996 leency 1637
	sub	[lineHeight], LINEH
1638
	sub	[charWidth], 8
5838 pathoswith 1639
	jmp	draw_editor
1640
@@:
1641
	ret
1642
endp
1643
 
1644
;---------------------------------------------------------------
1645
proc try_to_close_tabs ;// FIND TABS TO BE SAVED BEFORE CLOSE //
1646
;---------------------------------------------------------------
4274 tserj 1647
	push	ecx ebp
1648
	call	flush_cur_tab
1649
	mov	ebp,[exit_tab_item] ; [tab_bar.Items]
1650
	add	ebp,-sizeof.TABITEM
1651
    @@: dec	[exit_tab_num]
1652
	js	.ok
1653
	add	ebp,sizeof.TABITEM
1654
	mov	al,[ebp+TABITEM.Editor.Modified]
1655
	cmp	[ebp+TABITEM.Editor.Modified],0
1656
	je	@b
1657
	mov	[exit_tab_item],ebp
1658
	call	set_cur_tab
1659
	call	make_tab_visible
1660
	xor	eax,eax
1661
	inc	eax
1662
    @@: pop	ebp ecx
1663
	ret
1664
  .ok:	xor	eax,eax
1665
	jmp	@b
1666
endp