Subversion Repositories Kolibri OS

Rev

Rev 5838 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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