Subversion Repositories Kolibri OS

Rev

Rev 327 | Rev 617 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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