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