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