Subversion Repositories Kolibri OS

Rev

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

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