Subversion Repositories Kolibri OS

Rev

Rev 178 | Rev 267 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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