Subversion Repositories Kolibri OS

Rev

Rev 4542 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1457 IgorA 1
; макрос для системной библиотеки box_lib.obj
2
; элемент TextEditor для Kolibri OS
4987 IgorA 3
; файл последний раз изменялся 27.06.2014 IgorA
1457 IgorA 4
; на код применена GPL2 лицензия
5
 
6
;input:
7
; edi = pointer to tedit struct
8
; reg = index
9
;output:
10
; reg = pointer to 'tex' struct
11
macro ConvertIndexToPointer reg {
12
  imul reg,sizeof.symbol
13
  add reg,ted_tex
14
}
15
 
16
;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
17
macro ColToIndexOffset ind_reg,out_reg {
18
	mov out_reg,ind_reg
19
	imul out_reg,sizeof.TexColViv
20
	add out_reg,ted_key_words_data
21
}
22
 
23
macro use_text_edit
24
{
25
TED_PANEL_NULL	 equ 0 ;нет открытой панели
26
TED_PANEL_FIND	 equ 1 ;панель поиска
27
TED_PANEL_SYNTAX equ 2 ;панель выбора файлов подсветки
28
TED_PANEL_WIDTH  equ 150 ;ширина панели
29
 
30
MAX_COLOR_WORD_LEN equ 40
31
;------------------------------------------------------------------------------
32
struct TexSelect
33
  x0 dd ?
34
  y0 dd ?
35
  x1 dd ?
36
  y1 dd ?
37
ends
38
 
39
struct TexColViv
2102 IgorA 40
	Text  rb MAX_COLOR_WORD_LEN ; слово для подсветки
41
	f1    dd 0 ; справка по слову
42
	flags db ? ; f1+4 флаги используемые при выделении
43
	endc  db ? ; f1+5 символ конца выделения (используется при flags&4)
44
	escc  db ? ; f1+6 экранирующий символ (используется при flags&4)
45
	color db ? ; f1+7 номер цвета
1457 IgorA 46
ends
47
 
48
struct symbol
49
  c db ?    ;  +0 символ
50
  col db ?  ;  +1 цвет
51
  perv dd ? ;  +2
52
  next dd ? ;  +6 указатели
53
  tc dd ?   ; +10 врем. создания
54
  td dd ?   ; +14 врем. удаления
55
ends
56
;------------------------------------------------------------------------------
57
 
1464 IgorA 58
ted_symbol_tab db 26 ;ascii код стрелки вправо, используется для рисования табуляции в режиме показа невидимых символов
1458 IgorA 59
 
1457 IgorA 60
if lang eq ru
61
 
62
txtRow db 'Строка',0
63
txtCol db 'Знак',0
64
txtOtm db 'Отмены',0
65
txtBuf db 'Буфер:',0
66
 
67
else
68
 
69
txtRow db 'Rows',0
70
txtCol db 'Cols',0
71
txtOtm db 'Undo',0
72
txtBuf db 'Buffer:',0
73
 
74
end if
75
 
1464 IgorA 76
;EvChar - таблица для фильтрования добавляемых символов, что-бы не попали лишние знаки
1457 IgorA 77
align 4
1458 IgorA 78
EvChar db 0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
1457 IgorA 79
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
80
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
81
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
82
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
83
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
84
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
85
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
86
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
87
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
88
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
89
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
90
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
91
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
92
    db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
93
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
94
 
95
KM_SHIFT equ 0x00010000
96
KM_CTRL equ 0x00020000
97
KM_ALT equ 0x00040000
98
KM_NUMLOCK equ 0x00080000
99
 
100
; KEY CODES
101
KEY_F1 equ 0x0000003B
102
KEY_F2 equ 0x0000003C
103
KEY_F3 equ 0x0000003D
104
 
105
 
106
 
107
align 4
108
proc ted_init, edit:dword
1458 IgorA 109
	push eax ecx edi
110
	mov edi,dword[edit]
1457 IgorA 111
 
1458 IgorA 112
	mov ecx,sizeof.symbol
113
	imul ecx,ted_max_chars
1489 IgorA 114
	invoke mem.alloc,ecx ;выделяем память
1458 IgorA 115
	mov ted_tex,eax
116
	mov ted_tex_1,eax
117
	add ted_tex_1,sizeof.symbol
118
	add eax,ecx
119
	mov ted_tex_end,eax
1457 IgorA 120
 
1458 IgorA 121
	stdcall ted_clear, edi,1
1457 IgorA 122
 
123
;-------------------------------------------------
1458 IgorA 124
	mov ecx,1024 ;1024 - для массива ted_arr_key_pos
125
	add ecx,ted_syntax_file_size
1489 IgorA 126
	invoke mem.alloc,ecx
1458 IgorA 127
	mov ted_arr_key_pos,eax
128
	add eax,1024
129
	mov ted_syntax_file,eax
1457 IgorA 130
 
1458 IgorA 131
	stdcall ted_init_scroll_bars,edi,3
132
	pop edi ecx eax
133
	ret
1457 IgorA 134
endp
135
 
1458 IgorA 136
MIN_W_SCRL_ARE equ 3 ;минимальная отображаемая область для верт. скроллинга
137
MIN_H_SCRL_ARE equ 3 ;минимальная отображаемая область для гориз. скроллинга
138
;input:
1459 IgorA 139
; opt = 1 - менять цвет скроллингов, 2 - изменились размеры окна,
140
;  4 - изменились размеры документа
1457 IgorA 141
align 4
1458 IgorA 142
proc ted_init_scroll_bars, edit:dword, opt:dword
143
	pushad
1459 IgorA 144
	mov edi,dword[edit]
1458 IgorA 145
	mov esi,ted_scr_w
146
	mov ebx,ted_scr_h
147
	bt dword[opt],0
148
	jae @f
149
		mov ecx,ted_color_wnd_work
150
		mov dword[esi+sb_offs_bckg_col],ecx
151
		mov dword[ebx+sb_offs_bckg_col],ecx
152
		mov ecx,ted_color_wnd_capt
153
		mov dword[esi+sb_offs_frnt_col],ecx
154
		mov dword[ebx+sb_offs_frnt_col],ecx
155
		mov ecx,ted_color_wnd_bord
156
		mov dword[esi+sb_offs_line_col],ecx
157
		mov dword[ebx+sb_offs_line_col],ecx
158
	@@:
1459 IgorA 159
	bt dword[opt],2 ; изменились размеры документа ?
160
	jae .doc_resize
161
		call ted_get_num_lines
162
		cmp eax,100
163
		jge @f
164
			mov eax,100
165
		@@:
166
		mov dword[esi+sb_offs_max_area],eax
167
	.doc_resize:
168
	bt dword[opt],1 ; изменились размеры окна ?
1458 IgorA 169
	jae .no_size
170
			mov edx,ted_wnd_l
171
			add edx,ted_rec_l
172
			mov word[ebx+sb_offs_start_x],dx ;выставляем левый отступ гориз. скроллинга
173
		mov eax,ted_wnd_h ;calculate lines in page
174
			mov edx,ted_wnd_t
175
			add edx,eax
176
			mov word[ebx+sb_offs_start_y],dx ;выставляем верхний отступ гориз. скроллинга
177
		sub eax,ted_rec_t
178
		xor edx,edx
179
		mov ecx,ted_rec_h
180
		div ecx
181
		cmp eax,MIN_W_SCRL_ARE
182
		jg @f
183
			mov eax,MIN_W_SCRL_ARE
184
		@@:
185
		mov dword[esi+sb_offs_cur_area],eax
186
 
187
		mov eax,ted_wnd_w ;calculate cols in page
188
			mov edx,ted_wnd_l ;левый отступ окна
189
			add edx,eax ;добавляем ширину окна
190
			mov word[esi+sb_offs_start_x],dx ;выставляем левый отступ верт. скроллинга
191
			mov edx,ted_wnd_t
192
			mov word[esi+sb_offs_start_y],dx ;выставляем верхний отступ верт. скроллинга
193
			mov edx,ted_wnd_h
194
			mov word[esi+sb_offs_size_y],dx ;выставляем высоту верт. скроллинга
195
		sub eax,ted_rec_l
196
			mov word[ebx+sb_offs_size_x],ax ;выставляем ширину гориз. скроллинга
197
		xor edx,edx
198
		mov ecx,ted_rec_w
199
		div ecx
200
		cmp eax,MIN_H_SCRL_ARE
201
		jg @f
202
			mov eax,MIN_H_SCRL_ARE
203
		@@:
204
		dec eax
205
		mov dword[ebx+sb_offs_cur_area],eax ;устанавливаем число символов, которые влазят в экран для гориз. скроллинга
206
	.no_size:
207
	popad
208
	ret
209
endp
210
 
211
align 4
1457 IgorA 212
proc ted_delete, edit:dword
1464 IgorA 213
	push edi
214
	mov edi,dword[edit]
1489 IgorA 215
	invoke mem.free,ted_tex
216
	invoke mem.free,ted_arr_key_pos ;ted_syntax_file
1464 IgorA 217
	pop edi
218
	ret
1457 IgorA 219
endp
220
 
221
 
222
;input:
223
; eax = key kodes
224
align 4
225
proc ted_key, edit:dword, table:dword, control:dword
226
	pushad
227
	mov edi,dword[edit]
1458 IgorA 228
	mov esi,ted_el_focus
229
	cmp dword[esi],edi
230
	jne .end_key_fun ;элемент не в фокусе выходим из функции
1457 IgorA 231
	mov esi,dword[control]
232
 
233
	cmp ah,KEY_F1 ;[F1]
234
	jne @f
235
		stdcall ted_show_help_f1,edi
236
		jmp .end_key_fun
237
	@@:
238
	cmp ah,KEY_F3 ;[F3]
239
	jne @f
240
		stdcall ted_but_find_next,edi
241
		jmp .end_key_fun
242
	@@:
243
 
244
	test esi,KM_CTRL ;Ctrl+...
245
	jz .key_Ctrl
246
		cmp ah,24 ;Ctrl+O
247
		jne @f
248
			cmp ted_fun_on_key_ctrl_o,0
249
			je @f
250
				call ted_fun_on_key_ctrl_o
251
		@@:
1458 IgorA 252
		cmp ah,31 ;Ctrl+S
253
		jne @f
254
			cmp ted_fun_on_key_ctrl_s,0
255
			je @f
256
				call ted_fun_on_key_ctrl_s
257
		@@:
1457 IgorA 258
		cmp ah,33 ;Ctrl+F
259
		jne @f
260
		cmp ted_panel_id,TED_PANEL_FIND
261
		je @f
262
			cmp ted_fun_on_key_ctrl_f,0
263
			je @f
264
				call ted_fun_on_key_ctrl_f
265
		@@:
266
		cmp ah,44 ;Ctrl+Z
267
		jne @f
268
			stdcall ted_but_undo,edi
269
		@@:
270
		cmp ah,46 ;Ctrl+C
271
		jne @f
272
			stdcall ted_but_copy,edi
273
		@@:
274
		cmp ah,47 ;Ctrl+V
275
		jne @f
276
			stdcall ted_but_paste,edi
277
		@@:
278
		cmp ah,49 ;Ctrl+N
279
		jne @f
280
			cmp ted_fun_on_key_ctrl_n,0
281
			je @f
282
				call ted_fun_on_key_ctrl_n
283
		@@:
284
		cmp ah,199 ;Ctrl+Home
285
		jne @f
286
			call ted_key_ctrl_home
287
		@@:
288
		jmp .end_key_fun
289
	.key_Ctrl:
290
 
1458 IgorA 291
	test esi,KM_SHIFT ;Shift+...
292
	jz .key_Shift
293
		cmp ah,72 ;Shift+Up
294
		jne @f
295
			call ted_sel_key_up
296
		@@:
297
		cmp ah,75 ;Shift+Left
298
		jne @f
299
			call ted_sel_key_left
300
		@@:
301
		cmp ah,77 ;Shift+Right
302
		jne @f
303
			call ted_sel_key_right
304
		@@:
305
		cmp ah,80 ;Shift+Down
306
		jne @f
307
			call ted_sel_key_down
308
		@@:
309
		;mov ted_drag_k,1 ;начинаем выделение от клавиатуры
310
		jmp .key_MoveCur
311
	.key_Shift:
1457 IgorA 312
;-------------------------------------------------
1458 IgorA 313
	cmp ah,72 ;178 ;Up
314
	jne @f
315
		call ted_draw_cursor_sumb
316
		call ted_cur_move_up
317
		cmp dl,8
318
		jne .no_red_0
319
			call ted_scroll_set_redraw
320
			stdcall ted_draw,edi
321
			jmp @f
322
		.no_red_0:
323
		call ted_draw_main_cursor
324
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
325
	@@:
1464 IgorA 326
	cmp ah,80 ;177 ;Down
327
	jne @f
328
		call ted_draw_cursor_sumb
329
		call ted_cur_move_down
330
		cmp dl,8
331
		jne .no_red_1
332
			call ted_scroll_set_redraw
333
			stdcall ted_draw,edi
334
			jmp @f
335
		.no_red_1:
336
		call ted_draw_main_cursor
337
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
338
	@@:
3903 IgorA 339
	cmp ah,75 ;176 ;Left
340
	jne @f
341
		call ted_draw_cursor_sumb
342
		call ted_cur_move_left
343
		cmp dl,8
344
		jne .no_red_2
345
			call ted_scroll_set_redraw
346
			stdcall ted_draw,edi
347
			jmp @f
348
		.no_red_2:
349
		call ted_draw_main_cursor
350
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
351
	@@:
352
	cmp ah,77 ;179 ;Right
353
	jne @f
354
		call ted_draw_cursor_sumb
355
		call ted_cur_move_right
356
		cmp dl,8
357
		jne .no_red_3
358
			call ted_scroll_set_redraw
359
			stdcall ted_draw,edi
360
			jmp @f
361
		.no_red_3:
362
		call ted_draw_main_cursor
363
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
364
	@@:
365
	cmp ah,71 ;180 ;Home
366
	jne @f
367
		call ted_draw_cursor_sumb
368
		call ted_cur_move_x_first_char
369
		cmp dl,8
370
		jne .no_red_4
371
			call ted_scroll_set_redraw
372
			stdcall ted_draw,edi
373
			jmp @f
374
		.no_red_4:
375
		call ted_draw_main_cursor
376
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
377
	@@:
378
	cmp ah,79 ;181 ;End
379
	jne @f
380
		call ted_draw_cursor_sumb
381
		call ted_cur_move_x_last_char
382
		cmp dl,8
383
		jne .no_red_5
384
			call ted_scroll_set_redraw
385
			stdcall ted_draw,edi
386
			jmp @f
387
		.no_red_5:
388
		call ted_draw_main_cursor
389
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
390
	@@:
391
	cmp ah,73 ;184 ;PageUp
392
	jne @f
393
		call ted_cur_move_page_up
394
		cmp dl,0
395
		je @f
396
		call ted_scroll_set_redraw
397
		stdcall ted_draw,edi
398
	@@:
399
	cmp ah,81 ;183 ;PageDown
400
	jne @f
401
		call ted_cur_move_page_down
402
		cmp dl,0
403
		je @f
404
		call ted_scroll_set_redraw
405
		stdcall ted_draw,edi
406
		mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
407
	@@:
1457 IgorA 408
;-------------------------------------------------
409
	.key_MoveCur:
410
 
3903 IgorA 411
	;ниже пропускаются служебные клавиши, которые могут давать мусорные символы в окно
412
	cmp ah,42 ;[L Shift] когда нажат без других кнопок
413
	je .end_key_fun
414
	cmp ah,54 ;[R Shift] когда нажат без других кнопок
415
	je .end_key_fun
416
	cmp ah,58 ;[Caps Lock]
417
	je .end_key_fun
1457 IgorA 418
	cmp ah,69 ;[Pause Break]
419
	je .end_key_fun
420
	cmp ah,120 ;[Fn]
421
	je .end_key_fun
422
	cmp ah,0x80 ;if key up
423
	ja .end_key_fun
424
 
425
	cmp dword[table],0
426
	je @f
427
		stdcall KeyConvertToASCII, dword[table]
428
	@@:
429
 
430
	;mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
431
 
432
	lea edx,[EvChar] ;берем адрес таблицы с допустимыми символами
433
	add dl,ah
434
	jae @f
435
		add edx,0x100 ;если было переполнение при добавлении кода символа
436
	@@:
437
	cmp byte [edx],1
438
	jne @f
439
		mov ted_key_new,ah
440
		call ted_set_undo
441
		mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
442
		stdcall ted_sel_text_del,edx
443
		cmp al,1
444
		jne .del
445
			mov edx,ted_opt_ed_move_cursor
446
		.del:
447
		cmp ted_cur_ins,1
448
		je .no_ins_mod
449
			stdcall ted_text_del,edi,ted_opt_ed_change_time
450
			mov edx,ted_opt_ed_move_cursor
451
		.no_ins_mod:
452
		mov ecx,edi
453
		add ecx,ted_offs_key_new
454
		stdcall ted_text_add,edi,ecx,1,edx ;добавляем символ введенный с клавиатуры
455
		cmp ted_key_new,13
456
		jne .dr_m_win
2758 IgorA 457
			;если вставили символ новой строки
458
			mov ecx,ted_scr_w
459
			inc dword[ecx+sb_offs_max_area] ;увеличиваем размер вертикального скроллинга
460
			mov edx,ted_cur_y
461
			cmp edx,dword[ecx+sb_offs_cur_area]
462
			jl .no_change
463
				dec ted_cur_y ;курсор оставляем на месте
464
				inc dword[ecx+sb_offs_position] ;сдвигаем ползунок
465
			.no_change:
1457 IgorA 466
			stdcall ted_draw,edi
467
			jmp .dr_cur_l
468
		.dr_m_win:
469
			stdcall ted_draw_cur_line,edi
470
		.dr_cur_l:
471
		cmp ted_fun_draw_panel_buttons,0
472
		je @f
473
			call ted_fun_draw_panel_buttons
474
	@@:
475
 
476
	cmp ah,8 ;[<-]
477
	jne @f
478
		call ted_set_undo
479
		stdcall ted_sel_text_del,ted_opt_ed_change_time
480
		cmp al,1
481
		je .del_one_b
482
			stdcall ted_text_del,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
483
		.del_one_b:
484
		stdcall ted_draw,edi
485
		cmp ted_fun_draw_panel_buttons,0
486
		je .end_key_fun
487
			call ted_fun_draw_panel_buttons
488
		jmp .end_key_fun
489
	@@:
490
 
491
	cmp ah,182 ;Delete
492
	jne @f
493
		call ted_set_undo
494
		stdcall ted_sel_text_del,ted_opt_ed_change_time
495
		cmp al,1
496
		je .del_one_d
497
			stdcall ted_text_del,edi,ted_opt_ed_change_time
498
		.del_one_d:
499
		stdcall ted_draw,edi
500
		cmp ted_fun_draw_panel_buttons,0
501
		je .end_key_fun
502
			call ted_fun_draw_panel_buttons
503
		jmp .end_key_fun
504
	@@:
505
 
506
	cmp ah,185 ;Ins
507
	jne @f
508
		call ted_draw_cursor_sumb
509
		xor ted_cur_ins,1
510
		call ted_draw_main_cursor
511
	@@:
512
 
513
	.end_key_fun:
514
	popad
515
	ret
516
endp
517
 
518
;output:
519
; al = 1 - can save
520
align 4
521
proc ted_can_save, edit:dword
522
	push ecx edi
523
	mov edi,dword[edit]
524
 
525
	mov ecx,ted_tim_ch
526
	sub ecx,ted_tim_undo
527
	mov al,1
528
	cmp ted_tim_ls,ecx
529
	jne @f
530
		dec al
531
	@@:
532
	pop edi ecx
533
	ret
534
endp
535
 
536
;input:
537
; edi = pointer to tedit struct
538
;output:
539
; al = 1 - selected
540
align 4
541
proc ted_is_select
542
  push ebx
543
  xor al,al
544
  cmp ted_drag_m,1
545
  je @f
546
    mov al,1
547
    mov ebx,ted_sel_x0
548
    cmp ebx,ted_sel_x1
549
    jne @f
550
    mov ebx,ted_sel_y0
551
    cmp ebx,ted_sel_y1
552
    jne @f
553
    xor al,al
554
  @@:
555
  pop ebx
556
  ret
557
endp
558
 
559
;input:
560
; edi = pointer to tedit struct
561
align 4
562
proc ted_sel_normalize
563
	push ecx esi
564
	push edi
565
		mov esi,edi
566
		add esi,ted_offs_sel
567
		add edi,ted_offs_seln
568
		mov ecx,sizeof.TexSelect
569
		rep movsb
570
	pop edi
571
 
572
	jmp @f
573
		.swp_f:
574
		mov ecx,ted_seln_x0
575
		m2m ted_seln_x0,ted_seln_x1
576
		mov ted_seln_x1,ecx
577
 
578
		mov ecx,ted_seln_y0
579
		cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
580
		jle .end_f
581
		m2m ted_seln_y0,ted_seln_y1
582
		mov ted_seln_y1,ecx
583
 
584
		jmp .end_f
585
	@@:
586
 
587
	mov ecx,ted_seln_y0
588
	cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
589
	jg .swp_f
590
 
591
	cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
592
	jne .end_f
593
		mov ecx,ted_seln_x0
594
		cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
595
		jg .swp_f
596
 
597
	.end_f:
598
	pop esi ecx
599
	ret
600
endp
601
 
602
;input:
603
; edi = pointer to tedit struct
604
;description:
605
; Функция вызываемая при начале выделения
606
align 4
607
proc ted_sel_start
608
	push eax ecx
609
		mov eax,ted_scr_h
610
		mov ecx,ted_cur_x
611
		add ecx,dword[eax+sb_offs_position]
612
		mov ted_sel_x0,ecx
613
		mov ted_sel_x1,ecx
614
 
615
		mov eax,ted_scr_w
616
		mov ecx,ted_cur_y
617
		add ecx,dword[eax+sb_offs_position]
618
		mov ted_sel_y0,ecx
619
		mov ted_sel_y1,ecx
620
	pop ecx eax
621
	ret
622
endp
623
 
624
;input:
625
; edi = pointer to tedit struct
626
;description:
627
; Функция вызываемая при перемещении выделения
628
align 4
629
proc ted_sel_move
630
	push eax ecx
631
		mov ecx,ted_cur_x
632
		mov eax,ted_scr_h
633
		add ecx,dword[eax+sb_offs_position]
634
		mov ted_sel_x1,ecx
635
 
636
		mov eax,ted_scr_w
637
		mov ecx,ted_cur_y
638
		add ecx,dword[eax+sb_offs_position]
639
		mov ted_sel_y1,ecx
640
	pop ecx eax
641
	cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
642
	je @f
643
		call ted_fun_draw_panel_buttons
644
	@@:
645
	ret
646
endp
647
 
648
;input:
649
; cl_al_mem = 1 - clear all memory
650
align 4
651
proc ted_clear, edit:dword, cl_al_mem:dword
1464 IgorA 652
	push ecx edi
653
	mov edi,dword[edit]
1457 IgorA 654
 
1464 IgorA 655
	mov ted_cur_x,0
656
	mov ted_cur_y,0
657
	mov ted_tim_ch,0
658
	mov ted_tim_ls,0
659
	mov ted_tim_co,0
660
	mov ted_tim_undo,0
661
	mov ted_help_id,-1
662
	mov ecx,sizeof.symbol
663
	shl ecx,1
664
	add ecx,ted_tex
665
	mov ted_ptr_free_symb,ecx
1457 IgorA 666
 
1464 IgorA 667
	mov ecx,ted_scr_w
668
	mov dword[ecx+sb_offs_position],0
669
	mov dword[ecx+sb_offs_max_area],100 ;число строк видимых в новом документе
670
	mov dword[ecx+sb_offs_redraw],1
671
	mov ecx,ted_scr_h
672
	mov dword[ecx+sb_offs_position],0
673
	mov dword[ecx+sb_offs_max_area],100 ;число символов видимых в новом документе
1457 IgorA 674
 
1464 IgorA 675
	mov ted_sel_x0,0
676
	mov ted_sel_y0,0
677
	mov ted_sel_x1,0
678
	mov ted_sel_y1,0
1457 IgorA 679
 
1464 IgorA 680
	cmp dword[cl_al_mem],0
681
	je .exit
1457 IgorA 682
 
1464 IgorA 683
	push edx
684
	mov ecx,sizeof.symbol
685
	imul ecx,ted_max_chars
686
	mov edx,ted_tex
687
	@@:
688
		mov byte [edx],0
689
		inc edx
690
	loop @b
691
	mov edx,ted_tex
692
	mov dword [edx+6],1
693
	pop edx
1457 IgorA 694
 
1464 IgorA 695
	.exit:
696
	pop edi ecx
697
	ret
1457 IgorA 698
endp
699
 
700
 
701
align 4
2707 IgorA 702
proc ted_init_syntax_file, edit:dword
1457 IgorA 703
	pushad
704
	mov edi,dword[edit]
705
 
706
	mov ecx,0x100
707
	mov edx,ted_arr_key_pos
708
	@@:
709
		mov dword[edx],-1
710
		add edx,4
711
	loop @b
712
 
713
	;init: ted_colors_text_count, ted_key_words_count, ...
714
	mov ted_colors_text_count,1
715
	mov ted_key_words_count,0
716
	mov ted_help_text_f1,0
717
	mov ted_help_id,-1 ;идентификатор слова для справки
718
 
719
	mov eax,edi ;сохраняем значение edi
720
	mov esi,ted_syntax_file
721
	add edi,ted_offs_count_colors
722
	mov ecx,9*4
723
	rep movsb
724
	mov edi,eax ;востанавливаем значение edi
725
 
726
	mov eax,ted_syntax_file
727
	add eax,32
728
	mov ted_text_colors,eax
729
 
730
	mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
731
	add eax,8
732
	shl eax,2
733
	add eax,ted_syntax_file
734
	mov ted_key_words_data,eax
735
 
736
	mov ecx,ted_key_words_count ;init: ted_arr_key_pos (first key positions)
737
	xor eax,eax
738
	@@:
739
		ColToIndexOffset eax,edx
740
		xor ebx,ebx
741
		mov bl,byte[edx]
742
		shl bx,2
743
		mov esi,ted_arr_key_pos
744
		add esi,ebx
745
		cmp dword[esi],-1
746
		jne .no_ch_key
747
			mov dword[esi],eax
748
		.no_ch_key:
749
		inc eax
750
	loop @b
751
 
752
	;init: ted_help_text_f1
2102 IgorA 753
	mov ecx,ted_key_words_count ;количество ключевых слов
754
	imul ecx,sizeof.TexColViv   ;размер структуры с 1-м кл. сл.
755
	add ecx,ted_key_words_data  ;начало файла с кл. сл.
756
	mov ted_help_text_f1,ecx    ;метка в памяти, где начинется текст со справкой
1457 IgorA 757
 
1458 IgorA 758
	stdcall ted_init_scroll_bars,edi,1 ;меняем цвета скроллингов
1457 IgorA 759
	.no_colors:
760
	popad
761
	ret
762
endp
763
 
764
;input:
765
; ebx = file size
766
; edi = pointer to tedit struct
767
;description:
768
; Функция вызывается при открытии файла
769
align 4
770
proc ted_on_open_file
771
	push eax ;destination
772
	push ecx ;for cycle
773
	push edx ;source
774
	push esi
775
 
776
	stdcall ted_clear,edi,0 ;чистим не всю память, потому что ниже будем ее заполнять новыми даными
4252 IgorA 777
 
778
	;когда символ завершения строки только 10 (без 13)
779
	mov edx,ted_tex
780
	mov ecx,ebx
781
	@@:
782
		cmp byte[edx],13
783
		je .no_10 ;если найден символ 13, то 10-е игнорируем
784
		inc edx
785
		loop @b
786
	mov edx,ted_tex
787
	mov ecx,ebx
788
	.s_10:
789
		cmp byte[edx],10
790
		jne @f
791
			mov byte[edx],13 ;меняем 10-й символ конца строки
792
		@@:
793
		inc edx
794
		loop .s_10
795
	.no_10:
796
 
797
	;переводим открытый файл внутрь элемента t_edit
1457 IgorA 798
	mov eax,ebx
799
	mov ecx,ebx
800
	add eax,2
801
	ConvertIndexToPointer eax
802
	mov edx,ted_tex
803
	add edx,ebx
804
	push ebx
805
	@@:
806
		mov ebx,[edx]
807
		mov byte [eax],bl
808
		mov dword [eax+2],ecx
809
		inc dword [eax+2]
810
		mov dword [eax+6],ecx
811
		add dword [eax+6],3
812
		;mov byte[eax+1],0 ;col=0
813
		mov dword [eax+10],-1 ;tc=-1
814
		mov dword [eax+14],0 ;td=0
815
 
816
		cmp ecx,0
817
		je @f
818
		dec ecx
819
		dec edx
820
		sub eax,sizeof.symbol
821
		jmp @b
822
	@@:
823
	pop ebx
824
	add eax,2
825
	mov dword [eax],0 ; first sumbol 'perv=0'
826
 
2348 IgorA 827
	mov edx,ted_tex ; настройки начального служебного символа
1457 IgorA 828
	; begining sumbol 'perv=0' 'next=2'
829
	mov dword [edx+2],0
830
	mov dword [edx+6],2
831
 
2348 IgorA 832
	add edx,sizeof.symbol ; настройки конечного служебного символа
1457 IgorA 833
	mov dword [edx+6],0 ; last sumbol 'next=0'
834
	mov dword [edx+2],ebx ; last sumbol 'perv=last'
835
	inc dword [edx+2]
2348 IgorA 836
	mov dword [edx+10],0 ; ставим время создания равное 0, что бы символ правильно обрабатывался при открытии файлов больших 28 байт
1457 IgorA 837
 
838
	mov edx,ebx
839
	inc edx ;2 = rezerv sumbols
840
	imul edx,sizeof.symbol
841
	add edx,ted_tex
842
	mov dword [edx+6],1 ; last sumbol 'next=1'
843
 
844
	@@: ;clear memory, need if before was open big file
845
		add edx,sizeof.symbol
846
		cmp edx,ted_tex_end
847
		jge @f
848
			mov dword[edx+10],0
849
			mov dword[edx+14],0
850
		jmp @b
851
	@@:
852
 
853
	call ted_get_num_lines
854
	cmp eax,100
855
	jge @f
856
		mov eax,100
857
	@@:
858
	mov esi,ted_scr_w
859
	mov dword[esi+sb_offs_max_area],eax
860
	pop esi edx ecx eax
861
 
862
	call ted_text_colored
863
	stdcall ted_draw,edi
864
	cmp ted_fun_draw_panel_buttons,0
865
	je @f
866
		call ted_fun_draw_panel_buttons
867
	@@:
868
	ret
869
endp
870
 
871
;input:
872
; edx = pointer to symbol struct
873
; edi = pointer to tedit struct
874
;output:
875
; edx = pointer to 'perv' visible symbol struct
876
align 4
877
ted_iterat_perv:
2809 IgorA 878
	cmp ted_tim_undo,0
879
	je .else
880
	push ebx
881
	@@:
882
		mov edx,dword[edx+2]
883
		cmp edx,0
884
		je @f
885
		imul edx,sizeof.symbol
886
		add edx,ted_tex
887
		call ted_symbol_not_vis
888
		cmp bl,1
889
		je @b
890
		cmp byte[edx],10 ;пропуск символа с кодом 10
891
		je @b
892
	pop ebx
893
	ret
894
	@@:
895
	mov edx,ted_tex ;начало файла
896
	pop ebx
897
	ret
898
	.else:
899
		mov edx,dword[edx+2]
900
		cmp edx,0
901
		je @f
902
		imul edx,sizeof.symbol
903
		add edx,ted_tex
904
		cmp dword [edx+14],0
905
		jne .else
906
		cmp byte[edx],10 ;пропуск символа с кодом 10
907
		je .else
908
	ret
909
	@@:
910
	mov edx,ted_tex ;начало файла
911
	ret
1457 IgorA 912
 
913
 
914
;input:
915
; edx = pointer to symbol struct
916
; edi = pointer to tedit struct
917
;output:
918
; edx = pointer to 'next' visible symbol struct
919
align 4
920
ted_iterat_next:
2809 IgorA 921
	cmp ted_tim_undo,0
922
	je .else
923
	push ebx
924
	@@:
925
		mov edx,dword[edx+6]
926
		cmp edx,1
927
		jle @f
928
		imul edx,sizeof.symbol
929
		add edx,ted_tex
1457 IgorA 930
 
2809 IgorA 931
		call ted_symbol_not_vis
932
		cmp bl,1
933
		je @b
934
		cmp byte[edx],10 ;пропуск символа с кодом 10
935
		je @b
936
	pop ebx
937
	ret
938
	@@:
939
	mov edx,ted_tex_1 ;конец файла
940
	pop ebx
941
	ret
942
	.else:
943
		mov edx,dword[edx+6]
944
		cmp edx,1
945
		jle @f
946
		imul edx,sizeof.symbol
947
		add edx,ted_tex
948
 
949
		cmp dword [edx+14],0
950
		jne .else
951
		cmp byte[edx],10 ;пропуск символа с кодом 10
952
		je .else
953
	ret
954
	@@:
955
	mov edx,ted_tex_1 ;конец файла
956
	ret
957
 
1457 IgorA 958
;input:
959
; bl = symbol end of select
2102 IgorA 960
; bh = экранирующий символ (= 0 если нет проверки на них)
1457 IgorA 961
; edx = pointer to symbol struct
962
; edi = pointer to tedit struct
963
;description:
964
; найти следующую позицию указанного символа
965
align 4
966
ted_iterat_next_pos_char:
2102 IgorA 967
	push ax
968
	mov al,1 ;предыдущий символ, служит для сравнения с символом bh
1457 IgorA 969
	@@:
970
		cmp bl,byte[edx]
2102 IgorA 971
		je .found
972
		.no_found:
1457 IgorA 973
		cmp edx,ted_tex_1
974
		jle @f
2102 IgorA 975
			mov al,byte[edx]
1457 IgorA 976
			call ted_iterat_next
977
			jmp @b
2102 IgorA 978
	.found:
979
		cmp bh,al
980
		je .no_found
1457 IgorA 981
	@@:
982
	call ted_iterat_next
2102 IgorA 983
	pop ax
1457 IgorA 984
	ret
985
 
986
;input:
987
; edx = pointer to symbol struct
988
; edi = pointer to tedit struct
989
align 4
990
ted_iterat_perv_color_tag:
991
  @@:
992
    cmp byte[edx+1],0
993
    jne @f
994
    call ted_iterat_perv
995
    cmp edx,ted_tex_1
996
    jle @f
997
    jmp @b
998
  @@:
999
  ret
1000
 
1001
;input:
1002
; edx = pointer to symbol struct
1003
; edi = pointer to tedit struct
1004
align 4
1005
ted_iterat_next_color_tag:
1006
  @@:
1007
    call ted_iterat_next
1008
    cmp byte[edx+1],0
1009
    jne @f
1010
    cmp edx,ted_tex_1
1011
    jle @f
1012
    jmp @b
1013
  @@:
1014
  ;call ted_iterat_next
1015
  ret
1016
 
1017
;input:
1018
; edx = pointer to symbol struct
1019
; edi = pointer to tedit struct
1020
;output:
1021
; bl = 1 if sumbol not visible
1022
; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
1023
align 4
1024
ted_symbol_not_vis:
1025
  push eax
1026
 
1027
  xor bl,bl
1028
 
1029
  cmp dword [edx+14],0
1030
  je @f
1031
  mov eax,[edx+14] ;eax=tex[i].td
1032
  add eax,ted_tim_undo
1033
  cmp eax,ted_tim_ch
1034
  jg @f
1035
    mov bl,1
1036
    pop eax
1037
    ret
1038
  @@:
1039
 
1040
  mov eax,ted_tim_ch
1041
  sub eax,ted_tim_undo
1042
  cmp [edx+10],eax
1043
  jle @f
1044
    or bl,1
1045
  @@:
1046
 
1047
  pop eax
1048
  ret
1049
 
1050
;input:
1051
; text:dword - pointer to text string
1052
; add_opt:dword - options
1053
align 4
1054
proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
1055
	locals
1056
		new_spc dd ? ;count new spaces
1057
		new_lin dd ? ;count new lines
1058
	endl
1059
;использование регистров внутри функции:
1060
;eax - позиция для вставки текста
1061
;ebx - для временных нужд, длинна вставляемого текста
1062
;ecx - для временных нужд
1063
;edx - указатель на структуру символа
1064
	pushad
1667 IgorA 1065
	cmp dword[t_len],1 ;проверяем длинну добвляемого текста
1066
	jl .no_add ;когда длинна <1 прыгаем на конец функции, во избежание глюков
1067
 
1457 IgorA 1068
	mov edi,dword[edit]
1069
	mov esi,dword[text]
1070
 
1071
	call ted_get_pos_by_cursor
1072
	call ted_get_text_perv_pos
1073
	call ted_get_text_arr_index ;eax=po_t
1074
 
1075
	mov dword[new_spc],0
1076
	cmp ted_gp_opt,2
1077
	je @f
1078
		push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
1079
			mov eax,ted_scr_h
1080
			mov eax,dword[eax+sb_offs_position]
1081
			add eax,ted_cur_x ;eax - номер символа
1082
			mov dword[new_spc],eax
1083
 
1084
			mov eax,ted_scr_w
1085
			mov eax,dword[eax+sb_offs_position]
1086
			add eax,ted_cur_y ;eax - номер строки
1087
			call ted_strlen ;ebx = line len
1088
			sub dword[new_spc],ebx ;от позиции курсора отнимаем длинну строки, узнаем колличество добавляемых пробелов
1089
		pop eax
1090
	@@:
1091
 
1092
	mov ebx,dword[t_len]
1093
 
1094
	mov dword[new_lin],0
1095
	cmp ted_gp_opt,0
1096
	jne @f
1097
		push eax
1098
			mov eax,ted_scr_w
1099
			mov eax,dword[eax+sb_offs_position]
1100
			add eax,ted_cur_y
1101
			inc eax
1102
			mov dword[new_lin],eax
1103
 
1104
			call ted_get_num_lines
1105
			sub dword[new_lin],eax
4987 IgorA 1106
			;увеличиваем линии в скроллинге на число добавленных дополнительных строк
1107
			mov ecx,ted_scr_w
1108
			add dword[ecx+sb_offs_max_area],eax ;увеличиваем размер вертикального скроллинга
1457 IgorA 1109
		pop eax
1110
	@@:
1111
 
1464 IgorA 1112
	mov edx,ted_ptr_free_symb
1113
	.beg_cycle: ;for(i=...;i
1114
		cmp dword [edx+10],0 ;if(!tex[i].tc && !tex[i].td)
1115
		jne .u1f
1116
		cmp dword [edx+14],0
1117
		jne .u1f
1118
			test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
1119
			jz .no_tim
1120
				inc ted_tim_ch
1121
			.no_tim:
1122
			test dword[add_opt],ted_opt_ed_move_cursor
1123
			jz .no_cur_mov
1124
			cmp dword[new_lin],0 ;если есть добавочные строки, то курсор еще не двигаем
1125
			jg .no_cur_mov
1126
			cmp dword[new_spc],0 ;если нет добавочных пробелов, то курсор тоже не двигаем
1127
			jg .no_cur_mov
1128
				inc ted_cur_x ;move cursor
1129
				;call ted_go_to_pos
1130
				cmp byte [esi],13
1131
				jne .no_cur_mov
1132
					mov ted_cur_x,0
1133
					inc ted_cur_y
4987 IgorA 1134
					;увеличиваем линии в скроллинге на число добавленных в тексте строк
1135
					mov ecx,ted_scr_w
1136
					inc dword[ecx+sb_offs_max_area] ;увеличиваем размер вертикального скроллинга
1464 IgorA 1137
			.no_cur_mov:
1457 IgorA 1138
 
4987 IgorA 1139
			; *** вставка текущего символа из строки ***
1464 IgorA 1140
			mov ecx,ted_opt_ed_change_time
1141
			not ecx
1142
			and dword[add_opt],ecx ;n_tim=false;
1457 IgorA 1143
 
1464 IgorA 1144
			mov cl,byte [esi] ;tex[i].c=ta[ns];
1145
			mov byte [edx],cl
1146
			m2m dword [edx+10],ted_tim_ch ;tex[i].tc=ted_tim_ch;
1147
			mov [edx+2],eax ;tex[i].perv=po_t;
1457 IgorA 1148
 
1464 IgorA 1149
			mov ecx,eax
1150
			imul ecx,sizeof.symbol
1151
			add ecx,ted_tex ; *** ecx = tex[po_t] ***
1152
			add ecx,6   ; *** ecx = tex[po_t].next ***
1153
			m2m dword [edx+6],dword [ecx] ;tex[i].next=tex[po_t].next;
1457 IgorA 1154
 
1464 IgorA 1155
			call ted_get_text_arr_index ;*** eax = i ***
1156
			mov [ecx],eax ;tex[po_t].next=i; // ссылки перенаправляем
1157
			mov ecx,[edx+6] ; *** ecx = tex[i].next ***
1158
			imul ecx,sizeof.symbol
1159
			add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
1160
			mov [ecx+2],eax ;tex[tex[i].next].perv=i;
1457 IgorA 1161
 
4987 IgorA 1162
			; *** вставка дополнительных строк и пробелов
1163
			; если курсор во время вставки находился за текстом ***
1464 IgorA 1164
			cmp dword[new_lin],0 ;add lines or text
1165
			jle .spc_add
1166
				dec dword[new_lin]
1167
				mov byte [edx],13
1168
				jmp .u1f
1169
			.spc_add:
1170
			cmp dword[new_spc],0 ;add spaces or text
1171
			jle .tex_add
1172
				dec dword[new_spc]
1173
				mov byte [edx],' '
1174
				jmp .u1f
1175
			.tex_add:
4987 IgorA 1176
			inc esi ; переход к следующему вставляемому символу
1464 IgorA 1177
			dec ebx
1178
		.u1f:
1179
		add edx,sizeof.symbol
1180
		cmp edx,ted_tex_end
1181
		jge @f ;out of memory
1182
		cmp ebx,0
1183
		jne .beg_cycle
1184
		mov ted_ptr_free_symb,edx ;меняем указатель на свободный символ, для более быстрого поиска памяти
1185
		jmp .add_all
1186
	@@:
1187
	cmp ted_increase_size,0
1188
	je .add_all
1189
		call ted_memory_increase
1190
		cmp ebx,0
1191
		jne .beg_cycle
1192
	.add_all: ;все символы добавлены
1457 IgorA 1193
 
1464 IgorA 1194
	call ted_text_colored
1667 IgorA 1195
	.no_add:
1464 IgorA 1196
	popad
1197
	ret
1457 IgorA 1198
endp
1199
 
1200
;input:
1464 IgorA 1201
;  edx = pointer to sumbol, when insert
1202
;  edi = pointer to tedit struct
1203
;output:
1204
;  edx = new pointer to sumbol, when insert
1205
align 4
1206
proc ted_memory_increase
1207
	cmp ted_increase_size,0
1208
	je @f
1209
		push eax ebx ecx
1210
		mov ecx,ted_increase_size
1211
		add ecx,ted_max_chars
1212
		mov ted_max_chars,ecx
1213
		imul ecx,sizeof.symbol
1489 IgorA 1214
		invoke mem.realloc, ted_tex,ecx
1464 IgorA 1215
		mov ebx,ted_tex
1216
		mov ted_tex,eax
1217
		mov ted_tex_1,eax
1218
		add ted_tex_1,sizeof.symbol
1219
			sub edx,ebx
1220
			add edx,eax
1221
			mov ted_ptr_free_symb,edx
1222
		add eax,ecx
1223
		mov ted_tex_end,eax
1224
		pop ecx ebx eax
1225
	@@:
1226
	ret
1227
endp
1228
 
1229
;input:
1457 IgorA 1230
;  ecx = position to free insert cell
1231
;  edx = pointer to sumbol, when insert
2324 IgorA 1232
;  esi = added symbol
1457 IgorA 1233
;  edi = pointer to tedit struct
1234
;output:
1235
;  ecx = position to inserted cell
1236
align 4
1237
ted_char_add:
1238
 
1239
  .loop_b:
1240
    cmp ecx,ted_tex_end
1241
    jge .end_f
1242
    cmp dword[ecx+10],0
1243
    jne @f
1244
      cmp dword[ecx+14],0
1245
      je .loop_e
1246
    @@:
1247
    add ecx,sizeof.symbol
1248
    jmp .loop_b
1249
  .loop_e:
1250
 
1251
  push eax ebx
1252
  mov eax,ted_tim_ch
1253
  mov dword[ecx+10],eax
2324 IgorA 1254
  mov ax,si
1457 IgorA 1255
  mov byte[ecx],al
1256
 
1257
  call ted_get_text_arr_index ; *** eax=pos ***
1258
  mov [ecx+2],eax ;tex[i].perv=pos;
1259
  m2m dword[ecx+6],dword[edx+6] ;tex[i].next=tex[pos].next;
1260
 
1261
  push edx
1262
    mov edx,ecx
1263
    call ted_get_text_arr_index ; *** eax=i ***
1264
  pop edx
1265
 
1266
  mov [edx+6],eax ;tex[pos].next=i; // ссылки перенаправляем
1267
  mov ebx,[ecx+6]
1268
  ConvertIndexToPointer ebx
1269
  mov [ebx+2],eax ;tex[tex[i].next].perv=i; // ...
1270
  pop ebx eax
1271
 
1272
  .end_f:
1273
  call ted_text_colored
1274
  ret
1275
 
4308 IgorA 1276
;description:
1277
; функция для смены кодировок
1278
;input:
1279
; table - таблица для перекодировки
1280
align 4
1281
proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword
1282
	mov edi,dword[edit]
1283
	mov esi,dword[table]
1284
	mov edx,ted_tex
1285
	.cycle:
1286
		;переходим на следующий символ
1287
		mov edx,dword[edx+6]
1288
		cmp edx,1
1289
		jle .end_text
1290
		imul edx,sizeof.symbol
1291
		add edx,ted_tex
1457 IgorA 1292
 
4308 IgorA 1293
		movzx eax,byte[edx]
1294
		add eax,esi
1295
		mov al,byte[eax]
1296
		cmp al,0
1297
		je @f
1298
			mov byte[edx],al ;меняем кодировку символа
1299
		@@:
1300
		jmp .cycle
1301
	.end_text:
1302
	;cmp esi,0
1303
	;je @f
1304
		stdcall ted_draw,edi ;обновляем окно
1305
	;@@:
1306
	ret
1307
endp
1308
 
1457 IgorA 1309
;input:
1310
; edi = pointer to tedit struct
1311
;output:
1312
; esi = count converted symbols
1313
;description:
1314
; Функция используется для смены регистра выбранных символов
1315
align 4
2324 IgorA 1316
proc ted_convert_sel_text, conv_fun:dword
1457 IgorA 1317
  locals
1318
    conv_cou dd ?
1319
  endl
1320
  mov dword[conv_cou],0
1321
  pushad
1322
 
1323
  call ted_is_select
1324
  cmp al,0
1325
  je .end_f
1326
    call ted_set_undo
1327
    call ted_sel_normalize
1328
 
1329
    mov esi,ted_seln_x0
1330
    mov ecx,ted_seln_y0
1331
    call ted_get_pos_by_coords
1332
    mov eax,edx
1333
    mov esi,ted_seln_x1
1334
    mov ecx,ted_seln_y1
1335
    call ted_get_pos_by_coords
1336
    ;call ted_get_text_perv_pos
1337
    mov ebx,edx
1338
 
1339
    cmp eax,ebx
1340
    je .end_f
1341
 
1342
    inc ted_tim_ch
1343
    mov edx,eax ;i=p0;
1464 IgorA 1344
    mov ecx,ted_ptr_free_symb
1457 IgorA 1345
    @@:
2324 IgorA 1346
      push eax
1347
      mov al,byte[edx]
1348
      call dword[conv_fun] ;преобразование символа
1349
      mov esi,eax
1350
      cmp byte[edx],al
1351
      pop eax
1457 IgorA 1352
      je .no_change
1353
	m2m dword [edx+14],ted_tim_ch
1354
	call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos);
1355
	call ted_get_text_next_pos ;go to added symbol
1356
	inc dword[conv_cou]
1357
      .no_change:
1358
 
1359
      call ted_iterat_next
1360
      cmp edx,ted_tex
1361
      je @f
1362
      cmp edx,ebx
1363
      je @f
1364
 
1365
      jmp @b
1366
    @@:
1367
    cmp dword[conv_cou],0
1368
    jne @f
1369
      dec ted_tim_ch
1370
    @@:
1371
  .end_f:
1372
  popad
1373
  mov esi,dword[conv_cou]
1374
  ret
1375
endp
1376
 
1377
;output:
1378
; bl = 0 - no delete
1379
; bl = 1 - delete
1380
align 4
1381
proc ted_text_del, edit:dword, del_opt:dword
1382
  push cx edx edi
1383
  mov edi,dword[edit]
1384
  mov ebx,dword[del_opt]
1385
 
1386
  xor cl,cl
1387
  test ebx,ted_opt_ed_move_cursor
1388
  jz @f
1389
    call ted_cur_move_left
1390
    cmp dl,0
1391
    je .no_del
1392
  @@:
1393
  call ted_get_pos_by_cursor
1394
  cmp ted_gp_opt,1
1395
  je .no_del
1396
    test ebx,ted_opt_ed_change_time
1397
    jz @f
1398
      inc ted_tim_ch
1399
    @@:
1400
    m2m dword [edx+14], ted_tim_ch
1401
    mov cl,1
1402
  .no_del:
1403
  mov bl,cl
1404
  pop edi edx cx
1405
  ret
1406
endp
1407
 
1408
;input:
1409
; edi = pointer to tedit struct
1410
;output:
1411
; al = 1 if delete
1412
;description:
1413
; Функция удаляет выделенный текст
1414
align 4
1415
proc ted_sel_text_del, del_opt:dword
1416
	push ebx ecx edx esi
1417
 
1418
	call ted_is_select
1419
	cmp al,0
1420
	je .end_f
1421
 
1422
		call ted_sel_normalize
1423
 
1424
		mov esi,ted_seln_x1
1425
		mov ecx,ted_seln_y1
1426
		call ted_get_pos_by_coords
1427
		mov ebx,edx
1428
 
1429
		mov esi,ted_seln_x0
1430
		mov ecx,ted_seln_y0
1431
		call ted_get_pos_by_coords
1432
 
1433
		test dword[del_opt],ted_opt_ed_change_time
1434
		jz @f
1435
			inc ted_tim_ch
1436
		@@:
1437
		cmp edx,ted_tex
1438
		je @f
1439
		cmp edx,ebx ;if(i==te)break;
1440
		je @f
1441
			m2m dword[edx+14],ted_tim_ch
1442
			mov esi,ted_opt_ed_change_time
1443
			not esi
1444
			and dword[del_opt],esi ;n_tim=false;
1445
			call ted_iterat_next
1446
			jmp @b
1447
		@@:
1448
		test dword[del_opt],ted_opt_ed_change_time
1449
		jz @f
1450
			dec ted_tim_ch
1451
			xor al,al
1452
		@@:
1453
		test dword[del_opt],ted_opt_ed_change_time
1454
		jnz @f
1455
			mov ecx,ted_seln_x0
1456
			mov edx,ted_seln_y0
1457
			call ted_go_to_pos
1458
			mov ted_sel_x0,0
1459
			mov ted_sel_y0,0
1460
			mov ted_sel_x1,0
1461
			mov ted_sel_y1,0
1462
		@@:
1463
	.end_f:
1464
	pop esi edx ecx ebx
1465
	ret
1466
endp
1467
 
1468
 
1469
;input:
1470
; eax = pointer to begin select
1471
; ebx = pointer to end select
1472
; edi = pointer to tedit struct
1473
align 4
1474
ted_revers:
1475
  cmp eax,ebx
1476
  jne @f
1477
    ret
1478
  @@:
1479
 
1480
  push ecx edx
1481
 
1482
  mov edx,ted_tex_1
1483
  cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
1484
  jne @f
1485
    call ted_get_text_perv_pos
1486
    mov ebx,edx
1487
  @@:
1488
 
1489
  push esi
1490
    mov edx,[eax+2] ; *** edx = tex[p0].perv ***
1491
    ConvertIndexToPointer edx
1492
    add edx,6
1493
    mov ecx,[edx] ;tmp = tex[tex[p0].perv].next;
1494
 
1495
    mov esi,[ebx+6] ; *** esi = tex[p1].next ***
1496
    ConvertIndexToPointer esi
1497
    add esi,2
1498
    m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv;
1499
 
1500
    mov [esi],ecx ;tex[tex[p1].next].perv = tmp;
1501
  pop esi
1502
 
1503
  mov ecx,[eax+2] ;tmp = tex[p0].perv;
1504
  m2m dword[eax+2],dword[ebx+6] ;tex[p0].perv = tex[p1].next;
1505
  mov [ebx+6],ecx ;tex[p1].next = tmp;
1506
 
1507
  mov edx,eax ;i=p0;
1508
  @@:
1509
    mov ecx,[edx+6] ;tmp = tex[i].next;
1510
    m2m dword[edx+6],dword[edx+2] ;tex[i].next = tex[i].perv;
1511
    mov [edx+2],ecx ;tex[i].perv = tmp;
1512
    cmp edx,ebx ;if(i==p1)break;
1513
    je @f
1514
; ---
1515
;cmp edx,ted_tex
1516
;je @f
1517
; ---
1518
    mov edx,ecx ;i = tmp;
1519
    ConvertIndexToPointer edx
1520
    jmp @b
1521
  @@:
1522
  pop edx ecx
1523
  call ted_text_colored
1524
  ret
1525
 
1526
 
1527
;input:
1528
; edi = pointer to tedit struct
1529
;output:
1530
; dl = 0 not move
1531
; dl = 2 if move up
1532
; dl = 8 if scroll move up
1533
align 4
1534
ted_cur_move_up:
1535
  cmp ted_cur_y,0
1536
  je @f
1537
    dec ted_cur_y
1538
    mov dl,2
1539
    ret
1540
  @@:
1541
  push eax
1542
  mov eax,ted_scr_w
1543
  cmp dword[eax+sb_offs_position],0
1544
  je @f
1545
    dec dword[eax+sb_offs_position]
1546
    mov dl,8
1547
    jmp .ret_f
1548
  @@:
1549
  mov dl,0
1550
  .ret_f:
1551
  pop eax
1552
  ret
1553
 
1554
;input:
1555
; edi = pointer to tedit struct
1556
;output:
1557
; dl = 0 not move
1558
; dl = 2 if move down
1559
; dl = 8 if scroll move down
1560
align 4
1561
ted_cur_move_down:
1562
  push eax ebx
1563
  mov ebx,ted_scr_w
1564
  mov dl,0
1565
  mov eax,dword[ebx+sb_offs_cur_area]
1566
  dec eax
1567
  cmp ted_cur_y,eax
1568
  jge @f
1569
    inc ted_cur_y
1570
    mov dl,2
1571
    jmp .ret_f
1572
  @@:
1573
  mov eax,ted_cur_y
1574
  add eax,dword[ebx+sb_offs_position]
1575
  inc eax
1576
  cmp dword[ebx+sb_offs_max_area],eax
1577
  jle @f
1578
    inc dword[ebx+sb_offs_position]
1579
    mov dl,8
1580
  @@:
1581
  .ret_f:
1582
  pop ebx eax
1583
  ret
1584
 
1585
 
1586
;input:
1587
; edi = pointer to tedit struct
1588
;output:
1589
; dl = 0 not move
1590
; dl = 1 if move up
1591
align 4
1592
ted_cur_move_page_up:
1593
  push eax ebx
1594
  mov ebx,ted_scr_w
1595
  mov eax,dword[ebx+sb_offs_cur_area]
1596
  xor dl,dl
1597
  cmp eax,dword[ebx+sb_offs_position]
1598
  jg @f
1599
    sub dword[ebx+sb_offs_position],eax
1600
    mov dl,1
1601
  @@:
1602
  cmp dword[ebx+sb_offs_position],0
1603
  je @f
1604
  cmp dl,1
1605
  je @f
1606
    mov dword[ebx+sb_offs_position],0
1607
    mov dl,1
1608
  @@:
1609
  pop ebx eax
1610
  ret
1611
 
1612
;input:
1613
; edi = pointer to tedit struct
1614
align 4
1615
ted_cur_move_page_down:
1616
	push eax ebx ecx
1617
	mov ecx,ted_scr_w
1618
 
1619
	xor dl,dl
1620
	mov eax,dword[ecx+sb_offs_max_area]
1621
	sub eax,dword[ecx+sb_offs_cur_area]
1622
	cmp dword[ecx+sb_offs_position],eax
1623
	jge @f
1624
		mov ebx,dword[ecx+sb_offs_cur_area]
1625
		add dword[ecx+sb_offs_position],ebx
1626
		mov dl,1
1627
		mov dword[ecx+sb_offs_redraw],1
1628
		cmp dword[ecx+sb_offs_position],eax
1629
		jle @f
1630
			mov dword[ecx+sb_offs_position],eax
1631
	@@:
1632
	pop ecx ebx eax
1633
	ret
1634
 
1635
;input:
1636
; edi = pointer to tedit struct
1637
;output:
1638
; dl = 0 not move
1639
; dl = 1 if move left
1640
; dl = 3 if move left and up
1641
; dl = 8 if scroll move up
1642
align 4
1643
ted_cur_move_left:
1644
	cmp ted_cur_x,0
1645
	je @f
1646
		dec ted_cur_x
1647
		mov dl,1
1648
		ret
1649
	@@:
1650
	push eax
1651
	mov eax,ted_scr_h
1652
	cmp dword[eax+sb_offs_position],0
1653
	je @f
1654
		dec dword[eax+sb_offs_position]
1655
		mov dl,8
1656
		jmp .ret_f
1657
	@@:
1658
	cmp ted_cur_y,0
1659
	jne @f
1660
		mov eax,ted_scr_w
1661
		mov dl,0
1662
		cmp dword[eax+sb_offs_position],0
1663
		je .ret_f
1664
			dec dword[eax+sb_offs_position]
1665
			call ted_scroll_set_redraw
1666
			call ted_cur_move_x_last_char
1667
			mov dl,8
1668
			jmp .ret_f
1669
	@@:
1670
	cmp ted_cur_y,0
1671
	je @f
1672
		dec ted_cur_y
1673
		call ted_cur_move_x_last_char
1674
		cmp dl,8
1675
		je .ret_f
1676
		mov dl,3
1677
		jmp .ret_f
1678
	@@:
1679
	mov dl,0
1680
	.ret_f:
1681
	pop eax
1682
	ret
1683
 
1684
;input:
1685
; edi = pointer to tedit struct
1686
align 4
1687
ted_cur_move_right:
1688
	push eax ebx
1689
	mov eax,ted_scr_h
1690
	xor dl,dl
1691
	mov ebx,dword[eax+sb_offs_cur_area]
1692
	cmp ted_cur_x,ebx
1693
	jge @f
1694
		inc ted_cur_x
1695
		mov dl,1
1696
		jmp .ret_f
1697
	@@:
1698
		inc dword[eax+sb_offs_position]
1699
		mov dl,8
1700
	.ret_f:
1701
	pop ebx eax
1702
	ret
1703
 
1704
;input:
1705
; edi = pointer to tedit struct
1706
align 4
1707
ted_cur_move_x_last_char:
1708
;[hScr.position]
1709
;[hScr.cur_area]
1710
;dl-???
1711
  push eax ebx ecx
1712
  mov eax,ted_cur_y
1713
  mov ecx,ted_scr_w
1714
  add eax,dword[ecx+sb_offs_position]
1715
  call ted_strlen
1716
  xor dl,dl
1717
 
1718
  mov ecx,ted_scr_h
1719
  cmp ebx,dword[ecx+sb_offs_position]
1720
  jge @f
1721
    mov dl,8
1722
    mov dword[ecx+sb_offs_position],ebx
1723
  @@:
1724
  sub ebx,dword[ecx+sb_offs_position]
1725
 
1726
  cmp ebx,dword[ecx+sb_offs_cur_area]
1727
  jle @f ; b---[---]---e
1728
    add dword[ecx+sb_offs_position],ebx
1729
    mov ebx,dword[ecx+sb_offs_cur_area]
1730
    sub dword[ecx+sb_offs_position],ebx
1731
    mov dl,8
1732
  @@:
1733
  mov ted_cur_x,ebx
1734
  pop ecx ebx eax
1735
  ret
1736
 
1737
;input:
1738
; edi = pointer to tedit struct
1739
;output:
1740
; dl = 0 not move
1741
; dl = 1 move cursor
1742
; dl = 8 move cursor and scroll
1743
align 4
1744
ted_cur_move_x_first_char:
1745
	xor dl,dl
1746
	cmp ted_cur_x,0
1747
	je @f
1748
		mov ted_cur_x,0
1749
		mov dl,1
1750
	@@:
1751
	push eax
1752
	mov eax,ted_scr_h
1753
	cmp dword[eax+sb_offs_position],0
1754
	je @f
1755
		mov dword[eax+sb_offs_position],0
1756
		mov dl,8
1757
	@@:
1758
	pop eax
1759
	ret
1760
 
1761
;input:
1762
; edx = pointer to symbol struct
1763
; edi = pointer to tedit struct
1764
;output:
1765
; eax = array index
1766
align 4
1767
ted_get_text_arr_index:
1768
	push ecx edx
1769
		mov eax,edx
1770
		sub eax,ted_tex
1771
		xor edx,edx
1772
		mov ecx,sizeof.symbol
1773
		div ecx
1774
	pop edx ecx
1775
	ret
1776
 
1777
;input:
1778
; edx = pointer to symbol struct
1779
; edi = pointer to tedit struct
1780
;output:
1781
; edx = pointer to 'perv' struct
1782
align 4
1783
ted_get_text_perv_pos:
1784
	mov edx,dword[edx+2]
1785
	imul edx,sizeof.symbol
1786
	add edx,ted_tex
1787
	ret
1788
 
1789
;input:
1790
; edx = pointer to symbol struct
1791
;output:
1792
; edx = pointer to 'next' symbol struct
1793
align 4
1794
ted_get_text_next_pos:
1795
	mov edx,dword[edx+6]
1796
	imul edx,sizeof.symbol
1797
	add edx,ted_tex
1798
	ret
1799
 
1800
;input:
1801
; edi = pointer to tedit struct
1802
;output:
1803
; edx = symbol under cursor
1804
; ted_gp_opt = 1,2
1805
; edx = tex[1].perv if error
1806
; ted_gp_opt = 0
1807
align 4
1808
ted_get_pos_by_cursor:
1809
	push eax ecx esi
1810
		mov esi,ted_cur_x
1811
		mov eax,ted_scr_h
1812
		add esi,dword[eax+sb_offs_position]
1813
		mov ecx,ted_cur_y
1814
		mov eax,ted_scr_w
1815
		add ecx,dword[eax+sb_offs_position]
1816
		call ted_get_pos_by_coords
1817
	pop esi ecx eax
1818
	ret
1819
 
1820
;input:
1821
; esi = XPos
1822
; ecx = YPos
1823
; edi = pointer to tedit struct
1824
;output:
1825
; edx = symbol under cursor
1826
; ted_gp_opt = 1 if found text line
1827
; ted_gp_opt = 2 if found text line and column
1828
; edx = tex[1] if error
1829
; ted_gp_opt = 0 if text no found
1830
align 4
1831
ted_get_pos_by_coords:
1832
  push eax ;Row
1833
  push ebx ;Col
1834
 
1835
  xor eax,eax
1836
  xor ebx,ebx
1837
  mov ted_gp_opt,0
1838
  mov edx,ted_tex
1839
  @@:
1840
    call ted_iterat_next
1841
    cmp edx,ted_tex_1
1842
    jle @f
1843
    cmp ebx,esi
1844
    jne .u1_0 ;Col <> ted_cur_x
1845
      mov ted_gp_opt,1
1846
      cmp eax,ecx
1847
      jge @f ; Row >= ted_cur_y
1848
    .u1_0:
1849
    mov ted_gp_opt,0
1850
    inc ebx
1851
    cmp byte [edx],13
1852
    jne @b
1853
    cmp eax,ecx
1854
    jge @f ; Row >= ted_cur_y
1855
    inc eax
1856
    xor ebx,ebx
1857
    jmp @b
1858
  @@:
1859
  cmp eax,ecx
1860
  jne @f ; Row = ted_cur_y
1861
    inc ted_gp_opt
1862
  @@:
1863
  cmp ted_gp_opt,0
1864
  jne @f
1865
    mov edx,ted_tex_1
1866
    ;call ted_get_text_perv_pos
1867
  @@:
1868
  pop ebx eax
1869
  ret
1870
 
1871
 
1872
;input:
1873
; eax = Row
1874
; edi = pointer to tedit struct
1875
;output:
1876
; ebx = str len
1877
align 4
1878
ted_strlen:
1879
  push edx ecx
1880
  ;ecx = Row, from cycle
1881
 
1882
  xor ebx,ebx
1883
  xor ecx,ecx
1884
  mov edx,ted_tex
1885
  @@:
1886
    call ted_iterat_next
1887
    cmp edx,ted_tex_1
1888
    jle @f
1889
    inc ebx
1890
    cmp byte [edx],13
1891
    jne @b
1892
    dec ebx ;lenght minus 1 sumbol to paragraph
1893
    cmp eax,ecx
1894
    je @f
1895
    xor ebx,ebx
1896
    inc ecx
1897
    jmp @b
1898
  @@:
1899
 
1900
  cmp eax,ecx
1901
  je @f
1902
    xor ebx,ebx
1903
  @@:
1904
 
1905
  pop ecx edx
1906
  ret
1907
 
1908
 
1909
;input:
1910
; edx = symbol position
1911
; edi = pointer to tedit struct
1912
;output:
1913
; eax = number of line
1914
; ebx = symbol position in line
1915
align 4
1916
ted_get_text_coords:
1917
  push edx
1918
  xor eax,eax
1919
  xor ebx,ebx
1920
  @@:
1921
    call ted_iterat_perv
1922
 
1923
    cmp eax,0
1924
    jne .no_col_mov
1925
    inc ebx
1926
    .no_col_mov:
1927
 
1928
    cmp edx,ted_tex_1
1929
    jle @f
1930
    cmp byte [edx],13
1931
    jne @b
1932
    inc eax
1933
    jmp @b
1934
  @@:
1935
  dec ebx
1936
  pop edx
1937
  ret
1938
 
1939
;input:
1940
; edi = pointer to tedit struct
1941
;output:
1942
; eax = num lines
1943
align 4
1944
ted_get_num_lines:
1945
  push edx
1946
  mov eax,1
1947
  mov edx,ted_tex
1948
  @@:
1949
    call ted_iterat_next
1950
    cmp edx,ted_tex_1
1951
    jle @f
1952
    cmp byte [edx],13
1953
    jne @b
1954
    inc eax
1955
    jmp @b
1956
  @@:
1957
;...
1958
;dec eax
1959
  pop edx
1960
  ret
1961
 
1962
 
1963
;input:
1964
; edi = pointer to tedit struct
1965
;description:
1966
; отменяет отмененные действия, перед изменением документа
1967
align 4
1968
proc ted_set_undo
2348 IgorA 1969
	mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры
1970
	cmp ted_tim_undo,1
1971
	jl .no_work
1457 IgorA 1972
 
2348 IgorA 1973
	push eax ebx edx
1974
	mov edx,ted_tex
1975
	call ted_get_text_next_pos ;long i=tex[0].next;
1976
	mov eax,ted_tim_undo
1977
	sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
1978
	mov eax,ted_tim_ch
1979
	cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
1980
	jle @f
1981
		mov ted_tim_ls,0
1982
	@@:
1983
		cmp edx,ted_tex_1
1984
		jle @f
1457 IgorA 1985
 
2348 IgorA 1986
		;if(tex[i].tc>ted_tim_ch){ // если создание символа было отменено
1987
		cmp [edx+10],eax
1988
		jle .no_u1
1989
			mov dword [edx+10],0
1990
			mov dword [edx+14],0
1457 IgorA 1991
 
2348 IgorA 1992
			mov ebx,[edx+2]
1993
			imul ebx,sizeof.symbol
1994
			add ebx,ted_tex ;ebx=tex[i].perv
1995
			m2m dword [ebx+6],dword [edx+6] ;tex[tex[i].perv].next=tex[i].next;
1457 IgorA 1996
 
2348 IgorA 1997
			mov ebx,[edx+6]
1998
			imul ebx,sizeof.symbol
1999
			add ebx,ted_tex ;ebx=tex[i].next
2000
			m2m dword [ebx+2],dword [edx+2] ;tex[tex[i].next].perv=tex[i].perv;
1457 IgorA 2001
 
2348 IgorA 2002
			cmp ted_ptr_free_symb,edx
2003
			jle .no_cor_free
2004
				mov ted_ptr_free_symb,edx ;меняем указатель на свободный символ, для более быстрого поиска памяти
2005
			.no_cor_free:
2006
			mov edx,ebx ;оптимизируем по скорости (edx после вызова ted_get_text_next_pos будет равен ebx)
2007
			jmp @b
2008
		.no_u1:
1457 IgorA 2009
 
2348 IgorA 2010
		;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // если удаление символа было отменено
2011
		cmp [edx+14],eax
2012
		jle .no_u2
2013
			mov dword [edx+14],0
2014
		.no_u2:
1457 IgorA 2015
 
2348 IgorA 2016
		call ted_get_text_next_pos
2017
		jmp @b
2018
	@@:
2019
	mov ted_tim_undo,0
2020
	mov eax,ted_tim_co
2021
	cmp ted_tim_ch,eax
2022
	jge @f
2023
		mov ted_tim_co,0
2024
	@@:
2025
	pop edx ebx eax
2026
	.no_work:
2027
	ret
1457 IgorA 2028
endp
2029
 
2030
;input:
2031
; ecx = Col
2032
; edx = Row
2033
; edi = pointer to tedit struct
2034
align 4
2035
ted_go_to_pos:
2036
	push eax
2037
	mov eax,ted_scr_w
2038
	mov ted_cur_x,ecx
2039
	sub edx,dword[eax+sb_offs_position]
2040
 
2041
	cmp edx,dword[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
2042
	jl @f
2043
		push ebx
2044
		mov ebx,edx
2045
		sub ebx,dword[eax+sb_offs_cur_area]
2046
		inc ebx
2047
		add dword[eax+sb_offs_position],ebx
2048
		sub edx,ebx
2049
		pop ebx
2050
		; ??? redrav
2051
	@@:
2052
	mov ted_cur_y,edx
2053
	pop eax
2054
	ret
2055
 
2056
;input:
2057
; edi = pointer to tedit struct
2058
align 4
2059
ted_text_colored:
2060
  push eax edx
2061
  mov eax,ted_tim_ch
2062
  sub eax,ted_tim_undo
2063
  mov ted_tim_co,eax
2064
  mov edx,ted_tex
2065
  @@:
2066
    call ted_iterat_next
2067
    cmp edx,ted_tex_1
2068
    jle @f
2069
    mov byte[edx+1],0
2070
    jmp @b
2071
  @@:
2072
 
2073
  cmp ted_key_words_count,1
2074
  jl .no_colors
2075
  mov edx,ted_tex
2076
  @@:
2077
    call ted_text_find_sel_color
2078
    cmp edx,ted_tex_1
2079
    jle .no_colors
2080
    jmp @b
2081
  .no_colors:
2082
  pop edx eax
2083
  ret
2084
 
2085
 
2086
;input:
2087
; edx = pointer to start symbol
2088
; edi = pointer to tedit struct
2089
;output:
2090
; edx = pointer to next symbol
2091
;description:
2092
; Функция для поиска и выделения подсвеченых слов
2093
align 4
2094
proc ted_text_find_sel_color
2095
locals
2096
  begPos dd ? ;начальная позиция
2097
  endPos dd ? ;конечная позиция
2098
  find db ? ;найдено / не найдено
2099
  f_color db ? ;индекс цвета найденого слова
2100
endl
2101
  push eax ebx ecx esi
2102
;eax = word_n текущий номер (позиция) проверяемого слова в списке
2103
;ebx = для разных целей
2104
;ecx = l_pos последний номер (позиция) подходящего слова в списке
2105
;esi = для разных целей, номер проверяемого символа в слове
2106
  mov dword[begPos],1
2107
  mov dword[endPos],1
2108
  mov byte[find],0
2109
  mov byte[f_color],1
2110
  @@:
2111
    call ted_iterat_next
2112
    cmp edx,ted_tex_1
2113
    jle @f
2114
 
2115
    xor eax,eax
2116
    mov al,byte[edx]
2117
    shl ax,2 ;eax*=4
2118
    add eax,ted_arr_key_pos
2119
    mov eax,dword[eax]
2120
    cmp eax,0
2121
    jl @b ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
2122
 
2123
    mov ecx,eax
2124
    ;while(l_pos
2125
    .wh_1b:
2126
      cmp ecx,ted_key_words_count
2127
      jge .wh_1e
2128
      ColToIndexOffset ecx,esi
2129
      mov bl,byte[esi]
2130
      ColToIndexOffset eax,esi
2131
      cmp bl,byte[esi]
2132
      jne .wh_1e
2133
	inc ecx
2134
      jmp .wh_1b
2135
    .wh_1e:
2136
 
2137
    mov dword[begPos],edx ;bP=i;
2138
    mov esi,1
2139
 
2140
    .wh_2b: ;while(1){
2141
      call ted_iterat_next
2142
 
2143
      ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
2144
      .wh_3b:
2145
	cmp ecx,eax
2146
	jle .wh_3e
2147
	dec ecx
2148
	ColToIndexOffset ecx,ebx
2149
	inc ecx
2150
	;cmp byte[ebx+esi],byte[edx]
2151
	mov bl,byte[ebx+esi]
2152
	cmp bl,byte[edx]
2153
	je .wh_3e
2154
	  dec ecx
2155
	jmp .wh_3b
2156
      .wh_3e:
2157
 
2158
      ColToIndexOffset eax,ebx
2159
      cmp byte[ebx+esi],0
2160
      jne .if_0 ;if(Col[word_n].Text[pos]==0){
2161
	mov dword[endPos],edx ;eP=i;
2162
	ColToIndexOffset eax,ebx
2102 IgorA 2163
	mov bl,byte[ebx+MAX_COLOR_WORD_LEN+7]
1457 IgorA 2164
	mov byte[f_color],bl ;f_color=Col[word_n].color;
2165
 
2166
mov byte[find],1
2167
	  ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
2168
	  mov bl,byte[ebx+MAX_COLOR_WORD_LEN+4]
2169
	  cmp bl,0 ;if(Col[word_n].wwo)
2170
	  je .if_2n
2171
	    push edx
2172
	    mov edx,dword[begPos]
2173
     call ted_iterat_perv
2174
 
2175
	    btr bx,0 ;1-1
2176
	    jae .if_3e ;if(Col[word_n].wwo&1)
2177
	      ;u1= !(isalnum(cont_s)||cont_s=='_')
2178
	      call isalnum
2179
	      jae .if_3e
2180
		mov byte[find],0
2181
	    .if_3e:
2182
 
2183
	    btr bx,3 ;4-1
2184
	    jae .if_4e ;if(Col[word_n].wwo&8)
2185
	      ;u1= !isalpha(cont_s);
2186
	      call isalpha
2187
	      jae .if_4e
2188
		mov byte[find],0
2189
	    .if_4e:
2190
 
2191
	    mov edx,dword[endPos]
2192
;     call ted_iterat_next
2193
 
2194
	    btr bx,1 ;2-1
2195
	    jae .if_5e ;if(Col[word_n].wwo&2)
2196
	      ;u1= !(isalnum(cont_s)||cont_s=='_')
2197
	      call isalnum
2198
	      jae .if_5e
2199
		mov byte[find],0
2200
	    .if_5e:
2201
 
2202
	    btr bx,4 ;5-1
2203
	    jae .if_6e ;if(Col[word_n].wwo&16)
2204
	      ;u1= !isalpha(cont_s);
2205
	      call isalpha
2206
	      jae .if_6e
2207
		mov byte[find],0
2208
	    .if_6e:
2209
 
2210
	    btr bx,2 ;3-1
2211
	    jae .if_7e ;if(Col[word_n].wwo&4)
2212
	    ColToIndexOffset eax,ebx
2102 IgorA 2213
	    mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
1457 IgorA 2214
	    call ted_iterat_next_pos_char
2215
       cmp edx,ted_tex_1
2216
       jle .if_7e
2217
       mov dword[endPos],edx
2218
	    .if_7e:
2219
 
2220
	    pop edx
2221
	  .if_2n:
2222
;                 if(i!=1){ // не конец документа
2223
;                   cont_s=tex[eP].c;
2224
;                   if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // не букв.-числ. символ
2225
;                   if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // не числ. символ
2226
;                   if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
2227
 
2228
	cmp eax,ecx
2229
	je .wh_2e ;if(word_n==l_pos) break; // do double - если слово точно последнее
2230
      .if_0:
2231
 
2232
      cmp edx,ted_tex_1
2233
      jle .wh_2e ;if(i==1) break;
2234
 
2235
      ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
2236
      .wh_4b:
2237
	cmp ecx,eax
2238
	jle .wh_4e
2239
	ColToIndexOffset eax,ebx
2240
	;cmp byte[ebx+esi],byte[edx]
2241
	mov bl,byte[ebx+esi]
2242
	cmp bl,byte[edx]
2243
	je .wh_4e
2244
	  inc eax
2245
	jmp .wh_4b
2246
      .wh_4e:
2247
 
2248
      cmp eax,ecx
2249
      je .wh_2e;if(word_n==l_pos) break;
2250
      inc esi ;pos++;
2251
      jmp .wh_2b
2252
    .wh_2e:
2253
 
2254
    cmp byte[find],1 ;if(fnd)break;
2255
    je @f
2256
    mov edx,dword[begPos];i=bP;
2257
    jmp @b
2258
  @@:
2259
 
2260
  cmp byte[find],1
2261
  jne .if_1e ;if(fnd){ // выделение найденого текста
2262
;    if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
2263
    mov eax,dword[begPos]
2264
    mov bl,byte[f_color]
2265
    mov byte[eax+1],bl ;tex[bP].col=f_color;
2266
    mov eax,dword[endPos]
2267
    mov byte[eax+1],0xff ;tex[eP].col=255;
2268
;    return ItPoPerv(eP); // возвращаем позицию конца вхождения
2269
    mov edx,dword[endPos]
2270
    call ted_get_text_perv_pos
2271
    jmp @f
2272
  .if_1e:
2273
    mov edx,ted_tex
2274
  @@:
2275
 
2276
  pop esi ecx ebx eax
2277
  ret
2278
endp
2279
 
2280
;input:
2281
; edx = pointer to char (byte)
2282
;output:
2283
; cf=1 if symbol is...
2284
align 4
2285
tab_all_num db 0,0,0,0,0,0,11111111b,11b,11111110b,0xff,0xff,111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0;,0,0,0,0,0,0,0,0 - tab_alpha_0,0,0,0,0,0,0,0
2286
tab_alpha db 0,0,0,0,0,0,0,0,11111110b,0xff,0xff,111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2287
 
2288
align 4
2289
isalnum:
2290
  push eax ebx
2291
  mov al,byte[edx] ;al=offset
2292
  shr al,3
2293
  and eax,11111b
2294
  lea ebx,[tab_all_num]
2295
  add ebx,eax
2296
  mov ah,byte[ebx]
2297
  mov al,byte[edx] ;al=bit
2298
  and ax,111b
2299
  mov bx,word[ebx]
2300
  btr bx,ax
2301
  pop ebx eax
2302
  ret
2303
align 4
2304
isalpha:
2305
  push eax ebx
2306
  mov al,byte[edx] ;al=offset
2307
  shr al,3
2308
  and eax,11111b
2309
  lea ebx,[tab_alpha]
2310
  add ebx,eax
2311
  mov ah,byte[ebx]
2312
  mov al,byte[edx] ;al=bit
2313
  and ax,111b
2314
  mov bx,word[ebx]
2315
  btr bx,ax
2316
  pop ebx eax
2317
  ret
2318
 
2319
align 4
2320
proc ted_show_help_f1, edit:dword
2321
  push eax edx edi
2322
  mov edi,dword[edit]
2323
 
2324
  call ted_get_pos_by_cursor
2325
  push edx
2326
    call ted_iterat_next_color_tag
2327
    mov eax,edx
2328
  pop edx
2329
  call ted_iterat_perv_color_tag
2330
 
2331
  cmp eax,ted_tex
2332
  jle @f
2333
  cmp edx,ted_tex_1
2334
  jle @f
2335
    stdcall ted_find_help_id,eax
2336
  @@:
2337
  ;call ted_draw_main_cursor
2338
  call ted_draw_help_f1
2339
  pop edi edx eax
2340
  ret
2341
endp
2342
 
2343
;input:
2344
; edx = position begin 'symbol' struct
2345
; edi = pointer to tedit struct
2346
; end_pos = position end 'symbol' struct
2347
align 4
2348
proc ted_find_help_id, end_pos:dword
2349
; ecx = word_n
2350
; ebx = l_pos
2351
  mov ted_help_id,-1
2352
 
2353
  push ebx ecx
2354
    xor ebx,ebx
2355
    mov bl,byte[edx]
2356
    shl bx,2 ;ebx*=4
2357
    add ebx,ted_arr_key_pos
2358
    mov ecx,dword[ebx]
2359
    cmp ecx,0
2360
    jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
2361
      push esi eax
2362
      mov ebx,ecx ;l_pos=word_n;
2363
      ColToIndexOffset ecx,esi
2364
      push cx
2365
      mov cl,byte[esi]
2366
      @@:
2367
	cmp ebx,ted_key_words_count ;while(l_pos
2368
	jge @f
2369
	;ColToIndexOffset ecx,esi
2370
	ColToIndexOffset ebx,eax
2371
	cmp cl,byte[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
2372
	jne @f
2373
	  inc ebx ;l_pos++;
2374
	  jmp @b
2375
      @@:
2376
      pop cx
2377
      call ted_iterat_next ;pos=1;
2378
      mov esi,1
2379
      @@:
2380
	push dx
2381
	push word[edx]
2382
	pop dx
2383
	  .wh_0b:
2384
	    cmp ebx,ecx ;while(l_pos>word_n
2385
	    jle .wh_0e
2386
	    dec ebx
2387
	    ColToIndexOffset ebx,eax
2388
	    inc ebx
2389
	    cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
2390
	    je .wh_0e
2391
	      dec ebx ;l_pos--;
2392
	    jmp .wh_0b
2393
	  .wh_0e:
2394
 
2395
	  .wh_1b:
2396
	    cmp ebx,ecx ;while(l_pos>word_n
2397
	    jle .wh_1e
2398
	    ColToIndexOffset ecx,eax
2399
	    cmp byte[eax+esi],dl
2400
	    je .wh_1e
2401
	      inc ecx ;word_n++;
2402
	    jmp .wh_1b
2403
	  .wh_1e:
2404
	pop dx
2405
 
2406
	cmp ecx,ebx ;if(word_n==l_pos) break;
2407
	je @f
2408
	call ted_iterat_next ;pos++;
2409
	cmp edx,dword[end_pos] ;for(...;i
2410
	je @f ;jge
2411
	inc esi
2412
	jmp @b
2413
      @@:
2414
      pop eax esi
2415
 
2416
      mov ted_help_id,ecx
2417
      ;return word_n;
2418
 
2419
    .if_0e:
2420
  pop ecx ebx
2421
  ret
2422
endp
2423
 
2424
;output:
2425
; eax = код ошибки
2426
; ebx = колличество прочитанных байт
2427
align 4
2428
proc ted_open_file, edit:dword, file:dword, f_name:dword ;функция открытия файла
2808 IgorA 2429
	push ecx edx edi
1457 IgorA 2430
	mov edi,dword[edit]
2431
 
2808 IgorA 2432
	; *** проверяем размер памяти и если не хватает то увеличиваем ***
2433
	;пробуем получить информацию о файле
1457 IgorA 2434
	mov eax,70
2435
	mov ebx,dword[file]
2808 IgorA 2436
	mov dword[ebx], 5
2437
	mov dword[ebx+4], 0
2438
	mov dword[ebx+8], 0
2439
	mov dword[ebx+12], 0
2440
	m2m dword[ebx+16], ted_tex
2441
	mov  byte[ebx+20], 0
2442
	push dword[f_name]
2443
	pop dword[ebx+21]
2444
	int 0x40
2445
	cmp eax,0
2446
	je .end_0
2447
		mov edx,ted_max_chars
2448
		cmp eax,2 ;функция не поддерживается для данной файловой системы
2449
		je @f
2450
		jmp .ret_f
2451
	.end_0:
2452
	;проверяем хватит ли памяти для загрузки файла
2453
	mov ecx,ted_max_chars
2454
	sub ecx,2 ;ecx = максимальное число байт, для которых была выделена память
2455
	mov edx,ted_tex
2456
	mov edx,dword[edx+32] ;+32 = +0x20: qword: размер файла в байтах
2457
	cmp edx,ecx
2458
	jl @f
2459
		;увеличиваем память если не хватило
2460
		mov ecx,edx ;память необходимая для открытия файла
2461
		add ecx,2  ;память для служебных начального и конечного символов
2462
		add ecx,ted_increase_size ;память для редактирования файла
2463
		mov ted_max_chars,ecx
2464
		imul ecx,sizeof.symbol
2465
		invoke mem.realloc, ted_tex,ecx
2466
		mov ted_tex,eax
2467
		mov ted_tex_1,eax
2468
		add ted_tex_1,sizeof.symbol
2469
		add eax,ecx
2470
		mov ted_tex_end,eax
2471
		mov ecx,ted_tex_1
2472
		add ecx,sizeof.symbol
2473
		mov ted_ptr_free_symb,ecx
2474
	@@:
2475
 
2476
	; *** пробуем открыть файл ***
2477
	mov eax,70
2478
	mov ebx,dword[file]
1457 IgorA 2479
	mov dword[ebx], 0
2480
	mov dword[ebx+4], 0
2481
	mov dword[ebx+8], 0
2808 IgorA 2482
	m2m dword[ebx+12], edx ;число байт, которые могут быть считаны с файла (не больше чем ted_max_chars)
1457 IgorA 2483
	m2m dword[ebx+16], ted_tex
2484
	mov  byte[ebx+20], 0
2485
	push dword[f_name]
2486
	pop dword[ebx+21]
2487
	int 0x40
2488
 
2489
	cmp eax,0
2490
	je @f
2491
	cmp eax,6
2492
	je @f
2493
		jmp .ret_f
2494
	@@:
2495
	cmp ebx,-1
2496
	je .ret_f
2497
		;if open file
2498
		call ted_on_open_file
2499
	.ret_f:
2808 IgorA 2500
	pop edi edx ecx
1457 IgorA 2501
	ret
2502
endp
2503
 
2504
align 4
2505
proc ted_but_select_word, edit:dword
2506
	pushad
2507
	mov edi,dword[edit]
2508
 
2509
	call ted_get_pos_by_cursor
2510
	push edx
2511
		call ted_iterat_perv_color_tag
2512
		cmp edx,ted_tex_1
2513
		jle @f
2514
			call ted_get_text_coords
2515
			mov ted_sel_x0,ebx
2516
			mov ted_sel_y0,eax
2517
		@@:
2518
	pop edx
2519
	call ted_iterat_next_color_tag
2520
	cmp edx,ted_tex_1
2521
	jle @f
2522
		call ted_get_text_coords
2523
		mov ted_sel_x1,ebx
2524
		mov ted_sel_y1,eax
2525
	@@:
2526
 
2527
	cmp ted_fun_draw_panel_buttons,0
2528
	je @f
2529
		call ted_fun_draw_panel_buttons
2530
	@@:
2531
	stdcall ted_draw,edi
2532
	popad
2533
	ret
2534
endp
2535
 
2536
align 4
2537
proc ted_but_cut, edit:dword
2538
	push edi
2539
	mov edi,dword[edit]
2540
 
2541
	stdcall ted_but_copy,edi
2542
	call ted_set_undo
2543
	stdcall ted_sel_text_del,ted_opt_ed_change_time
2544
 
2545
	cmp al,1
2546
	jne @f
2547
		stdcall ted_draw,edi
2548
		cmp ted_fun_draw_panel_buttons,0
2549
		je @f
2550
			call ted_fun_draw_panel_buttons
2551
	@@:
2552
	pop edi
2553
	ret
2554
endp
2555
 
2556
;output:
2557
; al = 1 if copy text
2558
align 4
2559
proc ted_but_copy, edit:dword
2560
	pushad
2561
	mov edi,dword[edit]
2562
 
2563
	call ted_is_select
2564
	cmp al,0
2565
	je .end_f ;if not selected text
2566
	call ted_sel_normalize
2567
 
2568
	mov esi,ted_seln_x1
2569
	mov ecx,ted_seln_y1
2570
	call ted_get_pos_by_coords
2571
	mov ebx,edx
2572
	mov esi,ted_seln_x0
2573
	mov ecx,ted_seln_y0
2574
	call ted_get_pos_by_coords
2575
	mov esi,ebx
2576
 
4228 IgorA 2577
	mov ecx,12 ;system buffer header size
1457 IgorA 2578
	mov ebx,ted_buffer
4228 IgorA 2579
	mov dword[ebx+4],0 ;text data
2580
	mov dword[ebx+8],1 ;code 866
2581
	add ebx,ecx
1457 IgorA 2582
	@@:
2583
		cmp edx,ted_tex_1 ;end of file
2584
		jle @f
2585
		cmp edx,esi ;end of select
2586
		je @f
2587
		inc ecx
2588
		cmp ecx,ted_buffer_size ;owerflow bufer
2589
		je @f
2590
 
2591
		mov al,byte[edx]
2592
		mov byte[ebx],al
2593
		inc ebx
2594
 
2595
		call ted_iterat_next
2596
		jmp @b
2597
	@@:
2598
	mov byte[ebx],0
2599
 
4542 IgorA 2600
	cmp ecx,12
1457 IgorA 2601
	je .end_f
4542 IgorA 2602
		inc ecx ;размер данных в буфере + символ завершения строки
4228 IgorA 2603
		mov ebx,ted_buffer
4542 IgorA 2604
		mov dword[ebx],ecx
2605
		mcall 54,2,ecx,ted_buffer
1457 IgorA 2606
		call ted_draw_buffer
2607
		cmp ted_fun_draw_panel_buttons,0
2608
		je .end_f
2609
			call ted_fun_draw_panel_buttons
2610
	.end_f:
2611
	popad
2612
	ret
2613
endp
2614
 
2615
 
2616
align 4
2617
proc ted_but_paste, edit:dword
4228 IgorA 2618
	pushad
1457 IgorA 2619
	mov edi,dword[edit]
2620
 
4228 IgorA 2621
	mcall 54,0
2622
	cmp eax,1
2623
	jl .no_buf_r
2624
 
2625
	mov esi,eax
2626
	.cycle: ;обратный цикл по слотам
2627
	dec esi ;номер текущего, проверяемого слота
2628
	mcall 54,1,esi ;read system buffer
2629
	cmp eax,1
2630
	je .no_buf_r
2631
	cmp eax,-1
2632
	je .no_buf_r
2633
		mov ecx,dword[eax]
2634
		cmp ecx,1 ;size
2635
		jl .no_buf_r
2636
		cmp dword[eax+4],0 ;text
2637
		je @f
2638
			cmp esi,1
2639
			jge .cycle ;если в буфере не текст, а слотов в буфере несколько, пробуем перейти к верхнему слоту
2640
			jmp .no_buf_r
2641
		@@:
2642
		cmp dword[eax+8],1 ;866
2643
		je @f
2644
			cmp esi,1
2645
			jge .cycle ;если в буфере текст не в кодировке 866 ... пробуем перейти к верхнему слоту
2646
			jmp .no_buf_r
2647
		@@:
2648
		;копирование текста из системного буфера во внутренний
2649
		cmp ecx,ted_buffer_size
2650
		jle @f
2651
			mov ecx,ted_buffer_size
2652
		@@:
2653
		mov edi,ted_buffer
2654
		mov esi,eax
2655
		add	esi,4 ;12
2656
		mov dword[edi],ecx
2657
		add edi,4 ;12
2658
		sub ecx,4 ;12
2659
		rep movsb
2660
		mov edi,dword[edit]
2661
 
2662
		mov esi,eax
2663
		add	esi,12
2664
		jmp .buf_r
2665
	.no_buf_r:
2666
 
2667
	;если не удалось прочитать данные из системного буфера, попадаем сюда
1457 IgorA 2668
	mov esi,ted_buffer
4228 IgorA 2669
	cmp dword[esi],1 ;проверяем есть ли данные во внутреннем буфере
2670
	jl .no_paste ;если вообще ничего не удалось прочитать идем на выход
2671
	add esi,12 ;system buffer header size
2672
	.buf_r:
2673
 
2674
	mov edx,esi
1457 IgorA 2675
	call tl_strlen
2676
	cmp eax,1
4228 IgorA 2677
	jl .no_paste
1457 IgorA 2678
		mov esi,eax
2679
		call ted_set_undo
2680
		mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
2681
		stdcall ted_sel_text_del,ebx
2682
		cmp al,1
2683
		jne .del
2684
			mov ebx,ted_opt_ed_move_cursor
2685
		.del:
4228 IgorA 2686
		stdcall ted_text_add,edi,edx,esi,ebx
1457 IgorA 2687
		stdcall ted_draw,edi
2688
		cmp ted_fun_draw_panel_buttons,0
4228 IgorA 2689
		je .no_paste
1457 IgorA 2690
			call ted_fun_draw_panel_buttons
4228 IgorA 2691
	.no_paste:
2692
	popad
1457 IgorA 2693
	ret
2694
endp
2695
 
2696
align 4
2324 IgorA 2697
proc ted_but_sumb_upper uses edi esi, edit:dword
2698
	mov edi,dword[edit]
1457 IgorA 2699
 
2324 IgorA 2700
	stdcall ted_convert_sel_text,fb_char_toupper
2701
	cmp esi,0
2702
	je @f
2703
		stdcall ted_draw,edi
2704
	@@:
2705
	ret
1457 IgorA 2706
endp
2707
 
2708
align 4
2324 IgorA 2709
proc ted_but_sumb_lover uses edi esi, edit:dword
2710
	mov edi,dword[edit]
1457 IgorA 2711
 
2324 IgorA 2712
	stdcall ted_convert_sel_text,fb_char_todown
2713
	cmp esi,0
2714
	je @f
2715
		stdcall ted_draw,edi
2716
	@@:
2717
	ret
1457 IgorA 2718
endp
2719
 
2720
align 4
2721
proc ted_but_reverse, edit:dword
2722
  push eax ebx edi
2723
  mov edi,dword[edit]
2724
 
2725
  call ted_is_select
2726
  cmp al,0
2727
  je @f
2728
    call ted_sel_normalize
2729
    push esi ecx edx
2730
      mov esi,ted_seln_x0
2731
      mov ecx,ted_seln_y0
2732
      call ted_get_pos_by_coords
2733
      mov eax,edx
2734
      mov esi,ted_seln_x1
2735
      cmp esi,0
2736
      je .beg_str
2737
	dec esi
2738
      .beg_str:
2739
      mov ecx,ted_seln_y1
2740
      call ted_get_pos_by_coords
2741
      ;call ted_get_text_perv_pos
2742
      mov ebx,edx
2743
    pop edx ecx esi
2744
    ;cmp eax,...
2745
    ;je @f
2746
    call ted_revers
2747
  @@:
2748
  stdcall ted_draw,edi
2749
  pop edi ebx eax
2750
  ret
2751
endp
2752
 
2753
align 4
2754
proc ted_but_undo, edit:dword
2755
	push eax edi
2756
	mov edi,dword[edit]
2757
 
2758
	mov eax,ted_tim_undo
2759
	cmp ted_tim_ch,eax
2760
	jbe @f
2761
		inc ted_tim_undo
2762
		;call ted_text_colored
2763
		stdcall ted_draw,edi
2764
		cmp ted_fun_draw_panel_buttons,0
2765
		je @f
2766
			call ted_fun_draw_panel_buttons
2767
	@@:
2768
	pop edi eax
2769
	ret
2770
endp
2771
 
2772
align 4
2773
proc ted_but_redo, edit:dword
2774
	push edi
2775
	mov edi,dword[edit]
2776
 
2777
	cmp ted_tim_undo,1
2778
	jb @f
2779
		dec ted_tim_undo
2780
		;call ted_text_colored
2781
		stdcall ted_draw,edi
2782
		cmp ted_fun_draw_panel_buttons,0
2783
		je @f
2784
			call ted_fun_draw_panel_buttons
2785
	@@:
2786
	pop edi
2787
	ret
2788
endp
2789
 
2790
align 4
2791
proc ted_but_find_next, edit:dword
2792
	pushad
2793
	mov edi,dword[edit]
2794
 
2795
	call ted_get_pos_by_cursor
2796
	mov eax,ted_buffer_find
2797
	mov bl,byte[eax]
2798
	@@:
2799
		call ted_get_find_rezult
2800
		cmp bh,1
2801
		je @f ; find
2802
			call ted_iterat_next
2803
			cmp edx,ted_tex_1
2804
			jle @f
2805
			jmp @b
2806
	@@:
2807
	cmp bh,0
2808
	je @f
2809
		call ted_get_text_coords
2810
		inc ebx ;move cursor right
2811
		mov ted_sel_x1,ebx
2812
		mov ted_sel_y1,eax
2813
		mov edx,eax
2814
		mov ecx,ebx
2815
		call ted_go_to_pos
2816
		mov edx,esi ;esi было установлео в ted_get_find_rezult
2817
		call ted_get_text_coords
2818
		mov ted_sel_x0,ebx
2819
		mov ted_sel_y0,eax
2820
		stdcall ted_draw,edi
2821
		jmp .end_find
2822
	@@:
2823
		;попадаем сюда если текст не найден
2824
		cmp ted_fun_find_err,0
2825
		je .end_find
2826
			call ted_fun_find_err ;пользовательская функция
2827
	.end_find:
2828
	popad
2829
	ret
2830
endp
2831
 
2832
;input:
2833
; edi = pointer to tedit struct
2834
align 4
2835
ted_key_ctrl_home:
2836
	mov ted_cur_x,0
2837
	mov ted_cur_y,0
2838
	push eax
2839
		mov eax,ted_scr_w
2840
		mov dword[eax+sb_offs_position],0
2841
		mov eax,ted_scr_h
2842
		mov dword[eax+sb_offs_position],0
2843
	pop eax
2844
	stdcall ted_draw,edi
2845
	cmp ted_fun_draw_panel_buttons,0
2846
	je @f
2847
		call ted_fun_draw_panel_buttons
2848
	@@:
2849
	ret
2850
 
2851
;input:
2852
; edi = pointer to tedit struct
2853
align 4
2854
proc ted_sel_key_up
2855
  cmp ted_drag_k,1
2856
  je @f
2857
    call ted_sel_start
2858
    mov ted_drag_k,1
2859
  @@:
2860
  push dx
2861
    call ted_cur_move_up
2862
    cmp dl,8
2863
    jne @f
2864
      call ted_scroll_set_redraw
2865
    @@:
2866
  pop dx
2867
  call ted_sel_move
2868
  stdcall ted_draw,edi
2869
  ret
2870
endp
2871
 
2872
;input:
2873
; edi = pointer to tedit struct
2874
align 4
2875
proc ted_sel_key_down
2876
  cmp ted_drag_k,1
2877
  je @f
2878
    call ted_sel_start
2879
    mov ted_drag_k,1
2880
  @@:
2881
  push dx
2882
    call ted_cur_move_down
2883
    cmp dl,8
2884
    jne @f
2885
      call ted_scroll_set_redraw
2886
    @@:
2887
  pop dx
2888
  call ted_sel_move
2889
  stdcall ted_draw,edi
2890
  ret
2891
endp
2892
 
2893
;input:
2894
; edi = pointer to tedit struct
2895
align 4
2896
proc ted_sel_key_left
2897
  cmp ted_drag_k,1
2898
  je @f
2899
    call ted_sel_start
2900
  @@:
2901
  push dx
2902
    call ted_cur_move_left
2903
    call ted_sel_move
2904
    cmp ted_drag_k,1
2905
    je @f
2906
      mov ted_drag_k,1
2907
      mov dl,8
2908
    @@:
2909
    cmp dl,8
2910
    jne @f
2911
      call ted_scroll_set_redraw
2912
      stdcall ted_draw,edi
2913
      jmp .end_f
2914
    @@:
2915
      stdcall ted_draw_cur_line,edi
2916
    .end_f:
2917
  pop dx
2918
  ret
2919
endp
2920
 
2921
;input:
2922
; edi = pointer to tedit struct
2923
align 4
2924
proc ted_sel_key_right
2925
  cmp ted_drag_k,1
2926
  je @f
2927
    call ted_sel_start
2928
  @@:
2929
  push dx
2930
    call ted_cur_move_right
2931
    call ted_sel_move
2932
    cmp ted_drag_k,1
2933
    je @f
2934
      mov ted_drag_k,1
2935
      mov dl,8
2936
    @@:
2937
    cmp dl,8
2938
    jne @f
2939
      call ted_scroll_set_redraw
2940
      stdcall ted_draw,edi
2941
      jmp .end_f
2942
    @@:
2943
      stdcall ted_draw_cur_line,edi
2944
    .end_f:
2945
  pop dx
2946
  ret
2947
endp
2948
 
2949
;input:
2950
; edi = pointer to tedit struct
2951
;description:
2952
; this function need to optimize output
2953
align 4
2954
proc ted_draw_cursor_sumb
2955
  pushad
2956
 
2957
  mov eax,13 ;rect
2958
  mov ebx,ted_wnd_l
2959
  add ebx,ted_rec_l
2960
  mov edx,ted_cur_x
2961
  imul edx,ted_rec_w
2962
  add ebx,edx
2963
  shl ebx,16
2964
  add ebx,ted_rec_w
2965
 
2966
  mov ecx,ted_wnd_t ;calc rect -> y0,y1
2967
  add ecx,ted_rec_t
2968
  mov edx,ted_cur_y
2969
  imul edx,ted_rec_h
2970
  add ecx,edx
2971
  shl ecx,16
2972
  add ecx,ted_rec_h
2973
 
2974
  mov edx,ted_color_wnd_work
2975
  push ecx
2976
    call ted_sel_normalize
2977
 
2978
    mov esi,ted_scr_w
2979
	mov ecx,dword[esi+sb_offs_position]
2980
    sub ted_seln_y0,ecx
2981
    sub ted_seln_y1,ecx
2982
 
2983
    mov ecx,ted_cur_y
2984
    cmp ecx,ted_seln_y0
2985
    jl .no_cur_sel
2986
    cmp ecx,ted_seln_y1
2987
    jg .no_cur_sel
2988
    mov edx,ted_color_select ;меняем цвет фона на цвет выделения
2989
 
2990
    mov esi,ted_scr_h
2991
	cmp ecx,ted_seln_y0
2992
    jne @f
2993
      mov ecx,ted_cur_x
2994
      add ecx,dword[esi+sb_offs_position]
2995
      cmp ecx,ted_seln_x0
2996
      jge @f
2997
      mov edx,ted_color_wnd_work
2998
    @@:
2999
 
3000
    mov ecx,ted_cur_y
3001
    cmp ecx,ted_seln_y1
3002
    jne .no_cur_sel
3003
      mov ecx,ted_cur_x
3004
      add ecx,dword[esi+sb_offs_position]
3005
      cmp ecx,ted_seln_x1
3006
      jl .no_cur_sel
3007
      mov edx,ted_color_wnd_work
3008
 
3009
    .no_cur_sel:
3010
  pop ecx
3011
  int 0x40 ;рисование прямоугольника
3012
 
3013
  call ted_get_pos_by_cursor ;берем позицию символа
3014
  cmp ted_gp_opt,2
3015
  jne @f
3016
    mov eax,4
3017
    mov esi,1
3018
    ror ecx,16
3019
    mov bx,cx
3020
    add ebx,0x10001
3021
    call ted_get_symb_color
3022
    call ted_convert_invis_symb
3023
    int 0x40 ;рисование символа
3024
  @@:
3025
 
3026
  popad
3027
  ret
3028
endp
3029
 
3030
;input:
3031
; edx -> pointer to text
3032
; edi -> указатель на структуру tedit
3033
;output:
3034
; ecx = color
3035
; if ted_mode_color=0 then ecx=ted_color_wnd_text
3036
align 4
3037
ted_get_symb_color:
3038
  mov ecx,ted_color_wnd_text ;задаем цвет текста по умолчанию
3039
 
3040
  push eax edx
3041
  cmp ted_mode_color,0
3042
  je .exit
3043
    jmp .on_first
3044
    @@:
3045
      call ted_iterat_perv
3046
      cmp edx,ted_tex_1
3047
      jle .exit
3048
    .on_first:
3049
      xor eax,eax
3050
      mov al,byte[edx+1]
3051
      cmp al,0 ;если al=0 то цвет не меняется
3052
    je @b
3053
 
3054
    cmp eax,ted_colors_text_count
3055
    jge .exit
3056
 
3057
    shl ax,2 ;умножаем индекс цвета на 4 байта
3058
    mov ecx,ted_text_colors ;прибавляем смещение 1-го цвета
3059
    add ecx,eax
3060
    mov ecx,dword[ecx] ;устанавливаем текущий цвет текста по смещению
3061
  .exit:
3062
  pop edx eax
3063
  ret
3064
 
3065
;input:
3066
; edx = pointer to text
3067
; edi = pointer to tedit struct
3068
;description:
3069
; Функция преобразует невидимые символы в печатаемые на экране
3070
align 4
3071
ted_convert_invis_symb:
1458 IgorA 3072
	cmp ted_mode_invis,1
3073
	jne .end_f
3074
		cmp byte[edx],9
3075
		jne @f
3076
			lea edx,[ted_symbol_tab]
3077
		@@:
3078
		cmp byte[edx],13
3079
		jne @f
3080
			mov edx,edi
3081
			add edx,ted_offs_symbol_new_line
3082
		@@:
3083
	.end_f:
3084
	ret
1457 IgorA 3085
 
3086
;input:
3087
; edi = pointer to tedit struct
3088
align 4
3089
ted_scroll_set_redraw:
3090
	push eax
3091
	mov eax,ted_scr_w
3092
	mov dword[eax+sb_offs_redraw],1
3093
	mov eax,ted_scr_h
3094
	mov dword[eax+sb_offs_redraw],1
3095
	pop eax
3096
	ret
3097
 
3098
align 4
3099
proc ted_draw, edit:dword
1458 IgorA 3100
	locals
3101
		line_num dd ?
3102
	endl
3103
	pushad
3104
	mov edi,dword[edit]
1457 IgorA 3105
 
1458 IgorA 3106
	mov eax,4 ;draw text
3107
	mov ecx,ted_text_colors
3108
	mov ecx,dword[ecx]
1457 IgorA 3109
 
1458 IgorA 3110
	mov ebx,ted_wnd_l
3111
	add ebx,ted_rec_l
3112
	shl ebx,16
3113
	add ebx,ted_wnd_t
3114
	add ebx,ted_rec_t
3115
	add ebx,0x10001 ;добавляем отступы для выравнивания буквы по центру
1457 IgorA 3116
 
1458 IgorA 3117
	call ted_sel_normalize ;need before draw select
3118
	mov esi,ted_scr_w
3119
	mov esi,dword[esi+sb_offs_position]
3120
	mov dword[line_num],esi
1457 IgorA 3121
 
1458 IgorA 3122
	stdcall ted_clear_line_before_draw, edi,ebx,1,esi
3123
	call ted_get_first_visible_pos
3124
	cmp edx,0
3125
	je .no_draw_text
3126
	mov esi,1 ;длинна выводимого текста по 1-му символу
3127
	@@:
3128
		call ted_iterat_next
3129
		cmp edx,ted_tex_1
3130
		jle .no_draw_text
1457 IgorA 3131
 
1458 IgorA 3132
		; *** цветовая разметка
3133
		cmp ted_mode_color,0
3134
		je .no_col_change
3135
		cmp byte[edx+1],0
3136
		je .no_col_change
3137
			call ted_get_symb_color
3138
		.no_col_change:
1457 IgorA 3139
 
1458 IgorA 3140
		cmp byte [edx],13
3141
		jne .no_13
3142
			cmp ted_mode_invis,1
3143
			jne .no_invis
3144
				push edx
3145
				mov edx,edi
3146
				add edx,ted_offs_symbol_new_line
3147
				int 0x40
3148
				pop edx
3149
			.no_invis:
3150
			add ebx,ted_rec_h
3151
			;optimized output \/
3152
			mov eax,ted_wnd_h
3153
			add eax,ted_wnd_t
3154
			cmp bx,ax
3155
			jg .no_draw_text
3156
			mov eax,4
3157
			;optimized output /\
3158
			and ebx,0xffff
3159
			ror ebx,16
3160
			add ebx,ted_wnd_l
3161
			add ebx,ted_rec_l
3162
			inc ebx
3163
			ror ebx,16
3164
			inc dword[line_num] ;increment line number
3165
			stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
3166
			call ted_opt_draw_line_left
3167
			jmp @b
3168
		.no_13:
1457 IgorA 3169
 
1458 IgorA 3170
		int 0x40
3171
		ror ebx,16
3172
		add ebx,ted_rec_w
3173
		mov esi,ted_wnd_l
3174
		add esi,ted_wnd_w
3175
		cmp bx,si
3176
		jl .no_opt
3177
			call ted_opt_draw_line_right
3178
		.no_opt:
3179
		mov si,1
3180
		ror ebx,16
3181
		jmp @b
3182
	.no_draw_text:
1457 IgorA 3183
 
1458 IgorA 3184
	stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
3185
	call ted_draw_line_numbers
3186
	call ted_draw_main_cursor
1457 IgorA 3187
 
3188
;---------------------------------------------
3189
; set all_redraw flag for draw all ScrollBar
3190
; In some cases it is necessity to draw only the area
3191
; of moving of a "runner", for acceleration of output -
3192
; in this case the flag needs to be reset to 0 (zero).
3193
	mov eax,ted_scr_h
3194
	mov esi,ted_scr_w
3195
	mov dword[eax+sb_offs_all_redraw],1
3196
	mov dword[esi+sb_offs_all_redraw],1
3197
 
3198
; рисование полос прокрутки
3199
	stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
3200
	stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
3201
; reset all_redraw flag
3202
	mov dword[eax+sb_offs_all_redraw],0
3203
	mov dword[esi+sb_offs_all_redraw],0
3204
;---------------------------------------------
3205
 
3206
  ;left-bottom square
3207
  mov ebx,ted_wnd_l
3208
  shl ebx,16
3209
  add ebx,ted_rec_l
3210
  mov ecx,ted_wnd_t
3211
  add ecx,ted_wnd_h
3212
  shl ecx,16
3213
  mov cx,word[eax+sb_offs_size_y]
3214
  inc cx
3215
  mov edx,ted_color_wnd_capt ;[sc.work]
3216
  mov eax,13
3217
  int 0x40
3218
 
3219
	;right-bottom square
3220
	mov ebx,ted_wnd_l
3221
	add ebx,ted_wnd_w
3222
	shl ebx,16
3223
	mov bx,word[esi+sb_offs_size_x]
3224
	inc bx
3225
	int 0x40
3226
 
3227
	cmp ted_fun_draw_panel_find,0
3228
	je @f
3229
		call ted_fun_draw_panel_find
3230
	@@:
3231
	cmp ted_fun_draw_panel_syntax,0
3232
	je @f
3233
		call ted_fun_draw_panel_syntax
3234
	@@:
3235
	popad
3236
	ret
3237
endp
3238
 
3239
;input:
3240
; edi = pointer to tedit struct
3241
align 4
3242
proc ted_draw_main_cursor
3243
  pushad
3244
 
3245
  mov eax,13 ;draw cursor
3246
  mov ecx,ted_wnd_t ;calc rect -> y0,y1
3247
  add ecx,ted_rec_t
3248
  mov edx,ted_cur_y
3249
  imul edx,ted_rec_h
3250
  add ecx,edx
3251
 
3252
  cmp ted_cur_ins,1 ;проверка режима работы курсора (обычный или вставка)
3253
  jne @f
3254
    mov edx,ted_rec_h
3255
    inc edx   ;1->1, 3->2, 5->3, ...
3256
    shr edx,1 ;edx = высота строки деленная на 2 (когда курсор не полный)
3257
    add ecx,edx
3258
  @@:
3259
  shl ecx,16
3260
  add ecx,ted_rec_h
3261
  cmp ted_cur_ins,1
3262
  jne @f
3263
    shr cx,1 ;делим высоту курсора на 2
3264
  @@:
3265
 
3266
  mov ebx,ted_wnd_l ;calc rect -> x0,x1
3267
  add ebx,ted_rec_l
3268
  mov edx,ted_cur_x
3269
  imul edx,ted_rec_w
3270
  add ebx,edx
3271
  shl ebx,16
3272
  add ebx,ted_rec_w
3273
 
3274
  mov edx,ted_color_cursor
3275
  int 0x40 ;вывод курсора
3276
 
3277
  call ted_get_pos_by_cursor
3278
  cmp ted_gp_opt,2
3279
  jne @f
3280
    mov eax,4 ;draw text
3281
    mov esi,1
3282
    ror ecx,16
3283
    mov bx,cx
3284
    add ebx,0x10001
3285
    cmp ted_cur_ins,1
3286
    jne .no_up_tetx
3287
      mov ecx,ted_rec_h
3288
      inc cx ; 1->1, 3->2, 5->3, ...
3289
      shr cx,1
3290
      sub bx,cx
3291
    .no_up_tetx:
3292
    mov ecx,ted_color_cur_text
3293
    call ted_convert_invis_symb
3294
    int 0x40
3295
  @@:
3296
 
3297
  mov eax,4
3298
  mov ebx,ted_wnd_l
3299
  add ebx,ted_rec_l
3300
  shl ebx,16
3301
  add ebx,ted_wnd_t
3302
  add ebx,3
3303
  mov ecx,ted_color_wnd_bord
3304
  or  ecx,0x80000000
3305
  lea edx,[txtRow]
3306
  int 0x40 ;вывод подписи 'Строка'
3307
 
3308
  add ebx,0x500000
3309
  lea edx,[txtCol]
3310
  int 0x40 ;вывод подписи 'Знак'
3311
 
3312
  cmp ted_tim_undo,0
3313
  je @f
3314
    add ebx,0x500000
3315
    lea edx,[txtOtm]
3316
    int 0x40
3317
    sub ebx,0x500000
3318
  @@:
3319
 
3320
  call ted_draw_buffer
3321
  call ted_draw_help_f1
3322
 
3323
  mov eax,47 ;draw cursor coords
3324
  mov esi,ted_color_wnd_bord
3325
  or  esi,0x40000000
3326
 
3327
  mov edx,ebx
3328
  ror edx,16
3329
  sub edx,35
3330
  ror edx,16
3331
  ;add edx,3
3332
  mov ebx,0x40000 ;Row=...
3333
  mov ecx,ted_scr_w
3334
  mov ecx,dword[ecx+sb_offs_position]
3335
  add ecx,ted_cur_y
3336
  inc ecx
3337
 
3338
push edi
3339
  mov edi,ted_color_wnd_work
3340
  int 0x40 ;вывод числа текущей строки
3341
pop edi
3342
 
3343
  ;mov ebx,0x40000 ;Col=...
3344
  mov ecx,ted_scr_h
3345
  mov ecx,dword[ecx+sb_offs_position]
3346
  add ecx,ted_cur_x
3347
  inc ecx
3348
  add edx,0x500000
3349
push edi
3350
  mov edi,ted_color_wnd_work
3351
  int 0x40 ;вывод числа знаков
3352
pop edi
3353
 
3354
  cmp ted_tim_undo,0
3355
  je @f
3356
    mov ecx,ted_tim_undo
3357
    add edx,0x500000
1458 IgorA 3358
	mov edi,ted_color_wnd_work ;портим регистр edi, но в конце функции это уже не важно
3359
    int 0x40 ;вывод числа отмененных действий
1457 IgorA 3360
  @@:
3361
 
3362
  popad
3363
  ret
3364
endp
3365
 
3366
;input:
3367
; edi = pointer to tedit struct
3368
proc ted_draw_buffer
3369
	pushad
3370
 
3371
	mov eax,ted_buffer
4228 IgorA 3372
	cmp dword[eax],1 ;смотрим размер буфера
3373
	jl @f
1458 IgorA 3374
		mov ebx,ted_rec_l
1457 IgorA 3375
		add bx,300
1458 IgorA 3376
		cmp ebx,ted_wnd_w ;сравниваем координату для вывод текста
3377
		jge @f ;подпись не влазит в окно
3378
 
3379
		add ebx,ted_wnd_l
1457 IgorA 3380
		shl ebx,16
3381
		add ebx,ted_wnd_t
3382
		add ebx,3
3383
		mov ecx,ted_color_wnd_bord
3384
		or ecx,0x40000000
3385
 
3386
		mov edx,ted_buffer
4228 IgorA 3387
		add edx,12
1457 IgorA 3388
		mov esi,edx
3389
		mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
3390
		call tl_strlen
3391
		;cmp eax,0 ;буфер пуст
3392
		;je @f
3393
		cmp eax,20
3394
		jle .crop_buf
3395
			mov eax,20 ;обрезка подписи до 20 символов
3396
		.crop_buf:
3397
		mov esi,eax
3398
		mov eax,4
3399
		int 0x40 ;вывод содержимого буфера
3400
 
3401
		sub ebx,50 shl 16
3402
		lea edx,[txtBuf]
3403
		mov esi,edx
3404
		call tl_strlen
3405
		mov esi,eax
3406
		mov eax,4
3407
		xor ecx,0x40000000 ;убираем цвет фона
3408
		int 0x40 ;вывод подписи для буфера
3409
	@@:
3410
	popad
3411
	ret
3412
endp
3413
 
3414
;input:
3415
; edi = pointer to tedit struct
3416
align 4
3417
proc ted_draw_help_f1
1458 IgorA 3418
	pushad
3419
	cmp ted_rec_t,13 ;минимальная высота для рисования справки
3420
	jle @f
3421
		mov eax,13 ;clear place before draw help
3422
		mov ebx,ted_wnd_l
3423
		add ebx,ted_rec_l
3424
		shl ebx,16
3425
		add ebx,ted_wnd_w
3426
		sub ebx,ted_rec_l
3427
		mov ecx,ted_wnd_t
3428
		add ecx,13
3429
		shl ecx,16
3430
		add ecx,ted_rec_h
3431
		mov edx,ted_color_wnd_capt
3432
		int 0x40
1457 IgorA 3433
 
1458 IgorA 3434
	cmp ted_help_id,-1
3435
	je @f
3436
		mov eax,ted_help_id
3437
		ColToIndexOffset eax,edx
1457 IgorA 3438
 
1458 IgorA 3439
		;SetCoordinates
3440
		mov ebx,ted_wnd_l
3441
		add ebx,ted_rec_l
3442
		shl ebx,16
3443
		add ebx,ted_wnd_t
3444
		add ebx,13 ;=3+10
1457 IgorA 3445
 
1458 IgorA 3446
		;SetTextColor
3447
		xor eax,eax
2102 IgorA 3448
		mov al,byte[edx+MAX_COLOR_WORD_LEN+7]
1458 IgorA 3449
		shl ax,2
3450
		mov ecx,ted_text_colors
3451
		add ecx,eax
3452
		mov ecx,dword[ecx]
3453
		or	ecx,0xc0000000 ;SetTextStyles
3454
		mov esi,edi
3455
			mov edi,ted_color_wnd_work
3456
			mov eax,4
3457
			int 0x40
3458
		mov edi,esi
1457 IgorA 3459
 
1458 IgorA 3460
		;*** draw help string ***
3461
		mov ecx,ted_color_wnd_bord
3462
		or ecx,0x80000000
3463
		mov edx,dword[edx+MAX_COLOR_WORD_LEN]
3464
		cmp edx,0
3465
		je @f
3466
			add edx,ted_help_text_f1
3467
			add ebx,0x500000
3468
			int 0x40
3469
	@@:
3470
	popad
3471
	ret
1457 IgorA 3472
endp
3473
 
3474
;input:
3475
; edi = pointer to tedit struct
3476
align 4
3477
proc ted_draw_line_numbers
3478
  pushad
3479
 
3480
  ;top panel with caption
3481
  mov ebx,ted_wnd_l
3482
;  add ebx,ted_rec_l
3483
  shl ebx,16
3484
  add ebx,ted_wnd_w
3485
;  sub ebx,ted_rec_l
3486
  mov edx,ted_color_wnd_work
3487
  mov ecx,ted_wnd_t
3488
  shl ecx,16
3489
  add ecx,ted_rec_t
3490
  mov eax,13
3491
  mov edx,ted_color_wnd_capt
3492
  int 0x40
3493
 
3494
  ;line numbers
3495
  mov ebx,0x40000 ;format
3496
  mov ecx,ted_scr_w
3497
  mov ecx,dword[ecx+sb_offs_position]
3498
  inc ecx
3499
  mov edx,3
3500
  add edx,ted_wnd_l
3501
  rol edx,16
3502
  add edx,ted_wnd_t
3503
  add edx,ted_rec_t
3504
  @@:
3505
 
3506
push ebx ecx edx
3507
  ;left panel with numbers
3508
  mov ebx,ted_wnd_l
3509
  shl ebx,16
3510
  add ebx,ted_rec_l
3511
  mov ecx,ted_rec_h
3512
  rol ecx,16
3513
  mov cx,dx
3514
  rol ecx,16
3515
  mov eax,13
3516
  mov edx,ted_color_wnd_capt
3517
  int 0x40 ;рисуем прямоугольник под номером строки
3518
pop edx ecx ebx
3519
 
3520
    mov eax,47
3521
    mov esi,ted_color_wnd_bord
3522
    int 0x40 ;рисуем номер строки
3523
    inc ecx
3524
    add edx,ted_rec_h
3525
    sub edx,ted_wnd_t
3526
	mov esi,edx
3527
	and esi,0xffff
3528
    cmp esi,ted_wnd_h
3529
    jge @f
3530
    add edx,ted_wnd_t
3531
    jmp @b
3532
  @@:
3533
 
3534
  popad
3535
  ret
3536
endp
3537
 
3538
;output:
3539
; ah = symbol
3540
align 4
3541
proc KeyConvertToASCII, table:dword
1464 IgorA 3542
	push ebx
3543
	mov ebx,dword[table] ;convert scan to ascii
3544
	ror ax,8
3545
	xor ah,ah
3546
	add bx,ax ;? ebx,eax
3547
	mov ah,byte[ebx]
3548
	pop ebx
3549
	ret
1457 IgorA 3550
endp
3551
 
3552
align 4
3553
proc ted_draw_cur_line, edit:dword
3554
  pushad
3555
    mov edi,dword[edit]
3556
 
3557
    mov ebx,ted_wnd_l
3558
    add ebx,ted_rec_l
3559
    shl ebx,16
3560
    mov eax,ted_cur_y
3561
    imul eax,ted_rec_h
3562
	mov bx,ax
3563
    add ebx,ted_wnd_t
3564
    add ebx,ted_rec_t ;ebx - координаты для прямоугольника очистки линии
3565
	add ebx,0x10001   ;добавляем отступы для выравнивания буквы по центру
3566
 
3567
    call ted_sel_normalize ;need before draw select
3568
	mov ecx,ted_cur_y
3569
	mov eax,ted_scr_w
3570
    add ecx,dword[eax+sb_offs_position]
3571
    stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
3572
 
3573
    mov eax,ted_scr_h
3574
	mov esi,dword[eax+sb_offs_position]
3575
    call ted_get_pos_by_coords
3576
 
3577
  cmp ted_gp_opt,2
3578
  jne .no_draw_text
3579
;  mov eax,4 ;draw text
3580
  call ted_get_symb_color
3581
  mov esi,1 ;draw 1 symbol
3582
  @@:
3583
    ;call ted_iterat_next
3584
    cmp edx,ted_tex_1
3585
    jle .no_draw_text
3586
 
3587
    ; *** цветовая разметка
3588
    cmp ted_mode_color,0
3589
    je .no_col_change
3590
    cmp byte[edx+1],0
3591
    je .no_col_change
3592
      call ted_get_symb_color
3593
    .no_col_change:
3594
 
3595
    mov eax,4 ;draw text
3596
    cmp byte [edx],13
3597
    jne .no_13
3598
      cmp ted_mode_invis,1
3599
      jne .no_draw_text
3600
 push edx
3601
 mov edx,edi
3602
 add edx,ted_offs_symbol_new_line
3603
 int 0x40
3604
 pop edx
3605
      jmp .no_draw_text
3606
    .no_13:
3607
 
3608
    int 0x40
3609
    ror ebx,16
3610
    add ebx,ted_rec_w
3611
    mov eax,ted_wnd_w
3612
    add eax,ted_wnd_l ;ax = отступ по оси x
3613
    cmp bx,ax
3614
    jge .no_draw_text ;Opt
3615
    ror ebx,16
3616
    call ted_iterat_next
3617
    jmp @b
3618
  .no_draw_text:
3619
 
3620
  call ted_draw_main_cursor
3621
  popad
3622
  ret
3623
endp
3624
 
3625
;input:
3626
; eax - text need find
3627
; bl - first symbol to find
3628
; edx - first symbol pointer
3629
; edi - pointer to tedit struct
3630
;output:
3631
; bh - rezult
3632
; edx - last text position (if find sucess)
3633
; esi - first symbol pointer
3634
;description:
3635
; Функция проверяет совпадает ли текст в буфере eax
3636
; с текстом редактора по указателю edx.
3637
; Стандартные функции (напр. strcmp) тут не подойдут, потому что
3638
; в памяти редактора текст содержится не в виде ascii строк.
3639
align 4
3640
ted_get_find_rezult:
3641
  push eax
3642
    mov bh,1
3643
    mov esi,edx ;copy edx
3644
    @@:
3645
      cmp byte[edx],bl
3646
      jne .no_text
3647
 
3648
      inc eax ;*** get next symbol (in find text) ***
3649
      mov bl,byte[eax]
3650
      cmp bl,0
3651
      je @f ;end of find text
3652
 
3653
      call ted_iterat_next ;*** get next symbol (in editor text) ***
3654
      cmp edx,ted_tex_1
3655
      jle @f ;end of editor text
3656
 
3657
      jmp @b
3658
      .no_text:
3659
	xor bh,bh
3660
	mov edx,esi ;restore edx
3661
    @@:
3662
  pop eax
3663
  mov bl,byte[eax] ;restore bl
3664
  ret
3665
 
3666
;input:
3667
;  clear_o - если =1 очистить одну строку, =0 очистить все строки окна до низу
3668
align 4
3669
proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
3670
	pushad
3671
	mov edi,dword[edit]
3672
	mov ebx,dword[coords]	;ebx = x*2^16+y coords to left up point clear line
3673
	mov esi,dword[numb_lin] ;esi - number text line
3674
 
3675
	sub ebx,0x10001 ;отнимаем отступы для выравнивания буквы по центру
3676
	cmp dword[clear_o],0
3677
	jne @f
3678
		add ebx,ted_rec_h
3679
		inc esi
3680
		ror ebx,16
3681
		xor bx,bx
3682
		add ebx,ted_wnd_l
3683
		add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
3684
		ror ebx,16
3685
	@@:
3686
 
3687
	mov eax,ted_wnd_h
3688
	add eax,ted_wnd_t
3689
	cmp ax,bx
3690
	jl .no_clear
3691
	sub ax,bx
3692
 
3693
	mov cx,bx
3694
	shl ecx,16
3695
 
3696
	xor bx,bx
3697
	add ebx,ted_wnd_w
3698
	sub ebx,ted_rec_l
3699
	xor cx,cx
3700
	add ecx,ted_rec_h
3701
	mov edx,ted_color_wnd_work
3702
 
3703
	cmp dword[clear_o],0
3704
	je .pusto
3705
	cmp ax,cx
3706
	jge @f
3707
	.pusto:
3708
		mov cx,ax
3709
	@@:
3710
 
3711
	call ted_is_select
3712
	cmp al,0
3713
	je @f
3714
	cmp ted_seln_y0,esi
3715
	jg @f
3716
	cmp ted_seln_y1,esi
3717
	jl @f
3718
		mov edx,ted_color_select ;draw selected line
3719
	@@:
3720
 
3721
	mov eax,13 ;rect
3722
	int 0x40
3723
 
3724
	call ted_is_select
3725
	cmp al,0
3726
	je .no_clear
3727
 
3728
	mov al,13 ;rect
3729
	xor cx,cx
3730
	add ecx,ted_rec_h
3731
	cmp ted_seln_y0,esi
3732
	jne @f
3733
		push bx esi
3734
		mov edx,ted_seln_x0 ; верхняя полоса (затирает слева)
3735
		mov esi,ted_scr_h
3736
		cmp edx,dword[esi+sb_offs_position]
3737
		jle .in_wnd
3738
			sub edx,dword[esi+sb_offs_position]
3739
			imul edx,ted_rec_w
3740
			mov bx,dx
3741
			jmp .no_wnd
3742
		.in_wnd:
3743
		mov bx,0
3744
		.no_wnd:
3745
		mov edx,ted_color_wnd_work
3746
		int 0x40
3747
		pop esi bx
3748
	@@:
3749
	cmp ted_seln_y1,esi
3750
	jne @f
3751
		push esi
3752
		mov edx,ted_seln_x1 ; нижняя полоса (затирает справа)
3753
		mov esi,ted_scr_h
3754
		cmp edx,dword[esi+sb_offs_position]
3755
		jle .in_wnd2
3756
			sub edx,dword[esi+sb_offs_position]
3757
			imul edx,ted_rec_w
3758
			sub bx,dx
3759
			shl edx,16
3760
			add ebx,edx
3761
		.in_wnd2:
3762
 
3763
		mov edx,ted_color_wnd_work
3764
		int 0x40
3765
		pop esi
3766
	@@:
3767
 
3768
	.no_clear:
3769
	popad
3770
	ret
3771
endp
3772
 
3773
;input:
3774
; edi = pointer to tedit struct
3775
;output:
3776
; ecx = новый цвет символа
3777
; edx = pointer to symbol
3778
; edx = 0 if text not in screen
3779
align 4
3780
ted_get_first_visible_pos:
3781
	push eax ecx
3782
	mov eax,ted_scr_w
3783
	mov edx,ted_tex
3784
	xor ecx,ecx
3785
	@@:
3786
		cmp ecx,dword[eax+sb_offs_position]
3787
		je @f
3788
		call ted_iterat_next
3789
		cmp edx,ted_tex_1
3790
		jle @f
3791
		cmp byte [edx],13
3792
		jne @b
3793
		inc ecx
3794
		jmp @b
3795
	@@:
3796
 
3797
	cmp ecx,dword[eax+sb_offs_position]
3798
	je @f
3799
		xor edx,edx
3800
	@@:
3801
	cmp ecx,dword[eax+sb_offs_max_area]
3802
	jle @f
3803
		mov dword[eax+sb_offs_max_area],ecx
3804
	@@:
3805
	pop ecx eax
3806
	call ted_opt_draw_line_left
3807
	ret
3808
 
3809
;input:
3810
; edx = pointer to symbol
3811
; edi = pointer to tedit struct
3812
;output:
3813
; ecx = цвет символа
3814
; edx = указатель на первый левый символ
3815
;description:
3816
; функция нужна для оптимизации вывода текста
3817
align 4
3818
proc ted_opt_draw_line_left
3819
  push ebx
3820
 
3821
  mov ebx,ted_scr_h
3822
  mov ebx,dword[ebx+sb_offs_position]
3823
  cmp ebx,0
3824
  je .ret_f
3825
  push eax
3826
  mov eax,edx
3827
 
3828
  cmp edx,ted_tex
3829
  jne @f
3830
    call ted_iterat_next
3831
    jmp .beg_cycle
3832
  @@:
3833
 
3834
  cmp ebx,0
3835
  je @f
3836
 
3837
  cmp byte[edx],13
3838
  jne @f
3839
    call ted_iterat_next
3840
    .beg_cycle:
3841
  @@:
3842
    cmp edx,ted_tex_1
3843
    jle @f
3844
    cmp byte[edx],13
3845
    je @f
3846
    cmp ebx,0
3847
    je @f
3848
;--------------------------------------
3849
xor eax,eax ;eax будет меняться
3850
mov al,byte[edx+1]
3851
cmp al,0
3852
je .no_color
3853
cmp eax,ted_colors_text_count
3854
jge .no_color
3855
  xor ecx,ecx
3856
  mov cl,byte[edx+1]
3857
  shl cx,2
3858
  add ecx,ted_text_colors
3859
  mov ecx,dword[ecx]
3860
.no_color:
3861
;--------------------------------------
3862
    mov eax,edx
3863
    call ted_iterat_next
3864
    dec ebx
3865
    jmp @b
3866
  @@:
3867
    mov edx,eax
3868
  pop eax
3869
  .ret_f:
3870
  call ted_get_symb_color
3871
  pop ebx
3872
  ret
3873
endp
3874
 
3875
;input:
3876
; edx = pointer to symbol
3877
; edi = pointer to tedit struct
3878
;output:
3879
; ecx = symbol color
3880
; edx = pointer to 13 symbol
3881
;description:
3882
; функция нужна для оптимизации вывода текста
3883
align 4
3884
proc ted_opt_draw_line_right
3885
	push eax
3886
	mov eax,edx
3887
	@@:
3888
		cmp edx,ted_tex_1
3889
		jle @f
3890
		cmp byte[edx],13
3891
		je @f
3892
		mov eax,edx
3893
		call ted_iterat_next
3894
		jmp @b
3895
	@@:
3896
	mov edx,eax ;perv sumbol
3897
	call ted_get_symb_color
3898
 
3899
	pop eax
3900
	ret
3901
endp
3902
 
3903
align 4
3904
proc ted_mouse, edit:dword
3905
	pushad
3906
	mov edi,dword[edit]
3907
 
3908
	;обрабатываем скроллинги
3909
	mov edx,ted_scr_h
3910
	mov ecx,ted_scr_w
3911
 
3912
	cmp word[edx+sb_offs_delta2],0
3913
	jne .horizontal
3914
 
3915
	mov eax,dword[ecx+sb_offs_max_area]
3916
	cmp eax,dword[ecx+sb_offs_cur_area]
3917
	jbe .horizontal
3918
	; mouse event for Vertical ScrollBar
3919
	stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
3920
	cmp dword[ecx+sb_offs_redraw],0
3921
	je @f
3922
		mov dword[ecx+sb_offs_redraw],0
3923
		stdcall ted_draw,edi
3924
		jmp .no_in_wnd
3925
	@@:
3926
	cmp word[ecx+sb_offs_delta2],0
3927
	jne .no_in_wnd
3928
	.horizontal:
3929
	mov eax,dword[edx+sb_offs_max_area]
3930
	cmp eax,dword[edx+sb_offs_cur_area]
3931
	jbe .other
3932
	; mouse event for Horizontal ScrollBar
3933
	stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
3934
	cmp dword[edx+sb_offs_redraw],0
3935
	je .other
3936
		mov dword[edx+sb_offs_redraw],0
3937
		stdcall ted_draw,edi
3938
		jmp .no_in_wnd
3939
	.other:
3940
	cmp word[ecx+sb_offs_delta2],0
3941
	jne .no_in_wnd
3942
	cmp word[edx+sb_offs_delta2],0
3943
	jne .no_in_wnd
3944
 
3945
	;обрабатываем окно редактора
3946
	mcall 37,2 ;get mouse buttons
3947
	cmp al,1
3948
	jne @f
3949
		mcall 37,1 ;get mouse coords
3950
		mov ebx,ted_wnd_t
3951
		add ebx,ted_rec_t
3952
		cmp ax,bx
3953
		jl @f ;y_mouse
3954
 
3955
		sub ebx,ted_rec_t
3956
		add ebx,ted_wnd_h
3957
		cmp bx,ax
3958
		jl @f ;y_mouse>y_wnd
3959
 
3960
		mov ebx,ted_wnd_l
3961
		add ebx,ted_rec_l
3962
		mov ecx,eax
3963
		shr ecx,16
3964
		cmp cx,bx
3965
		jl @f ;x_mouse
3966
 
3967
		sub ebx,ted_rec_l
3968
		add ebx,ted_wnd_w
3969
		cmp bx,cx
3970
		jl @f ;x_mouse>x_wnd
3971
 
3972
		call ted_draw_cursor_sumb
3973
		call ted_wnd_main_click
3974
		jmp .no_in_wnd
3975
	@@:
1458 IgorA 3976
	mov edx,ted_el_focus
3977
	cmp dword[edx],edi
3978
	jne @f
3979
		call ted_wnd_main_mouse_scroll ;смотрим на прокрутку колеса мыши
3980
	@@:
1457 IgorA 3981
	cmp ted_drag_m,0
3982
	je .no_in_wnd
3983
		mov ted_drag_m,0
3984
		stdcall ted_draw,edi
3985
		cmp ted_fun_draw_panel_buttons,0
3986
		je .no_in_wnd
3987
			call ted_fun_draw_panel_buttons
3988
	.no_in_wnd:
3989
	popad
3990
	ret
3991
endp
3992
 
3993
;input:
3994
; eax -> (x,y)
3995
; edi -> указатель на структуру tedit
3996
;description:
3997
; функция вызывется при нажатии кнопкой мыши и попадении курсором в окно редактора
3998
align 4
3999
ted_wnd_main_click:
1458 IgorA 4000
	push ebx ecx edx
4001
	mov ebx,ted_el_focus
4002
	mov dword[ebx],edi ;ставим фокус
1457 IgorA 4003
 
4004
  push eax
4005
    shr eax,16
4006
    and eax,0xffff
4007
    sub eax,ted_wnd_l
4008
    sub eax,ted_rec_l
4009
 
4010
    xor edx,edx
4011
    mov ecx,ted_rec_w
4012
    div cx
4013
    ;inc eax
4014
	mov ebx,ted_scr_h
4015
    cmp eax,dword[ebx+sb_offs_cur_area]
4016
    jle @f
4017
      mov eax,dword[ebx+sb_offs_cur_area]
4018
    @@:
4019
    ;dec eax
4020
    mov ted_cur_x,eax
4021
  pop eax
4022
 
4023
  push eax
4024
    and eax,0xffff
4025
    sub eax,ted_wnd_t
4026
    sub eax,ted_rec_t
4027
 
4028
    xor edx,edx
4029
    mov ecx,ted_rec_h
4030
    div cx
4031
    inc eax
4032
	mov ebx,ted_scr_w
4033
    cmp eax,dword[ebx+sb_offs_cur_area]
4034
    jle @f
4035
      mov eax,dword[ebx+sb_offs_cur_area]
4036
    @@:
4037
    dec eax
4038
    mov ted_cur_y,eax
4039
  pop eax
4040
 
1458 IgorA 4041
	cmp ted_drag_m,0
4042
	je @f
4043
		call ted_sel_move
4044
		jmp .sel_move
4045
	@@:
4046
		mov ted_drag_m,1
4047
		call ted_sel_start
4048
	.sel_move:
4049
	pop edx ecx ebx
4050
	ret
1457 IgorA 4051
 
4052
;input:
4053
; edi = pointer to tedit struct
4054
align 4
4055
ted_wnd_main_mouse_scroll:
4056
	push eax ebx ecx
1458 IgorA 4057
	mcall 37,7 ;прокрутка колеса мыши
1457 IgorA 4058
	cmp ax,0
4059
	je .no_scroll
4060
		mov ecx,ted_scr_w
4061
		mov ebx,dword[ecx+sb_offs_position] ;copy old scroll position
4062
		and eax,0xffff
4063
		btr ax,15
4064
		jae @f
4065
			or eax,0xffff8000
1458 IgorA 4066
		@@:
4067
		add dword[ecx+sb_offs_position],eax
1457 IgorA 4068
 
1458 IgorA 4069
		mov eax,[ecx+sb_offs_position]
4070
		cmp eax,[ecx+sb_offs_max_area]
4071
		jb @f
4072
			mov dword[ecx+sb_offs_position],ebx ;if scroll position out of range
4073
			jmp .no_scroll
4074
		@@:
4075
		stdcall ted_draw,edi
1457 IgorA 4076
	.no_scroll:
4077
	pop ecx ebx eax
4078
	ret
4079
 
4080
align 4
4308 IgorA 4081
proc ted_save_file, edit:dword, file:dword, f_name:dword
1457 IgorA 4082
  pushad
4083
  mov edi,dword[edit]
4084
 
4085
  stdcall ted_can_save,edi
4086
  cmp al,0
2102 IgorA 4087
;  je .no_save
1457 IgorA 4088
 
4089
  mov ecx,ted_max_chars
1489 IgorA 4090
  invoke mem.alloc,ecx
1457 IgorA 4091
  push eax ;запоминаем указатель на выделенную память
4092
 
4093
  mov edx,ted_tex
4094
  xor ecx,ecx
4095
  @@:
4096
    call ted_iterat_next
4097
    cmp edx,ted_tex_1
4098
    jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
4099
    mov bl,[edx]
4100
    mov byte[eax],bl
4101
    inc eax
4102
    inc ecx
4103
    jmp @b
4104
  @@:
4105
 
4106
  cmp ecx,0
4107
  je @f
4108
    mov ebx,dword[file]
4109
    pop eax ;записываем указатель на выделенную память
4110
    mov dword[ebx+16],eax
4111
    push eax ;обратно запоминаем указатель на выделенную память
4112
    mov eax,70
4113
    mov dword[ebx], 2
4114
    mov dword[ebx+4], 0
4115
    mov dword[ebx+8], 0
4116
    mov dword[ebx+12], ecx
4117
    mov  byte[ebx+20], 0
4118
    push dword[f_name]
4119
    pop dword[ebx+21]
4120
    int 0x40
4121
 
4122
    mov ted_err_save,al
4123
 
4124
    cmp eax,0
4125
    je .no_msg
4126
;    cmp eax,6
4127
;    je @f
4128
      cmp ax,10
4129
      jl .zifra_0_9
4130
	mov al,'?'
4131
	sub ax,48
4132
      .zifra_0_9:
4133
      add ax,48
4134
cmp ted_fun_save_err,0
4135
je @f
4136
call ted_fun_save_err
4137
      jmp @f
4138
    .no_msg:
4139
    m2m ted_tim_ls,ted_tim_ch
4140
  @@:
4141
 
4142
  pop ecx ;записываем указатель на выделенную память
1489 IgorA 4143
  invoke mem.free,ecx
1457 IgorA 4144
  .no_save:
4145
  popad
4146
  ret
4147
endp
4148
}