Subversion Repositories Kolibri OS

Rev

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