Subversion Repositories Kolibri OS

Rev

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