Subversion Repositories Kolibri OS

Rev

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