Subversion Repositories Kolibri OS

Rev

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