Rev 8932 | 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 ebx,ted_tex |
||
9485 | IgorA | 1267 | mov ecx,ted_max_chars |
1268 | call ted_mem_resize.no_2 |
||
1269 | sub edx,ebx |
||
1270 | add edx,ted_tex |
||
1271 | mov ted_ptr_free_symb,edx |
||
1464 | IgorA | 1272 | pop ecx ebx eax |
1273 | @@: |
||
1274 | ret |
||
1275 | endp |
||
1276 | |||
1277 | ;input: |
||
1457 | IgorA | 1278 | ; ecx = position to free insert cell |
1279 | ; edx = pointer to sumbol, when insert |
||
2324 | IgorA | 1280 | ; esi = added symbol |
1457 | IgorA | 1281 | ; edi = pointer to tedit struct |
1282 | ;output: |
||
1283 | ; ecx = position to inserted cell |
||
6274 | IgorA | 1284 | align 16 |
1457 | IgorA | 1285 | ted_char_add: |
6256 | IgorA | 1286 | .loop_b: |
1287 | cmp ecx,ted_tex_end |
||
1288 | jge .end_f |
||
7583 | IgorA | 1289 | cmp dword[ecx+symbol.tc],0 |
6256 | IgorA | 1290 | jne @f |
7583 | IgorA | 1291 | cmp dword[ecx+symbol.td],0 |
6256 | IgorA | 1292 | je .loop_e |
1293 | @@: |
||
1294 | add ecx,sizeof.symbol |
||
1295 | jmp .loop_b |
||
1296 | align 4 |
||
1297 | .loop_e: |
||
1457 | IgorA | 1298 | |
6256 | IgorA | 1299 | push eax ebx |
1300 | mov eax,ted_tim_ch |
||
7583 | IgorA | 1301 | mov [ecx+symbol.tc],eax |
6256 | IgorA | 1302 | mov ax,si |
1303 | mov byte[ecx],al |
||
1457 | IgorA | 1304 | |
6256 | IgorA | 1305 | call ted_get_text_arr_index ; *** eax=pos *** |
7583 | IgorA | 1306 | mov [ecx+symbol.perv],eax ;tex[i].perv=pos; |
1307 | m2m dword[ecx+symbol.next],dword[edx+symbol.next] ;tex[i].next=tex[pos].next; |
||
1457 | IgorA | 1308 | |
6256 | IgorA | 1309 | push edx |
1310 | mov edx,ecx |
||
1311 | call ted_get_text_arr_index ; *** eax=i *** |
||
1312 | pop edx |
||
1457 | IgorA | 1313 | |
7583 | IgorA | 1314 | mov [edx+symbol.next],eax ;tex[pos].next=i; // ссылки перенаправляем |
1315 | mov ebx,[ecx+symbol.next] |
||
6256 | IgorA | 1316 | ConvertIndexToPointer ebx |
7583 | IgorA | 1317 | mov [ebx+symbol.perv],eax ;tex[tex[i].next].perv=i; // ... |
6256 | IgorA | 1318 | pop ebx eax |
1457 | IgorA | 1319 | |
6256 | IgorA | 1320 | .end_f: |
1321 | call ted_text_colored |
||
1322 | ret |
||
1457 | IgorA | 1323 | |
4308 | IgorA | 1324 | ;description: |
1325 | ; функция для смены кодировок |
||
1326 | ;input: |
||
1327 | ; table - таблица для перекодировки |
||
6274 | IgorA | 1328 | align 16 |
4308 | IgorA | 1329 | proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword |
6274 | IgorA | 1330 | mov edi,[edit] |
7497 | IgorA | 1331 | mov esi,[table] |
4308 | IgorA | 1332 | mov edx,ted_tex |
1333 | .cycle: |
||
1334 | ;переходим на следующий символ |
||
7583 | IgorA | 1335 | mov edx,[edx+symbol.next] |
4308 | IgorA | 1336 | cmp edx,1 |
1337 | jle .end_text |
||
1338 | imul edx,sizeof.symbol |
||
1339 | add edx,ted_tex |
||
1457 | IgorA | 1340 | |
4308 | IgorA | 1341 | movzx eax,byte[edx] |
1342 | add eax,esi |
||
1343 | mov al,byte[eax] |
||
1344 | cmp al,0 |
||
1345 | je @f |
||
1346 | mov byte[edx],al ;меняем кодировку символа |
||
1347 | @@: |
||
1348 | jmp .cycle |
||
1349 | .end_text: |
||
1350 | ;cmp esi,0 |
||
1351 | ;je @f |
||
1352 | stdcall ted_draw,edi ;обновляем окно |
||
1353 | ;@@: |
||
1354 | ret |
||
1355 | endp |
||
1356 | |||
1457 | IgorA | 1357 | ;input: |
1358 | ; edi = pointer to tedit struct |
||
1359 | ;output: |
||
1360 | ; esi = count converted symbols |
||
1361 | ;description: |
||
1362 | ; Функция используется для смены регистра выбранных символов |
||
6274 | IgorA | 1363 | align 16 |
2324 | IgorA | 1364 | proc ted_convert_sel_text, conv_fun:dword |
7576 | IgorA | 1365 | locals |
1366 | conv_cou dd ? |
||
1367 | endl |
||
1368 | mov dword[conv_cou],0 |
||
1369 | pushad |
||
1457 | IgorA | 1370 | |
7576 | IgorA | 1371 | call ted_is_select |
1372 | or al,al |
||
1373 | jz .end_f |
||
1374 | call ted_set_undo |
||
1375 | call ted_sel_normalize |
||
1457 | IgorA | 1376 | |
7576 | IgorA | 1377 | mov esi,ted_seln_x0 |
1378 | mov ecx,ted_seln_y0 |
||
1379 | call ted_get_pos_by_coords |
||
1380 | mov eax,edx |
||
1381 | mov esi,ted_seln_x1 |
||
1382 | mov ecx,ted_seln_y1 |
||
1383 | call ted_get_pos_by_coords |
||
1384 | ;call ted_get_text_perv_pos |
||
1385 | mov ebx,edx |
||
1457 | IgorA | 1386 | |
7576 | IgorA | 1387 | cmp eax,ebx |
1388 | je .end_f |
||
1457 | IgorA | 1389 | |
7576 | IgorA | 1390 | inc ted_tim_ch |
1391 | mov edx,eax ;i=p0; |
||
1392 | mov ecx,ted_ptr_free_symb |
||
1393 | @@: |
||
1394 | push eax |
||
1395 | mov al,byte[edx] |
||
1396 | call dword[conv_fun] ;преобразование символа |
||
1397 | mov esi,eax |
||
1398 | cmp byte[edx],al |
||
1399 | pop eax |
||
1400 | je .no_change |
||
7583 | IgorA | 1401 | m2m dword[edx+symbol.td],ted_tim_ch |
7576 | IgorA | 1402 | call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos); |
1403 | call ted_get_text_next_pos ;go to added symbol |
||
1404 | inc dword[conv_cou] |
||
1405 | .no_change: |
||
1457 | IgorA | 1406 | |
7576 | IgorA | 1407 | call ted_iterat_next |
1408 | cmp edx,ted_tex |
||
1409 | je @f |
||
1410 | cmp edx,ebx |
||
1411 | jne @b |
||
1412 | @@: |
||
1413 | cmp dword[conv_cou],0 |
||
1414 | jne @f |
||
1415 | dec ted_tim_ch |
||
1416 | @@: |
||
1417 | .end_f: |
||
1418 | popad |
||
8036 | IgorA | 1419 | mov esi,[conv_cou] |
7576 | IgorA | 1420 | ret |
1457 | IgorA | 1421 | endp |
1422 | |||
1423 | ;output: |
||
1424 | ; bl = 0 - no delete |
||
1425 | ; bl = 1 - delete |
||
6274 | IgorA | 1426 | align 16 |
6256 | IgorA | 1427 | proc ted_text_del uses ecx edx edi, edit:dword, del_opt:dword |
6274 | IgorA | 1428 | mov edi,[edit] |
7497 | IgorA | 1429 | mov ebx,[del_opt] |
1457 | IgorA | 1430 | |
6256 | IgorA | 1431 | xor cl,cl |
1432 | test ebx,ted_opt_ed_move_cursor |
||
1433 | jz @f |
||
1434 | call ted_cur_move_left |
||
1435 | cmp dl,0 |
||
1436 | je .no_del |
||
1437 | @@: |
||
1438 | call ted_get_pos_by_cursor |
||
1439 | cmp ted_gp_opt,1 |
||
1440 | je .no_del |
||
1441 | test ebx,ted_opt_ed_change_time |
||
1442 | jz @f |
||
1443 | inc ted_tim_ch |
||
1444 | @@: |
||
7583 | IgorA | 1445 | m2m dword[edx+symbol.td], ted_tim_ch |
6256 | IgorA | 1446 | mov cl,1 |
1447 | .no_del: |
||
1448 | mov bl,cl |
||
1449 | ret |
||
1457 | IgorA | 1450 | endp |
1451 | |||
1452 | ;input: |
||
1453 | ; edi = pointer to tedit struct |
||
1454 | ;output: |
||
1455 | ; al = 1 if delete |
||
1456 | ;description: |
||
1457 | ; Функция удаляет выделенный текст |
||
6274 | IgorA | 1458 | align 16 |
6087 | IgorA | 1459 | proc ted_sel_text_del uses ebx ecx edx esi, del_opt:dword |
1457 | IgorA | 1460 | call ted_is_select |
7576 | IgorA | 1461 | or al,al |
1462 | jz .end_f |
||
1457 | IgorA | 1463 | call ted_sel_normalize |
1464 | |||
1465 | mov esi,ted_seln_x1 |
||
1466 | mov ecx,ted_seln_y1 |
||
1467 | call ted_get_pos_by_coords |
||
1468 | mov ebx,edx |
||
1469 | |||
1470 | mov esi,ted_seln_x0 |
||
1471 | mov ecx,ted_seln_y0 |
||
1472 | call ted_get_pos_by_coords |
||
1473 | |||
1474 | test dword[del_opt],ted_opt_ed_change_time |
||
1475 | jz @f |
||
1476 | inc ted_tim_ch |
||
1477 | @@: |
||
1478 | cmp edx,ted_tex |
||
1479 | je @f |
||
1480 | cmp edx,ebx ;if(i==te)break; |
||
1481 | je @f |
||
7583 | IgorA | 1482 | m2m dword[edx+symbol.td],ted_tim_ch |
1457 | IgorA | 1483 | mov esi,ted_opt_ed_change_time |
1484 | not esi |
||
1485 | and dword[del_opt],esi ;n_tim=false; |
||
1486 | call ted_iterat_next |
||
1487 | jmp @b |
||
6256 | IgorA | 1488 | align 4 |
1457 | IgorA | 1489 | @@: |
1490 | test dword[del_opt],ted_opt_ed_change_time |
||
1491 | jz @f |
||
1492 | dec ted_tim_ch |
||
1493 | xor al,al |
||
1494 | @@: |
||
1495 | test dword[del_opt],ted_opt_ed_change_time |
||
1496 | jnz @f |
||
1497 | mov ecx,ted_seln_x0 |
||
1498 | mov edx,ted_seln_y0 |
||
1499 | call ted_go_to_pos |
||
1500 | mov ted_sel_x0,0 |
||
1501 | mov ted_sel_y0,0 |
||
1502 | mov ted_sel_x1,0 |
||
1503 | mov ted_sel_y1,0 |
||
1504 | @@: |
||
1505 | .end_f: |
||
1506 | ret |
||
1507 | endp |
||
1508 | |||
1509 | |||
1510 | ;input: |
||
1511 | ; eax = pointer to begin select |
||
1512 | ; ebx = pointer to end select |
||
1513 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 1514 | align 16 |
1457 | IgorA | 1515 | ted_revers: |
6087 | IgorA | 1516 | cmp eax,ebx |
1517 | jne @f |
||
1518 | ret |
||
1519 | @@: |
||
1457 | IgorA | 1520 | |
6087 | IgorA | 1521 | push ecx edx |
1457 | IgorA | 1522 | |
6087 | IgorA | 1523 | mov edx,ted_tex_1 |
1524 | cmp edx,ebx ;if(p1==1)p1=tex[1].perv; |
||
1525 | jne @f |
||
1526 | call ted_get_text_perv_pos |
||
1527 | mov ebx,edx |
||
1528 | @@: |
||
1457 | IgorA | 1529 | |
6087 | IgorA | 1530 | push esi |
7583 | IgorA | 1531 | mov edx,[eax+symbol.perv] ; *** edx = tex[p0].perv *** |
6087 | IgorA | 1532 | ConvertIndexToPointer edx |
7583 | IgorA | 1533 | add edx,symbol.next |
1534 | mov ecx,[edx] ;ecx = tex[tex[p0].perv].next |
||
1457 | IgorA | 1535 | |
7583 | IgorA | 1536 | mov esi,[ebx+symbol.next] ; *** esi = tex[p1].next *** |
6087 | IgorA | 1537 | ConvertIndexToPointer esi |
7583 | IgorA | 1538 | add esi,symbol.perv |
1539 | m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv |
||
1457 | IgorA | 1540 | |
7583 | IgorA | 1541 | mov [esi],ecx ;tex[tex[p1].next].perv = ecx |
6087 | IgorA | 1542 | pop esi |
1457 | IgorA | 1543 | |
7583 | IgorA | 1544 | mov ecx,[eax+symbol.perv] ;ecx = tex[p0].perv |
1545 | m2m dword[eax+symbol.perv],dword[ebx+symbol.next] ;tex[p0].perv = tex[p1].next |
||
1546 | mov [ebx+symbol.next],ecx ;tex[p1].next = ecx |
||
1457 | IgorA | 1547 | |
6087 | IgorA | 1548 | mov edx,eax ;i=p0; |
1549 | @@: |
||
7583 | IgorA | 1550 | mov ecx,[edx+symbol.next] ;ecx = tex[i].next |
1551 | m2m dword[edx+symbol.next],dword[edx+symbol.perv] ;tex[i].next = tex[i].perv |
||
1552 | mov [edx+symbol.perv],ecx ;tex[i].perv = ecx |
||
6087 | IgorA | 1553 | cmp edx,ebx ;if(i==p1)break; |
1554 | je @f |
||
1457 | IgorA | 1555 | ; --- |
1556 | ;cmp edx,ted_tex |
||
1557 | ;je @f |
||
1558 | ; --- |
||
7583 | IgorA | 1559 | mov edx,ecx ;i = ecx |
6087 | IgorA | 1560 | ConvertIndexToPointer edx |
1561 | jmp @b |
||
1562 | @@: |
||
1563 | pop edx ecx |
||
1564 | call ted_text_colored |
||
1565 | ret |
||
1457 | IgorA | 1566 | |
1567 | |||
1568 | ;input: |
||
1569 | ; edi = pointer to tedit struct |
||
1570 | ;output: |
||
1571 | ; dl = 0 not move |
||
1572 | ; dl = 2 if move up |
||
1573 | ; dl = 8 if scroll move up |
||
6274 | IgorA | 1574 | align 16 |
1457 | IgorA | 1575 | ted_cur_move_up: |
1576 | cmp ted_cur_y,0 |
||
1577 | je @f |
||
1578 | dec ted_cur_y |
||
1579 | mov dl,2 |
||
1580 | ret |
||
1581 | @@: |
||
1582 | push eax |
||
1583 | mov eax,ted_scr_w |
||
1584 | cmp dword[eax+sb_offs_position],0 |
||
1585 | je @f |
||
1586 | dec dword[eax+sb_offs_position] |
||
1587 | mov dl,8 |
||
1588 | jmp .ret_f |
||
1589 | @@: |
||
1590 | mov dl,0 |
||
1591 | .ret_f: |
||
1592 | pop eax |
||
1593 | ret |
||
1594 | |||
1595 | ;input: |
||
1596 | ; edi = pointer to tedit struct |
||
1597 | ;output: |
||
1598 | ; dl = 0 not move |
||
1599 | ; dl = 2 if move down |
||
1600 | ; dl = 8 if scroll move down |
||
6274 | IgorA | 1601 | align 16 |
1457 | IgorA | 1602 | ted_cur_move_down: |
1603 | push eax ebx |
||
1604 | mov ebx,ted_scr_w |
||
7497 | IgorA | 1605 | xor dl,dl |
1606 | mov eax,[ebx+sb_offs_cur_area] |
||
1457 | IgorA | 1607 | dec eax |
1608 | cmp ted_cur_y,eax |
||
1609 | jge @f |
||
1610 | inc ted_cur_y |
||
1611 | mov dl,2 |
||
1612 | jmp .ret_f |
||
1613 | @@: |
||
1614 | mov eax,ted_cur_y |
||
7497 | IgorA | 1615 | add eax,[ebx+sb_offs_position] |
1457 | IgorA | 1616 | inc eax |
7497 | IgorA | 1617 | cmp [ebx+sb_offs_max_area],eax |
1457 | IgorA | 1618 | jle @f |
1619 | inc dword[ebx+sb_offs_position] |
||
1620 | mov dl,8 |
||
1621 | @@: |
||
1622 | .ret_f: |
||
1623 | pop ebx eax |
||
1624 | ret |
||
1625 | |||
1626 | |||
1627 | ;input: |
||
1628 | ; edi = pointer to tedit struct |
||
1629 | ;output: |
||
1630 | ; dl = 0 not move |
||
1631 | ; dl = 1 if move up |
||
6274 | IgorA | 1632 | align 16 |
1457 | IgorA | 1633 | ted_cur_move_page_up: |
7497 | IgorA | 1634 | push eax ebx |
1635 | mov ebx,ted_scr_w |
||
1636 | mov eax,[ebx+sb_offs_cur_area] |
||
1637 | xor dl,dl |
||
1638 | cmp eax,[ebx+sb_offs_position] |
||
1639 | jg @f |
||
1640 | sub [ebx+sb_offs_position],eax |
||
1641 | mov dl,1 |
||
1642 | @@: |
||
1643 | cmp dword[ebx+sb_offs_position],0 |
||
1644 | je @f |
||
1645 | cmp dl,1 |
||
1646 | je @f |
||
1647 | mov dword[ebx+sb_offs_position],0 |
||
1648 | mov dl,1 |
||
1649 | @@: |
||
1650 | pop ebx eax |
||
1651 | ret |
||
1457 | IgorA | 1652 | |
1653 | ;input: |
||
1654 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 1655 | align 16 |
1457 | IgorA | 1656 | ted_cur_move_page_down: |
1657 | push eax ebx ecx |
||
1658 | mov ecx,ted_scr_w |
||
1659 | |||
1660 | xor dl,dl |
||
7497 | IgorA | 1661 | mov eax,[ecx+sb_offs_max_area] |
1662 | sub eax,[ecx+sb_offs_cur_area] |
||
1663 | cmp [ecx+sb_offs_position],eax |
||
1457 | IgorA | 1664 | jge @f |
7497 | IgorA | 1665 | mov ebx,[ecx+sb_offs_cur_area] |
1666 | add [ecx+sb_offs_position],ebx |
||
1457 | IgorA | 1667 | mov dl,1 |
1668 | mov dword[ecx+sb_offs_redraw],1 |
||
7497 | IgorA | 1669 | cmp [ecx+sb_offs_position],eax |
1457 | IgorA | 1670 | jle @f |
7497 | IgorA | 1671 | mov [ecx+sb_offs_position],eax |
1457 | IgorA | 1672 | @@: |
1673 | pop ecx ebx eax |
||
1674 | ret |
||
1675 | |||
1676 | ;input: |
||
1677 | ; edi = pointer to tedit struct |
||
1678 | ;output: |
||
1679 | ; dl = 0 not move |
||
1680 | ; dl = 1 if move left |
||
1681 | ; dl = 3 if move left and up |
||
1682 | ; dl = 8 if scroll move up |
||
6274 | IgorA | 1683 | align 16 |
1457 | IgorA | 1684 | ted_cur_move_left: |
1685 | cmp ted_cur_x,0 |
||
1686 | je @f |
||
1687 | dec ted_cur_x |
||
1688 | mov dl,1 |
||
1689 | ret |
||
1690 | @@: |
||
1691 | push eax |
||
1692 | mov eax,ted_scr_h |
||
1693 | cmp dword[eax+sb_offs_position],0 |
||
1694 | je @f |
||
1695 | dec dword[eax+sb_offs_position] |
||
1696 | mov dl,8 |
||
1697 | jmp .ret_f |
||
1698 | @@: |
||
1699 | cmp ted_cur_y,0 |
||
1700 | jne @f |
||
1701 | mov eax,ted_scr_w |
||
1702 | mov dl,0 |
||
1703 | cmp dword[eax+sb_offs_position],0 |
||
1704 | je .ret_f |
||
1705 | dec dword[eax+sb_offs_position] |
||
1706 | call ted_scroll_set_redraw |
||
1707 | call ted_cur_move_x_last_char |
||
1708 | mov dl,8 |
||
1709 | jmp .ret_f |
||
1710 | @@: |
||
1711 | cmp ted_cur_y,0 |
||
1712 | je @f |
||
1713 | dec ted_cur_y |
||
1714 | call ted_cur_move_x_last_char |
||
1715 | cmp dl,8 |
||
1716 | je .ret_f |
||
1717 | mov dl,3 |
||
1718 | jmp .ret_f |
||
1719 | @@: |
||
1720 | mov dl,0 |
||
1721 | .ret_f: |
||
1722 | pop eax |
||
1723 | ret |
||
1724 | |||
1725 | ;input: |
||
1726 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 1727 | align 16 |
1457 | IgorA | 1728 | ted_cur_move_right: |
1729 | push eax ebx |
||
1730 | mov eax,ted_scr_h |
||
1731 | xor dl,dl |
||
7497 | IgorA | 1732 | mov ebx,[eax+sb_offs_cur_area] |
1457 | IgorA | 1733 | cmp ted_cur_x,ebx |
1734 | jge @f |
||
1735 | inc ted_cur_x |
||
1736 | mov dl,1 |
||
1737 | jmp .ret_f |
||
1738 | @@: |
||
1739 | inc dword[eax+sb_offs_position] |
||
1740 | mov dl,8 |
||
1741 | .ret_f: |
||
1742 | pop ebx eax |
||
1743 | ret |
||
1744 | |||
1745 | ;input: |
||
1746 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 1747 | align 16 |
1457 | IgorA | 1748 | ted_cur_move_x_last_char: |
1749 | ;[hScr.position] |
||
1750 | ;[hScr.cur_area] |
||
1751 | ;dl-??? |
||
1752 | push eax ebx ecx |
||
1753 | mov eax,ted_cur_y |
||
1754 | mov ecx,ted_scr_w |
||
7497 | IgorA | 1755 | add eax,[ecx+sb_offs_position] |
1457 | IgorA | 1756 | call ted_strlen |
1757 | xor dl,dl |
||
1758 | |||
1759 | mov ecx,ted_scr_h |
||
7497 | IgorA | 1760 | cmp ebx,[ecx+sb_offs_position] |
1457 | IgorA | 1761 | jge @f |
1762 | mov dl,8 |
||
7497 | IgorA | 1763 | mov [ecx+sb_offs_position],ebx |
1457 | IgorA | 1764 | @@: |
7497 | IgorA | 1765 | sub ebx,[ecx+sb_offs_position] |
1457 | IgorA | 1766 | |
7497 | IgorA | 1767 | cmp ebx,[ecx+sb_offs_cur_area] |
1457 | IgorA | 1768 | jle @f ; b---[---]---e |
7497 | IgorA | 1769 | add [ecx+sb_offs_position],ebx |
1770 | mov ebx,[ecx+sb_offs_cur_area] |
||
1771 | sub [ecx+sb_offs_position],ebx |
||
1457 | IgorA | 1772 | mov dl,8 |
1773 | @@: |
||
1774 | mov ted_cur_x,ebx |
||
1775 | pop ecx ebx eax |
||
1776 | ret |
||
1777 | |||
1778 | ;input: |
||
1779 | ; edi = pointer to tedit struct |
||
1780 | ;output: |
||
1781 | ; dl = 0 not move |
||
1782 | ; dl = 1 move cursor |
||
1783 | ; dl = 8 move cursor and scroll |
||
6274 | IgorA | 1784 | align 16 |
1457 | IgorA | 1785 | ted_cur_move_x_first_char: |
1786 | xor dl,dl |
||
1787 | cmp ted_cur_x,0 |
||
1788 | je @f |
||
1789 | mov ted_cur_x,0 |
||
1790 | mov dl,1 |
||
1791 | @@: |
||
1792 | push eax |
||
1793 | mov eax,ted_scr_h |
||
1794 | cmp dword[eax+sb_offs_position],0 |
||
1795 | je @f |
||
1796 | mov dword[eax+sb_offs_position],0 |
||
1797 | mov dl,8 |
||
1798 | @@: |
||
1799 | pop eax |
||
1800 | ret |
||
1801 | |||
1802 | ;input: |
||
1803 | ; edx = pointer to symbol struct |
||
1804 | ; edi = pointer to tedit struct |
||
1805 | ;output: |
||
1806 | ; eax = array index |
||
6274 | IgorA | 1807 | align 16 |
1457 | IgorA | 1808 | ted_get_text_arr_index: |
1809 | push ecx edx |
||
1810 | mov eax,edx |
||
1811 | sub eax,ted_tex |
||
1812 | xor edx,edx |
||
1813 | mov ecx,sizeof.symbol |
||
1814 | div ecx |
||
1815 | pop edx ecx |
||
1816 | ret |
||
1817 | |||
1818 | ;input: |
||
1819 | ; edx = pointer to symbol struct |
||
1820 | ; edi = pointer to tedit struct |
||
1821 | ;output: |
||
1822 | ; edx = pointer to 'perv' struct |
||
6274 | IgorA | 1823 | align 16 |
1457 | IgorA | 1824 | ted_get_text_perv_pos: |
7583 | IgorA | 1825 | mov edx,[edx+symbol.perv] |
1457 | IgorA | 1826 | imul edx,sizeof.symbol |
1827 | add edx,ted_tex |
||
1828 | ret |
||
1829 | |||
1830 | ;input: |
||
1831 | ; edx = pointer to symbol struct |
||
1832 | ;output: |
||
1833 | ; edx = pointer to 'next' symbol struct |
||
6274 | IgorA | 1834 | align 16 |
1457 | IgorA | 1835 | ted_get_text_next_pos: |
7583 | IgorA | 1836 | mov edx,[edx+symbol.next] |
1457 | IgorA | 1837 | imul edx,sizeof.symbol |
1838 | add edx,ted_tex |
||
1839 | ret |
||
1840 | |||
1841 | ;input: |
||
1842 | ; edi = pointer to tedit struct |
||
1843 | ;output: |
||
1844 | ; edx = symbol under cursor |
||
1845 | ; ted_gp_opt = 1,2 |
||
1846 | ; edx = tex[1].perv if error |
||
1847 | ; ted_gp_opt = 0 |
||
6274 | IgorA | 1848 | align 16 |
1457 | IgorA | 1849 | ted_get_pos_by_cursor: |
1850 | push eax ecx esi |
||
1851 | mov esi,ted_cur_x |
||
1852 | mov eax,ted_scr_h |
||
7497 | IgorA | 1853 | add esi,[eax+sb_offs_position] |
1457 | IgorA | 1854 | mov ecx,ted_cur_y |
1855 | mov eax,ted_scr_w |
||
7497 | IgorA | 1856 | add ecx,[eax+sb_offs_position] |
1457 | IgorA | 1857 | call ted_get_pos_by_coords |
1858 | pop esi ecx eax |
||
1859 | ret |
||
1860 | |||
1861 | ;input: |
||
1862 | ; esi = XPos |
||
1863 | ; ecx = YPos |
||
1864 | ; edi = pointer to tedit struct |
||
1865 | ;output: |
||
1866 | ; edx = symbol under cursor |
||
1867 | ; ted_gp_opt = 1 if found text line |
||
1868 | ; ted_gp_opt = 2 if found text line and column |
||
1869 | ; edx = tex[1] if error |
||
1870 | ; ted_gp_opt = 0 if text no found |
||
6274 | IgorA | 1871 | align 16 |
7577 | IgorA | 1872 | proc ted_get_pos_by_coords uses eax ebx |
1873 | xor eax,eax ;Row |
||
1874 | xor ebx,ebx ;Col |
||
1457 | IgorA | 1875 | mov ted_gp_opt,0 |
1876 | mov edx,ted_tex |
||
1877 | @@: |
||
1878 | call ted_iterat_next |
||
1879 | cmp edx,ted_tex_1 |
||
1880 | jle @f |
||
1881 | cmp ebx,esi |
||
1882 | jne .u1_0 ;Col <> ted_cur_x |
||
1883 | mov ted_gp_opt,1 |
||
1884 | cmp eax,ecx |
||
1885 | jge @f ; Row >= ted_cur_y |
||
1886 | .u1_0: |
||
1887 | mov ted_gp_opt,0 |
||
1888 | inc ebx |
||
1889 | cmp byte [edx],13 |
||
1890 | jne @b |
||
1891 | cmp eax,ecx |
||
1892 | jge @f ; Row >= ted_cur_y |
||
1893 | inc eax |
||
1894 | xor ebx,ebx |
||
1895 | jmp @b |
||
1896 | @@: |
||
1897 | cmp eax,ecx |
||
1898 | jne @f ; Row = ted_cur_y |
||
1899 | inc ted_gp_opt |
||
1900 | @@: |
||
1901 | cmp ted_gp_opt,0 |
||
1902 | jne @f |
||
1903 | mov edx,ted_tex_1 |
||
1904 | ;call ted_get_text_perv_pos |
||
1905 | @@: |
||
1906 | ret |
||
7577 | IgorA | 1907 | endp |
1457 | IgorA | 1908 | |
1909 | ;input: |
||
1910 | ; eax = Row |
||
1911 | ; edi = pointer to tedit struct |
||
1912 | ;output: |
||
1913 | ; ebx = str len |
||
6274 | IgorA | 1914 | align 16 |
1457 | IgorA | 1915 | ted_strlen: |
1916 | push edx ecx |
||
1917 | ;ecx = Row, from cycle |
||
1918 | |||
1919 | xor ebx,ebx |
||
1920 | xor ecx,ecx |
||
1921 | mov edx,ted_tex |
||
1922 | @@: |
||
1923 | call ted_iterat_next |
||
1924 | cmp edx,ted_tex_1 |
||
1925 | jle @f |
||
1926 | inc ebx |
||
1927 | cmp byte [edx],13 |
||
1928 | jne @b |
||
1929 | dec ebx ;lenght minus 1 sumbol to paragraph |
||
1930 | cmp eax,ecx |
||
1931 | je @f |
||
1932 | xor ebx,ebx |
||
1933 | inc ecx |
||
1934 | jmp @b |
||
1935 | @@: |
||
1936 | |||
1937 | cmp eax,ecx |
||
1938 | je @f |
||
1939 | xor ebx,ebx |
||
1940 | @@: |
||
1941 | |||
1942 | pop ecx edx |
||
1943 | ret |
||
1944 | |||
1945 | |||
1946 | ;input: |
||
1947 | ; edx = symbol position |
||
1948 | ; edi = pointer to tedit struct |
||
1949 | ;output: |
||
1950 | ; eax = number of line |
||
1951 | ; ebx = symbol position in line |
||
6274 | IgorA | 1952 | align 16 |
1457 | IgorA | 1953 | ted_get_text_coords: |
8532 | IgorA | 1954 | push edx |
1955 | xor eax,eax |
||
1956 | xor ebx,ebx |
||
1957 | @@: |
||
1958 | call ted_iterat_perv |
||
1457 | IgorA | 1959 | |
8532 | IgorA | 1960 | or eax,eax |
1961 | jnz .no_col_mov |
||
1962 | inc ebx |
||
1963 | .no_col_mov: |
||
1457 | IgorA | 1964 | |
8532 | IgorA | 1965 | cmp edx,ted_tex_1 |
1966 | jle @f |
||
1967 | cmp byte [edx],13 |
||
1968 | jne @b |
||
1969 | inc eax |
||
1970 | jmp @b |
||
1971 | @@: |
||
1972 | dec ebx |
||
1973 | pop edx |
||
1974 | ret |
||
1457 | IgorA | 1975 | |
1976 | ;input: |
||
1977 | ; edi = pointer to tedit struct |
||
1978 | ;output: |
||
1979 | ; eax = num lines |
||
6274 | IgorA | 1980 | align 16 |
1457 | IgorA | 1981 | ted_get_num_lines: |
6087 | IgorA | 1982 | push edx |
1983 | mov eax,1 |
||
1984 | mov edx,ted_tex |
||
1985 | @@: |
||
1986 | call ted_iterat_next |
||
1987 | cmp edx,ted_tex_1 |
||
1988 | jle @f |
||
7579 | IgorA | 1989 | cmp byte[edx],13 |
6087 | IgorA | 1990 | jne @b |
1991 | inc eax |
||
1992 | jmp @b |
||
1993 | @@: |
||
1457 | IgorA | 1994 | ;... |
1995 | ;dec eax |
||
6087 | IgorA | 1996 | pop edx |
1997 | ret |
||
1457 | IgorA | 1998 | |
1999 | |||
2000 | ;input: |
||
2001 | ; edi = pointer to tedit struct |
||
2002 | ;description: |
||
2003 | ; отменяет отмененные действия, перед изменением документа |
||
6274 | IgorA | 2004 | align 16 |
1457 | IgorA | 2005 | proc ted_set_undo |
2348 | IgorA | 2006 | mov ted_drag_k,0 ;заканчиваем выделение от клавиатуры |
2007 | cmp ted_tim_undo,1 |
||
2008 | jl .no_work |
||
1457 | IgorA | 2009 | |
2348 | IgorA | 2010 | push eax ebx edx |
2011 | mov edx,ted_tex |
||
2012 | call ted_get_text_next_pos ;long i=tex[0].next; |
||
2013 | mov eax,ted_tim_undo |
||
2014 | sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo; |
||
2015 | mov eax,ted_tim_ch |
||
2016 | cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch) |
||
2017 | jle @f |
||
2018 | mov ted_tim_ls,0 |
||
2019 | @@: |
||
2020 | cmp edx,ted_tex_1 |
||
2021 | jle @f |
||
1457 | IgorA | 2022 | |
2348 | IgorA | 2023 | ;if(tex[i].tc>ted_tim_ch){ // если создание символа было отменено |
7036 | IgorA | 2024 | cmp [edx+symbol.tc],eax |
2348 | IgorA | 2025 | jle .no_u1 |
7583 | IgorA | 2026 | mov dword[edx+symbol.tc],0 |
2027 | mov dword[edx+symbol.td],0 |
||
1457 | IgorA | 2028 | |
7036 | IgorA | 2029 | mov ebx,[edx+symbol.perv] |
2348 | IgorA | 2030 | imul ebx,sizeof.symbol |
2031 | add ebx,ted_tex ;ebx=tex[i].perv |
||
7036 | IgorA | 2032 | m2m dword [ebx+symbol.next],dword [edx+symbol.next] ;tex[tex[i].perv].next=tex[i].next; |
1457 | IgorA | 2033 | |
7036 | IgorA | 2034 | mov ebx,[edx+symbol.next] |
2348 | IgorA | 2035 | imul ebx,sizeof.symbol |
2036 | add ebx,ted_tex ;ebx=tex[i].next |
||
7036 | IgorA | 2037 | m2m dword [ebx+symbol.perv],dword [edx+symbol.perv] ;tex[tex[i].next].perv=tex[i].perv; |
1457 | IgorA | 2038 | |
2348 | IgorA | 2039 | cmp ted_ptr_free_symb,edx |
2040 | jle .no_cor_free |
||
2041 | mov ted_ptr_free_symb,edx ;меняем указатель на свободный символ, для более быстрого поиска памяти |
||
2042 | .no_cor_free: |
||
2043 | mov edx,ebx ;оптимизируем по скорости (edx после вызова ted_get_text_next_pos будет равен ebx) |
||
2044 | jmp @b |
||
2045 | .no_u1: |
||
1457 | IgorA | 2046 | |
2348 | IgorA | 2047 | ;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // если удаление символа было отменено |
7036 | IgorA | 2048 | cmp [edx+symbol.td],eax |
2348 | IgorA | 2049 | jle .no_u2 |
7583 | IgorA | 2050 | mov dword[edx+symbol.td],0 |
2348 | IgorA | 2051 | .no_u2: |
1457 | IgorA | 2052 | |
2348 | IgorA | 2053 | call ted_get_text_next_pos |
2054 | jmp @b |
||
2055 | @@: |
||
2056 | mov ted_tim_undo,0 |
||
2057 | mov eax,ted_tim_co |
||
2058 | cmp ted_tim_ch,eax |
||
2059 | jge @f |
||
2060 | mov ted_tim_co,0 |
||
2061 | @@: |
||
2062 | pop edx ebx eax |
||
2063 | .no_work: |
||
2064 | ret |
||
1457 | IgorA | 2065 | endp |
2066 | |||
7579 | IgorA | 2067 | ;description: |
2068 | ; переход на указанную позицию |
||
1457 | IgorA | 2069 | ;input: |
7579 | IgorA | 2070 | ; row = номер строки |
2071 | ; col = символ |
||
2072 | align 16 |
||
2073 | proc ted_go_to_position uses ecx edx edi, edit:dword, row:dword, col:dword |
||
2074 | mov edi,[edit] |
||
2075 | ; подготовка строки |
||
2076 | mov edx,[row] |
||
2077 | call ted_get_num_lines |
||
2078 | cmp edx,eax |
||
2079 | jle @f |
||
2080 | mov edx,eax ;ограничение по строке max |
||
2081 | @@: |
||
2082 | dec edx |
||
2083 | cmp edx,0 |
||
2084 | jge @f |
||
2085 | xor edx,edx ;ограничение по строке min |
||
2086 | @@: |
||
2087 | ; подготовка символа |
||
2088 | mov ecx,[col] |
||
2089 | dec ecx |
||
2090 | cmp ecx,0 |
||
2091 | jge @f |
||
2092 | xor ecx,ecx |
||
2093 | @@: |
||
2094 | call ted_go_to_pos |
||
2095 | stdcall ted_draw,edi |
||
2096 | ret |
||
2097 | endp |
||
2098 | |||
2099 | ;input: |
||
1457 | IgorA | 2100 | ; ecx = Col |
2101 | ; edx = Row |
||
2102 | ; edi = pointer to tedit struct |
||
7576 | IgorA | 2103 | ;output: |
2104 | ; ecx = cursor x |
||
2105 | ; edx = cursor y |
||
6274 | IgorA | 2106 | align 16 |
1457 | IgorA | 2107 | ted_go_to_pos: |
7576 | IgorA | 2108 | push eax ebx |
2109 | mov eax,ted_scr_h |
||
2110 | sub ecx,[eax+sb_offs_position] |
||
7577 | IgorA | 2111 | cmp ecx,0 ;ted_cur_x < 0 |
7576 | IgorA | 2112 | jge @f |
2113 | add [eax+sb_offs_position],ecx ;прокрутка скроллинга влево |
||
2114 | xor ecx,ecx |
||
2115 | @@: |
||
2116 | mov ebx,5 ;5 - желаемый отступ слева |
||
2117 | cmp ecx,ebx |
||
2118 | jge .end0 |
||
2119 | sub ebx,ecx ;ebx - на сколько символов нужно сдвинуть курсор |
||
2120 | cmp [eax+sb_offs_position],ebx |
||
2121 | jge @f |
||
2122 | add ecx,[eax+sb_offs_position] |
||
2123 | mov dword[eax+sb_offs_position],0 |
||
2124 | jmp .end0 |
||
2125 | @@: |
||
2126 | sub [eax+sb_offs_position],ebx |
||
2127 | add ecx,ebx |
||
2128 | .end0: |
||
2129 | cmp ecx,[eax+sb_offs_cur_area] ;ted_cur_x > [.cur_area] |
||
2130 | jl .end1 |
||
2131 | mov ebx,ecx |
||
2132 | sub ebx,[eax+sb_offs_cur_area] |
||
2133 | inc ebx |
||
2134 | add [eax+sb_offs_position],ebx ;прокрутка скроллинга вправо |
||
2135 | sub ecx,ebx |
||
2136 | .end1: |
||
2137 | mov ted_cur_x,ecx |
||
2138 | |||
1457 | IgorA | 2139 | mov eax,ted_scr_w |
7497 | IgorA | 2140 | sub edx,[eax+sb_offs_position] |
7576 | IgorA | 2141 | cmp edx,0 ;ted_cur_y < 0 |
2142 | jge @f |
||
2143 | add [eax+sb_offs_position],edx ;прокрутка скроллинга вверх |
||
2144 | xor edx,edx |
||
2145 | jmp .end2 |
||
2146 | @@: |
||
7497 | IgorA | 2147 | cmp edx,[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area] |
7576 | IgorA | 2148 | jl .end2 |
1457 | IgorA | 2149 | mov ebx,edx |
7497 | IgorA | 2150 | sub ebx,[eax+sb_offs_cur_area] |
1457 | IgorA | 2151 | inc ebx |
7576 | IgorA | 2152 | add [eax+sb_offs_position],ebx ;прокрутка скроллинга вниз |
1457 | IgorA | 2153 | sub edx,ebx |
7576 | IgorA | 2154 | .end2: |
1457 | IgorA | 2155 | mov ted_cur_y,edx |
7576 | IgorA | 2156 | pop ebx eax |
1457 | IgorA | 2157 | ret |
2158 | |||
2159 | ;input: |
||
2160 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 2161 | align 16 |
1457 | IgorA | 2162 | ted_text_colored: |
7877 | IgorA | 2163 | push eax edx |
2164 | mov eax,ted_tim_ch |
||
2165 | sub eax,ted_tim_undo |
||
2166 | mov ted_tim_co,eax |
||
2167 | mov edx,ted_tex |
||
2168 | @@: |
||
2169 | call ted_iterat_next |
||
2170 | cmp edx,ted_tex_1 |
||
2171 | jle @f |
||
2172 | mov byte[edx+1],0 |
||
2173 | jmp @b |
||
2174 | @@: |
||
1457 | IgorA | 2175 | |
7877 | IgorA | 2176 | cmp ted_key_words_count,1 |
2177 | jl .no_colors |
||
2178 | mov edx,ted_tex |
||
2179 | @@: |
||
2180 | call ted_text_find_sel_color |
||
2181 | cmp edx,ted_tex_1 |
||
8932 | IgorA | 2182 | jg @b |
2183 | |||
2184 | xor ax,ax |
||
2185 | mov edx,ted_tex |
||
2186 | .cycle0: |
||
2187 | call ted_iterat_next |
||
2188 | cmp edx,ted_tex_1 |
||
7877 | IgorA | 2189 | jle .no_colors |
8932 | IgorA | 2190 | mov al,byte[edx+1] |
2191 | or al,al |
||
2192 | jz .cycle0 |
||
2193 | cmp ah,al |
||
2194 | jne @f |
||
2195 | mov byte[edx+1],0 ;слияние рядом стоящих слов одного цвета |
||
2196 | @@: |
||
2197 | shl ax,8 |
||
2198 | jmp .cycle0 |
||
7877 | IgorA | 2199 | .no_colors: |
2200 | pop edx eax |
||
2201 | ret |
||
1457 | IgorA | 2202 | |
2203 | |||
2204 | ;input: |
||
2205 | ; edx = pointer to start symbol |
||
2206 | ; edi = pointer to tedit struct |
||
2207 | ;output: |
||
2208 | ; edx = pointer to next symbol |
||
2209 | ;description: |
||
2210 | ; Функция для поиска и выделения подсвеченых слов |
||
6274 | IgorA | 2211 | align 16 |
6086 | IgorA | 2212 | proc ted_text_find_sel_color uses eax ebx ecx esi |
1457 | IgorA | 2213 | locals |
6086 | IgorA | 2214 | begPos dd ? ;начальная позиция |
2215 | endPos dd ? ;конечная позиция |
||
8533 | IgorA | 2216 | find db ? ;0 - не найдено, 1 - найдено, 2 - найдено в конце файла |
6086 | IgorA | 2217 | f_color db ? ;индекс цвета найденого слова |
1457 | IgorA | 2218 | endl |
2219 | ;eax = word_n текущий номер (позиция) проверяемого слова в списке |
||
2220 | ;ebx = для разных целей |
||
2221 | ;ecx = l_pos последний номер (позиция) подходящего слова в списке |
||
2222 | ;esi = для разных целей, номер проверяемого символа в слове |
||
6086 | IgorA | 2223 | mov dword[begPos],1 |
2224 | mov dword[endPos],1 |
||
2225 | mov byte[find],0 |
||
2226 | mov byte[f_color],1 |
||
7877 | IgorA | 2227 | .cycle0: |
6086 | IgorA | 2228 | call ted_iterat_next |
2229 | cmp edx,ted_tex_1 |
||
7877 | IgorA | 2230 | jle .cycle0end |
1457 | IgorA | 2231 | |
8533 | IgorA | 2232 | movzx eax,byte[edx] |
2233 | shl eax,2 ;eax*=4 |
||
6086 | IgorA | 2234 | add eax,ted_arr_key_pos |
7497 | IgorA | 2235 | mov eax,[eax] |
6086 | IgorA | 2236 | cmp eax,0 |
7877 | IgorA | 2237 | jl .cycle0 ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){ |
1457 | IgorA | 2238 | |
6086 | IgorA | 2239 | mov ecx,eax |
2240 | ;while(l_pos |
||
2241 | .wh_1b: |
||
2242 | cmp ecx,ted_key_words_count |
||
2243 | jge .wh_1e |
||
2244 | ColToIndexOffset ecx,esi |
||
2245 | mov bl,byte[esi] |
||
2246 | ColToIndexOffset eax,esi |
||
2247 | cmp bl,byte[esi] |
||
2248 | jne .wh_1e |
||
2249 | inc ecx |
||
2250 | jmp .wh_1b |
||
2251 | .wh_1e: |
||
1457 | IgorA | 2252 | |
7497 | IgorA | 2253 | mov [begPos],edx ;bP=i; |
6086 | IgorA | 2254 | mov esi,1 |
2255 | align 4 |
||
2256 | .wh_2b: ;while(1){ |
||
2257 | call ted_iterat_next |
||
1457 | IgorA | 2258 | |
6086 | IgorA | 2259 | ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c) |
7877 | IgorA | 2260 | @@: |
6086 | IgorA | 2261 | cmp ecx,eax |
7877 | IgorA | 2262 | jle @f |
6086 | IgorA | 2263 | dec ecx |
2264 | ColToIndexOffset ecx,ebx |
||
2265 | inc ecx |
||
2266 | ;cmp byte[ebx+esi],byte[edx] |
||
2267 | mov bl,byte[ebx+esi] |
||
2268 | cmp bl,byte[edx] |
||
7877 | IgorA | 2269 | je @f |
6086 | IgorA | 2270 | dec ecx |
7877 | IgorA | 2271 | jmp @b |
2272 | @@: |
||
1457 | IgorA | 2273 | |
6086 | IgorA | 2274 | ColToIndexOffset eax,ebx |
2275 | cmp byte[ebx+esi],0 |
||
2276 | jne .if_0 ;if(Col[word_n].Text[pos]==0){ |
||
7497 | IgorA | 2277 | mov [endPos],edx ;eP=i; |
6086 | IgorA | 2278 | ColToIndexOffset eax,ebx |
7497 | IgorA | 2279 | mov bl,[ebx+MAX_COLOR_WORD_LEN+7] |
2280 | mov [f_color],bl ;f_color=Col[word_n].color; |
||
1457 | IgorA | 2281 | |
6086 | IgorA | 2282 | mov byte[find],1 |
2283 | ColToIndexOffset eax,ebx ;... ebx = Col[word_n] |
||
7497 | IgorA | 2284 | mov bl,[ebx+MAX_COLOR_WORD_LEN+4] |
6086 | IgorA | 2285 | cmp bl,0 ;if(Col[word_n].wwo) |
2286 | je .if_2n |
||
2287 | push edx |
||
7497 | IgorA | 2288 | mov edx,[begPos] |
6086 | IgorA | 2289 | call ted_iterat_perv |
1457 | IgorA | 2290 | |
6086 | IgorA | 2291 | btr bx,0 ;1-1 |
7877 | IgorA | 2292 | jae @f ;if(Col[word_n].wwo&1) |
6086 | IgorA | 2293 | ;u1= !(isalnum(cont_s)||cont_s=='_') |
2294 | call isalnum |
||
7877 | IgorA | 2295 | jae @f |
6086 | IgorA | 2296 | mov byte[find],0 |
2297 | jmp .if_4e |
||
7877 | IgorA | 2298 | @@: |
1457 | IgorA | 2299 | |
6086 | IgorA | 2300 | btr bx,3 ;4-1 |
2301 | jae .if_4e ;if(Col[word_n].wwo&8) |
||
2302 | ;u1= !isalpha(cont_s); |
||
2303 | call isalpha |
||
2304 | jae .if_4e |
||
2305 | mov byte[find],0 |
||
2306 | .if_4e: |
||
1457 | IgorA | 2307 | |
7497 | IgorA | 2308 | mov edx,[endPos] |
6086 | IgorA | 2309 | ;call ted_iterat_next |
1457 | IgorA | 2310 | |
6086 | IgorA | 2311 | btr bx,1 ;2-1 |
7877 | IgorA | 2312 | jae @f ;if(Col[word_n].wwo&2) |
6086 | IgorA | 2313 | ;u1= !(isalnum(cont_s)||cont_s=='_') |
2314 | call isalnum |
||
7877 | IgorA | 2315 | jae @f |
6086 | IgorA | 2316 | mov byte[find],0 |
2317 | jmp .if_6e |
||
7877 | IgorA | 2318 | @@: |
1457 | IgorA | 2319 | |
6086 | IgorA | 2320 | btr bx,4 ;5-1 |
2321 | jae .if_6e ;if(Col[word_n].wwo&16) |
||
2322 | ;u1= !isalpha(cont_s); |
||
2323 | call isalpha |
||
2324 | jae .if_6e |
||
2325 | mov byte[find],0 |
||
2326 | .if_6e: |
||
1457 | IgorA | 2327 | |
6086 | IgorA | 2328 | btr bx,2 ;3-1 |
2329 | jae .if_7e ;if(Col[word_n].wwo&4) |
||
2330 | ColToIndexOffset eax,ebx |
||
2331 | mov bx,word[ebx+MAX_COLOR_WORD_LEN+5] |
||
2332 | call ted_iterat_next_pos_char |
||
2333 | cmp edx,ted_tex_1 |
||
7877 | IgorA | 2334 | jg @f |
2335 | ;если дошли до конца файла и не нашли символ конца разметки |
||
2336 | call ted_iterat_perv |
||
8533 | IgorA | 2337 | mov byte[find],2 |
7877 | IgorA | 2338 | @@: |
6086 | IgorA | 2339 | mov dword[endPos],edx |
2340 | .if_7e: |
||
1457 | IgorA | 2341 | |
6086 | IgorA | 2342 | pop edx |
2343 | .if_2n: |
||
2344 | ;if(i!=1){ // не конец документа |
||
2345 | ; cont_s=tex[eP].c; |
||
2346 | ; if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_'); // не букв.-числ. символ |
||
2347 | ; if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // не числ. символ |
||
2348 | ; if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc); |
||
1457 | IgorA | 2349 | |
6086 | IgorA | 2350 | cmp eax,ecx |
2351 | je .wh_2e ;if(word_n==l_pos) break; // do double - если слово точно последнее |
||
2352 | .if_0: |
||
1457 | IgorA | 2353 | |
6086 | IgorA | 2354 | cmp edx,ted_tex_1 |
2355 | jle .wh_2e ;if(i==1) break; |
||
1457 | IgorA | 2356 | |
6086 | IgorA | 2357 | ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c) |
2358 | .wh_4b: |
||
2359 | cmp ecx,eax |
||
2360 | jle .wh_4e |
||
2361 | ColToIndexOffset eax,ebx |
||
2362 | ;cmp byte[ebx+esi],byte[edx] |
||
2363 | mov bl,byte[ebx+esi] |
||
2364 | cmp bl,byte[edx] |
||
2365 | je .wh_4e |
||
2366 | inc eax |
||
2367 | jmp .wh_4b |
||
2368 | .wh_4e: |
||
1457 | IgorA | 2369 | |
6086 | IgorA | 2370 | cmp eax,ecx |
2371 | je .wh_2e;if(word_n==l_pos) break; |
||
2372 | inc esi ;pos++; |
||
2373 | jmp .wh_2b |
||
2374 | .wh_2e: |
||
1457 | IgorA | 2375 | |
8533 | IgorA | 2376 | cmp byte[find],0 ;if(fnd)break; |
2377 | jne .cycle0end |
||
7497 | IgorA | 2378 | mov edx,[begPos];i=bP; |
7877 | IgorA | 2379 | jmp .cycle0 |
2380 | .cycle0end: |
||
1457 | IgorA | 2381 | |
8533 | IgorA | 2382 | cmp byte[find],0 |
2383 | je .if_1e ;if(fnd){ // выделение найденого текста |
||
6086 | IgorA | 2384 | ;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){ |
7497 | IgorA | 2385 | mov eax,[begPos] |
2386 | mov bl,[f_color] |
||
2387 | mov [eax+1],bl ;tex[bP].col=f_color; |
||
2388 | mov eax,[endPos] |
||
6086 | IgorA | 2389 | mov byte[eax+1],0xff ;tex[eP].col=255; |
8533 | IgorA | 2390 | cmp byte[find],2 |
2391 | je .if_1e |
||
2392 | ;return ItPoPerv(eP); // возвращаем позицию конца вхождения |
||
7497 | IgorA | 2393 | mov edx,[endPos] |
6086 | IgorA | 2394 | call ted_get_text_perv_pos |
2395 | jmp @f |
||
2396 | .if_1e: |
||
2397 | mov edx,ted_tex |
||
2398 | @@: |
||
1457 | IgorA | 2399 | |
6086 | IgorA | 2400 | ret |
1457 | IgorA | 2401 | endp |
2402 | |||
2403 | ;input: |
||
2404 | ; edx = pointer to char (byte) |
||
2405 | ;output: |
||
2406 | ; cf=1 if symbol is... |
||
6274 | IgorA | 2407 | align 16 |
6086 | IgorA | 2408 | 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 |
2409 | 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 | 2410 | |
6086 | IgorA | 2411 | ;output: |
2412 | ; cf=1 если в [edx] буква, цифра или '_' |
||
6274 | IgorA | 2413 | align 16 |
1457 | IgorA | 2414 | isalnum: |
6086 | IgorA | 2415 | push eax ebx |
2416 | movzx eax,byte[edx] ;al=offset |
||
2417 | shr eax,3 |
||
2418 | lea ebx,[tab_all_num] |
||
2419 | add ebx,eax |
||
2420 | movzx ax,byte[edx] ;al=bit |
||
2421 | and ax,111b |
||
2422 | bt word[ebx],ax |
||
2423 | pop ebx eax |
||
2424 | ret |
||
2425 | |||
2426 | ;output: |
||
2427 | ; cf=1 если в [edx] буква или '_' |
||
6274 | IgorA | 2428 | align 16 |
1457 | IgorA | 2429 | isalpha: |
6086 | IgorA | 2430 | push eax ebx |
2431 | movzx eax,byte[edx] ;al=offset |
||
2432 | shr eax,3 |
||
2433 | lea ebx,[tab_alpha] |
||
2434 | add ebx,eax |
||
2435 | movzx ax,byte[edx] ;al=bit |
||
2436 | and ax,111b |
||
2437 | bt word[ebx],ax |
||
2438 | pop ebx eax |
||
2439 | ret |
||
1457 | IgorA | 2440 | |
6274 | IgorA | 2441 | align 16 |
6086 | IgorA | 2442 | proc ted_show_help_f1 uses eax edx edi, edit:dword |
6274 | IgorA | 2443 | mov edi,[edit] |
1457 | IgorA | 2444 | |
6086 | IgorA | 2445 | call ted_get_pos_by_cursor |
2446 | push edx |
||
2447 | call ted_iterat_next_color_tag |
||
2448 | mov eax,edx |
||
2449 | pop edx |
||
2450 | call ted_iterat_perv_color_tag |
||
1457 | IgorA | 2451 | |
6086 | IgorA | 2452 | cmp eax,ted_tex |
2453 | jle @f |
||
2454 | cmp edx,ted_tex_1 |
||
2455 | jle @f |
||
2456 | stdcall ted_find_help_id,eax |
||
2457 | @@: |
||
2458 | ;call ted_draw_main_cursor |
||
2459 | call ted_draw_help_f1 |
||
2460 | ret |
||
1457 | IgorA | 2461 | endp |
2462 | |||
2463 | ;input: |
||
2464 | ; edx = position begin 'symbol' struct |
||
2465 | ; edi = pointer to tedit struct |
||
2466 | ; end_pos = position end 'symbol' struct |
||
6274 | IgorA | 2467 | align 16 |
8262 | IgorA | 2468 | proc ted_find_help_id uses ebx ecx, end_pos:dword |
1457 | IgorA | 2469 | ; ecx = word_n |
2470 | ; ebx = l_pos |
||
2471 | mov ted_help_id,-1 |
||
2472 | |||
8533 | IgorA | 2473 | movzx ebx,byte[edx] |
2474 | shl ebx,2 ;ebx*=4 |
||
1457 | IgorA | 2475 | add ebx,ted_arr_key_pos |
7497 | IgorA | 2476 | mov ecx,[ebx] |
1457 | IgorA | 2477 | cmp ecx,0 |
2478 | jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){ |
||
2479 | push esi eax |
||
2480 | mov ebx,ecx ;l_pos=word_n; |
||
2481 | ColToIndexOffset ecx,esi |
||
2482 | push cx |
||
7497 | IgorA | 2483 | mov cl,[esi] |
1457 | IgorA | 2484 | @@: |
2485 | cmp ebx,ted_key_words_count ;while(l_pos |
||
2486 | jge @f |
||
2487 | ;ColToIndexOffset ecx,esi |
||
2488 | ColToIndexOffset ebx,eax |
||
7497 | IgorA | 2489 | cmp cl,[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0]) |
1457 | IgorA | 2490 | jne @f |
2491 | inc ebx ;l_pos++; |
||
2492 | jmp @b |
||
2493 | @@: |
||
2494 | pop cx |
||
2495 | call ted_iterat_next ;pos=1; |
||
2496 | mov esi,1 |
||
2497 | @@: |
||
2498 | push dx |
||
2499 | push word[edx] |
||
2500 | pop dx |
||
2501 | .wh_0b: |
||
2502 | cmp ebx,ecx ;while(l_pos>word_n |
||
2503 | jle .wh_0e |
||
2504 | dec ebx |
||
2505 | ColToIndexOffset ebx,eax |
||
2506 | inc ebx |
||
2507 | cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i]) |
||
2508 | je .wh_0e |
||
2509 | dec ebx ;l_pos--; |
||
2510 | jmp .wh_0b |
||
2511 | .wh_0e: |
||
2512 | |||
2513 | .wh_1b: |
||
2514 | cmp ebx,ecx ;while(l_pos>word_n |
||
2515 | jle .wh_1e |
||
2516 | ColToIndexOffset ecx,eax |
||
2517 | cmp byte[eax+esi],dl |
||
2518 | je .wh_1e |
||
2519 | inc ecx ;word_n++; |
||
2520 | jmp .wh_1b |
||
2521 | .wh_1e: |
||
2522 | pop dx |
||
2523 | |||
2524 | cmp ecx,ebx ;if(word_n==l_pos) break; |
||
2525 | je @f |
||
2526 | call ted_iterat_next ;pos++; |
||
7497 | IgorA | 2527 | cmp edx,[end_pos] ;for(...;i |
1457 | IgorA | 2528 | je @f ;jge |
2529 | inc esi |
||
2530 | jmp @b |
||
2531 | @@: |
||
2532 | pop eax esi |
||
2533 | |||
2534 | mov ted_help_id,ecx |
||
2535 | ;return word_n; |
||
2536 | |||
2537 | .if_0e: |
||
2538 | ret |
||
2539 | endp |
||
2540 | |||
9485 | IgorA | 2541 | ;description: |
2542 | ; изменяем размер памяти для текста (установка ted_ptr_free_symb на 1 символ) |
||
2543 | ;input: |
||
2544 | ; ecx - число символов в файле |
||
2545 | ; edi - pointer to tedit struct |
||
1457 | IgorA | 2546 | ;output: |
9485 | IgorA | 2547 | ; eax, ecx - разрушаются |
2548 | align 16 |
||
2549 | ted_mem_resize: |
||
2550 | add ecx,2 ;память для текста + служебные начальный и конечный символы |
||
2551 | .no_2: |
||
2552 | add ecx,ted_increase_size ;память для редактирования файла |
||
2553 | mov ted_max_chars,ecx |
||
2554 | imul ecx,sizeof.symbol |
||
2555 | invoke mem.realloc, ted_tex,ecx |
||
2556 | mov ted_tex,eax |
||
2557 | mov ted_tex_1,eax |
||
2558 | add ted_tex_1,sizeof.symbol |
||
2559 | add eax,ecx |
||
2560 | mov ted_tex_end,eax |
||
2561 | mov ecx,ted_tex_1 |
||
2562 | add ecx,sizeof.symbol |
||
2563 | mov ted_ptr_free_symb,ecx |
||
2564 | ret |
||
2565 | |||
2566 | ;output: |
||
1457 | IgorA | 2567 | ; eax = код ошибки |
2568 | ; ebx = колличество прочитанных байт |
||
6274 | IgorA | 2569 | align 16 |
9485 | IgorA | 2570 | proc ted_open_file uses ecx edx edi esi, edit:dword, file:dword, f_name:dword ;функция открытия файла |
2571 | locals |
||
2572 | unpac_mem dd ? |
||
2573 | endl |
||
6274 | IgorA | 2574 | mov edi,[edit] |
1457 | IgorA | 2575 | |
2808 | IgorA | 2576 | ; *** проверяем размер памяти и если не хватает то увеличиваем *** |
2577 | ;пробуем получить информацию о файле |
||
6274 | IgorA | 2578 | mov ebx,[file] |
2579 | mov dword[ebx], SSF_GET_INFO |
||
2808 | IgorA | 2580 | mov dword[ebx+4], 0 |
2581 | mov dword[ebx+8], 0 |
||
2582 | mov dword[ebx+12], 0 |
||
2583 | m2m dword[ebx+16], ted_tex |
||
2584 | mov byte[ebx+20], 0 |
||
2585 | push dword[f_name] |
||
2586 | pop dword[ebx+21] |
||
6274 | IgorA | 2587 | mcall SF_FILE |
2588 | or eax,eax |
||
2589 | jz .end_0 |
||
2808 | IgorA | 2590 | mov edx,ted_max_chars |
2591 | cmp eax,2 ;функция не поддерживается для данной файловой системы |
||
2592 | je @f |
||
2593 | jmp .ret_f |
||
6274 | IgorA | 2594 | align 4 |
2808 | IgorA | 2595 | .end_0: |
2596 | ;проверяем хватит ли памяти для загрузки файла |
||
2597 | mov ecx,ted_max_chars |
||
2598 | sub ecx,2 ;ecx = максимальное число байт, для которых была выделена память |
||
2599 | mov edx,ted_tex |
||
6274 | IgorA | 2600 | mov edx,[edx+32] ;+32 = +0x20: qword: размер файла в байтах |
2808 | IgorA | 2601 | cmp edx,ecx |
2602 | jl @f |
||
9485 | IgorA | 2603 | mov ecx,edx |
2604 | call ted_mem_resize |
||
2808 | IgorA | 2605 | @@: |
2606 | |||
2607 | ; *** пробуем открыть файл *** |
||
6274 | IgorA | 2608 | mov ebx,[file] |
2609 | mov dword[ebx], SSF_READ_FILE |
||
1457 | IgorA | 2610 | mov dword[ebx+4], 0 |
2611 | mov dword[ebx+8], 0 |
||
2808 | IgorA | 2612 | m2m dword[ebx+12], edx ;число байт, которые могут быть считаны с файла (не больше чем ted_max_chars) |
1457 | IgorA | 2613 | m2m dword[ebx+16], ted_tex |
2614 | mov byte[ebx+20], 0 |
||
2615 | push dword[f_name] |
||
2616 | pop dword[ebx+21] |
||
6274 | IgorA | 2617 | mcall SF_FILE |
1457 | IgorA | 2618 | |
6274 | IgorA | 2619 | or eax,eax |
2620 | jz @f |
||
1457 | IgorA | 2621 | cmp eax,6 |
8262 | IgorA | 2622 | jne .ret_f |
1457 | IgorA | 2623 | @@: |
2624 | cmp ebx,-1 |
||
2625 | je .ret_f |
||
2626 | ;if open file |
||
9485 | IgorA | 2627 | push eax |
2628 | mov eax,ted_tex |
||
2629 | cmp dword[eax],'KPCK' |
||
2630 | jne .end_unpack |
||
2631 | ;выделение памяти для распаковки файла |
||
2632 | invoke mem.alloc,[eax+4] |
||
2633 | mov [unpac_mem],eax |
||
2634 | stdcall unpack,ted_tex,[unpac_mem] |
||
2635 | mov ecx,ted_max_chars |
||
2636 | sub ecx,2 ;ecx = максимальное число байт, для которых была выделена память |
||
2637 | mov eax,ted_tex |
||
2638 | mov ebx,[eax+4] |
||
2639 | cmp ebx,ecx |
||
2640 | jl @f ;если для распакованого файла не хватает выделенной памяти |
||
2641 | mov ecx,ebx |
||
2642 | call ted_mem_resize |
||
2643 | @@: |
||
2644 | mov edi,ted_tex |
||
2645 | mov esi,[unpac_mem] |
||
2646 | mov ecx,ebx |
||
2647 | cld |
||
2648 | rep movsb |
||
2649 | mov edi,[edit] |
||
2650 | invoke mem.free,[unpac_mem] |
||
2651 | .end_unpack: |
||
2652 | pop eax |
||
1457 | IgorA | 2653 | call ted_on_open_file |
2654 | .ret_f: |
||
2655 | ret |
||
2656 | endp |
||
2657 | |||
6274 | IgorA | 2658 | align 16 |
1457 | IgorA | 2659 | proc ted_but_select_word, edit:dword |
2660 | pushad |
||
6274 | IgorA | 2661 | mov edi,[edit] |
1457 | IgorA | 2662 | |
2663 | call ted_get_pos_by_cursor |
||
2664 | push edx |
||
2665 | call ted_iterat_perv_color_tag |
||
2666 | cmp edx,ted_tex_1 |
||
2667 | jle @f |
||
2668 | call ted_get_text_coords |
||
2669 | mov ted_sel_x0,ebx |
||
2670 | mov ted_sel_y0,eax |
||
2671 | @@: |
||
2672 | pop edx |
||
2673 | call ted_iterat_next_color_tag |
||
2674 | cmp edx,ted_tex_1 |
||
2675 | jle @f |
||
2676 | call ted_get_text_coords |
||
2677 | mov ted_sel_x1,ebx |
||
2678 | mov ted_sel_y1,eax |
||
2679 | @@: |
||
2680 | |||
2681 | cmp ted_fun_draw_panel_buttons,0 |
||
2682 | je @f |
||
2683 | call ted_fun_draw_panel_buttons |
||
2684 | @@: |
||
2685 | stdcall ted_draw,edi |
||
2686 | popad |
||
2687 | ret |
||
2688 | endp |
||
2689 | |||
7497 | IgorA | 2690 | ;output: |
2691 | ; al = 1 if delete |
||
6274 | IgorA | 2692 | align 16 |
6087 | IgorA | 2693 | proc ted_but_cut uses edi, edit:dword |
6274 | IgorA | 2694 | mov edi,[edit] |
1457 | IgorA | 2695 | |
2696 | stdcall ted_but_copy,edi |
||
2697 | call ted_set_undo |
||
2698 | stdcall ted_sel_text_del,ted_opt_ed_change_time |
||
2699 | |||
2700 | cmp al,1 |
||
2701 | jne @f |
||
2702 | stdcall ted_draw,edi |
||
2703 | cmp ted_fun_draw_panel_buttons,0 |
||
2704 | je @f |
||
2705 | call ted_fun_draw_panel_buttons |
||
2706 | @@: |
||
2707 | ret |
||
2708 | endp |
||
2709 | |||
6274 | IgorA | 2710 | align 16 |
1457 | IgorA | 2711 | proc ted_but_copy, edit:dword |
2712 | pushad |
||
6274 | IgorA | 2713 | mov edi,[edit] |
1457 | IgorA | 2714 | |
2715 | call ted_is_select |
||
6274 | IgorA | 2716 | or al,al |
2717 | jz .end_f ;if not selected text |
||
1457 | IgorA | 2718 | call ted_sel_normalize |
2719 | |||
2720 | mov esi,ted_seln_x1 |
||
2721 | mov ecx,ted_seln_y1 |
||
2722 | call ted_get_pos_by_coords |
||
2723 | mov ebx,edx |
||
2724 | mov esi,ted_seln_x0 |
||
2725 | mov ecx,ted_seln_y0 |
||
2726 | call ted_get_pos_by_coords |
||
2727 | mov esi,ebx |
||
2728 | |||
4228 | IgorA | 2729 | mov ecx,12 ;system buffer header size |
1457 | IgorA | 2730 | mov ebx,ted_buffer |
4228 | IgorA | 2731 | mov dword[ebx+4],0 ;text data |
2732 | mov dword[ebx+8],1 ;code 866 |
||
2733 | add ebx,ecx |
||
1457 | IgorA | 2734 | @@: |
2735 | cmp edx,ted_tex_1 ;end of file |
||
2736 | jle @f |
||
2737 | cmp edx,esi ;end of select |
||
2738 | je @f |
||
2739 | inc ecx |
||
2740 | cmp ecx,ted_buffer_size ;owerflow bufer |
||
2741 | je @f |
||
2742 | |||
2743 | mov al,byte[edx] |
||
2744 | mov byte[ebx],al |
||
2745 | inc ebx |
||
5832 | IgorA | 2746 | cmp al,13 |
2747 | jne .no_13 |
||
2748 | mov byte[ebx],10 ;делаем конец строки в буфере 13,10 для совместимости с другими программами |
||
2749 | inc ebx |
||
2750 | inc ecx |
||
2751 | .no_13: |
||
2752 | |||
1457 | IgorA | 2753 | call ted_iterat_next |
2754 | jmp @b |
||
2755 | @@: |
||
2756 | mov byte[ebx],0 |
||
2757 | |||
4542 | IgorA | 2758 | cmp ecx,12 |
1457 | IgorA | 2759 | je .end_f |
4228 | IgorA | 2760 | mov ebx,ted_buffer |
6274 | IgorA | 2761 | mov [ebx],ecx |
2762 | mcall SF_CLIPBOARD,SSF_WRITE_CB,ecx,ted_buffer |
||
1457 | IgorA | 2763 | call ted_draw_buffer |
2764 | cmp ted_fun_draw_panel_buttons,0 |
||
2765 | je .end_f |
||
2766 | call ted_fun_draw_panel_buttons |
||
2767 | .end_f: |
||
2768 | popad |
||
2769 | ret |
||
2770 | endp |
||
2771 | |||
2772 | |||
6274 | IgorA | 2773 | align 16 |
1457 | IgorA | 2774 | proc ted_but_paste, edit:dword |
4228 | IgorA | 2775 | pushad |
6274 | IgorA | 2776 | mov edi,[edit] |
1457 | IgorA | 2777 | |
6274 | IgorA | 2778 | mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT |
4228 | IgorA | 2779 | cmp eax,1 |
2780 | jl .no_buf_r |
||
2781 | |||
2782 | mov esi,eax |
||
2783 | .cycle: ;обратный цикл по слотам |
||
2784 | dec esi ;номер текущего, проверяемого слота |
||
6274 | IgorA | 2785 | mcall SF_CLIPBOARD,SSF_READ_CB,esi |
4228 | IgorA | 2786 | cmp eax,1 |
2787 | je .no_buf_r |
||
2788 | cmp eax,-1 |
||
2789 | je .no_buf_r |
||
7497 | IgorA | 2790 | mov ecx,[eax] |
4228 | IgorA | 2791 | cmp ecx,1 ;size |
2792 | jl .no_buf_r |
||
2793 | cmp dword[eax+4],0 ;text |
||
2794 | je @f |
||
2795 | cmp esi,1 |
||
2796 | jge .cycle ;если в буфере не текст, а слотов в буфере несколько, пробуем перейти к верхнему слоту |
||
2797 | jmp .no_buf_r |
||
2798 | @@: |
||
2799 | cmp dword[eax+8],1 ;866 |
||
2800 | je @f |
||
2801 | cmp esi,1 |
||
2802 | jge .cycle ;если в буфере текст не в кодировке 866 ... пробуем перейти к верхнему слоту |
||
2803 | jmp .no_buf_r |
||
2804 | @@: |
||
2805 | ;копирование текста из системного буфера во внутренний |
||
2806 | cmp ecx,ted_buffer_size |
||
2807 | jle @f |
||
2808 | mov ecx,ted_buffer_size |
||
2809 | @@: |
||
2810 | mov edi,ted_buffer |
||
2811 | mov esi,eax |
||
2812 | add esi,4 ;12 |
||
2813 | mov dword[edi],ecx |
||
2814 | add edi,4 ;12 |
||
2815 | sub ecx,4 ;12 |
||
2816 | rep movsb |
||
6274 | IgorA | 2817 | mov edi,[edit] |
4228 | IgorA | 2818 | |
2819 | mov esi,eax |
||
2820 | add esi,12 |
||
2821 | jmp .buf_r |
||
2822 | .no_buf_r: |
||
2823 | |||
2824 | ;если не удалось прочитать данные из системного буфера, попадаем сюда |
||
1457 | IgorA | 2825 | mov esi,ted_buffer |
4228 | IgorA | 2826 | cmp dword[esi],1 ;проверяем есть ли данные во внутреннем буфере |
2827 | jl .no_paste ;если вообще ничего не удалось прочитать идем на выход |
||
2828 | add esi,12 ;system buffer header size |
||
2829 | .buf_r: |
||
2830 | |||
2831 | mov edx,esi |
||
1457 | IgorA | 2832 | call tl_strlen |
2833 | cmp eax,1 |
||
4228 | IgorA | 2834 | jl .no_paste |
1457 | IgorA | 2835 | mov esi,eax |
2836 | call ted_set_undo |
||
2837 | mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor |
||
2838 | stdcall ted_sel_text_del,ebx |
||
2839 | cmp al,1 |
||
2840 | jne .del |
||
2841 | mov ebx,ted_opt_ed_move_cursor |
||
2842 | .del: |
||
4228 | IgorA | 2843 | stdcall ted_text_add,edi,edx,esi,ebx |
1457 | IgorA | 2844 | stdcall ted_draw,edi |
2845 | cmp ted_fun_draw_panel_buttons,0 |
||
4228 | IgorA | 2846 | je .no_paste |
1457 | IgorA | 2847 | call ted_fun_draw_panel_buttons |
4228 | IgorA | 2848 | .no_paste: |
2849 | popad |
||
1457 | IgorA | 2850 | ret |
2851 | endp |
||
2852 | |||
6274 | IgorA | 2853 | align 16 |
2324 | IgorA | 2854 | proc ted_but_sumb_upper uses edi esi, edit:dword |
6274 | IgorA | 2855 | mov edi,[edit] |
1457 | IgorA | 2856 | |
2324 | IgorA | 2857 | stdcall ted_convert_sel_text,fb_char_toupper |
6274 | IgorA | 2858 | or esi,esi |
2859 | jz @f |
||
2324 | IgorA | 2860 | stdcall ted_draw,edi |
2861 | @@: |
||
2862 | ret |
||
1457 | IgorA | 2863 | endp |
2864 | |||
6274 | IgorA | 2865 | align 16 |
2324 | IgorA | 2866 | proc ted_but_sumb_lover uses edi esi, edit:dword |
6274 | IgorA | 2867 | mov edi,[edit] |
1457 | IgorA | 2868 | |
2324 | IgorA | 2869 | stdcall ted_convert_sel_text,fb_char_todown |
6274 | IgorA | 2870 | or esi,esi |
2871 | jz @f |
||
2324 | IgorA | 2872 | stdcall ted_draw,edi |
2873 | @@: |
||
2874 | ret |
||
1457 | IgorA | 2875 | endp |
2876 | |||
6274 | IgorA | 2877 | align 16 |
6087 | IgorA | 2878 | proc ted_but_reverse uses eax ebx edi, edit:dword |
6274 | IgorA | 2879 | mov edi,[edit] |
1457 | IgorA | 2880 | |
6087 | IgorA | 2881 | call ted_is_select |
6274 | IgorA | 2882 | or al,al |
2883 | jz @f |
||
6087 | IgorA | 2884 | call ted_sel_normalize |
2885 | push esi ecx edx |
||
2886 | mov esi,ted_seln_x0 |
||
2887 | mov ecx,ted_seln_y0 |
||
2888 | call ted_get_pos_by_coords |
||
2889 | mov eax,edx |
||
2890 | mov esi,ted_seln_x1 |
||
2891 | cmp esi,0 |
||
2892 | je .beg_str |
||
2893 | dec esi |
||
2894 | .beg_str: |
||
2895 | mov ecx,ted_seln_y1 |
||
2896 | call ted_get_pos_by_coords |
||
2897 | ;call ted_get_text_perv_pos |
||
2898 | mov ebx,edx |
||
2899 | pop edx ecx esi |
||
2900 | ;cmp eax,... |
||
2901 | ;je @f |
||
2902 | call ted_revers |
||
2903 | @@: |
||
2904 | stdcall ted_draw,edi |
||
2905 | ret |
||
1457 | IgorA | 2906 | endp |
2907 | |||
6274 | IgorA | 2908 | align 16 |
6087 | IgorA | 2909 | proc ted_but_undo uses eax edi, edit:dword |
6274 | IgorA | 2910 | mov edi,[edit] |
1457 | IgorA | 2911 | |
2912 | mov eax,ted_tim_undo |
||
2913 | cmp ted_tim_ch,eax |
||
2914 | jbe @f |
||
2915 | inc ted_tim_undo |
||
2916 | ;call ted_text_colored |
||
2917 | stdcall ted_draw,edi |
||
2918 | cmp ted_fun_draw_panel_buttons,0 |
||
2919 | je @f |
||
2920 | call ted_fun_draw_panel_buttons |
||
2921 | @@: |
||
2922 | ret |
||
2923 | endp |
||
2924 | |||
6274 | IgorA | 2925 | align 16 |
6087 | IgorA | 2926 | proc ted_but_redo uses edi, edit:dword |
6274 | IgorA | 2927 | mov edi,[edit] |
1457 | IgorA | 2928 | |
2929 | cmp ted_tim_undo,1 |
||
2930 | jb @f |
||
2931 | dec ted_tim_undo |
||
2932 | ;call ted_text_colored |
||
2933 | stdcall ted_draw,edi |
||
2934 | cmp ted_fun_draw_panel_buttons,0 |
||
2935 | je @f |
||
2936 | call ted_fun_draw_panel_buttons |
||
2937 | @@: |
||
2938 | ret |
||
2939 | endp |
||
2940 | |||
7576 | IgorA | 2941 | ;description: |
2942 | ; функция находит текст на который указывает ted_buffer_find |
||
2943 | ;input: |
||
2944 | ; f_opt = параметры поиска: |
||
7577 | IgorA | 2945 | ; (0 - искать ниже курсора, 1 - искать выше курсора, 2 - искать от начала файла) |
2946 | ; если установлен 31-й бит, то не обновляется окно |
||
7583 | IgorA | 2947 | ; если установлен 30-й бит, то поиск идет без учета регистра символов |
7577 | IgorA | 2948 | ;output: |
2949 | ; eax = был ли найден искомый текст (0 - нет, 1 - да) |
||
6274 | IgorA | 2950 | align 16 |
7577 | IgorA | 2951 | proc ted_but_find uses ebx ecx edx edi esi, edit:dword, f_opt:dword |
7583 | IgorA | 2952 | mov eax,[f_opt] |
2953 | push eax |
||
7576 | IgorA | 2954 | push [edit] |
7583 | IgorA | 2955 | cmp al,2 |
7576 | IgorA | 2956 | jne @f |
7577 | IgorA | 2957 | call _but_find_first |
2958 | jmp .end0 |
||
7576 | IgorA | 2959 | @@: |
7583 | IgorA | 2960 | cmp al,0 |
7576 | IgorA | 2961 | jne @f |
7577 | IgorA | 2962 | call _but_find_next |
2963 | jmp .end0 |
||
7576 | IgorA | 2964 | @@: |
7583 | IgorA | 2965 | cmp al,1 |
2966 | jne @f |
||
7577 | IgorA | 2967 | call _but_find_perv |
7583 | IgorA | 2968 | jmp .end0 |
2969 | @@: |
||
2970 | add esp,8 |
||
7577 | IgorA | 2971 | .end0: |
2972 | |||
2973 | bt dword[f_opt],31 |
||
2974 | jc .end1 |
||
2975 | or eax,eax |
||
2976 | jz @f |
||
2977 | ;текст найден, обновляем окно |
||
2978 | stdcall ted_draw,edi |
||
2979 | jmp .end1 |
||
2980 | @@: |
||
2981 | ;текст не найден, пробуем вызвать сообщение |
||
2982 | cmp ted_fun_find_err,0 |
||
2983 | je .end1 |
||
2984 | call ted_fun_find_err ;пользовательская функция |
||
2985 | .end1: |
||
7576 | IgorA | 2986 | ret |
2987 | endp |
||
2988 | |||
2989 | ;description: |
||
7577 | IgorA | 2990 | ; функция находит текст от начала файла, или от конца текущего выделения |
7583 | IgorA | 2991 | ;input: |
2992 | ; f_opt = опции для поиска |
||
7577 | IgorA | 2993 | ;output: |
2994 | ; eax = был ли найден искомый текст (0 - нет, 1 - да) |
||
2995 | ; ebx, ecx, edx, edi, edi - портятся |
||
7576 | IgorA | 2996 | align 16 |
7583 | IgorA | 2997 | proc _but_find_first, edit:dword, f_opt:dword |
7576 | IgorA | 2998 | mov edi,[edit] |
2999 | |||
3000 | call ted_is_select |
||
3001 | or al,al |
||
3002 | jz @f |
||
3003 | call ted_sel_normalize |
||
3004 | mov edx,ted_sel_y1 |
||
3005 | mov ecx,ted_sel_x1 |
||
3006 | call ted_go_to_pos ;переход на конец выделения |
||
3007 | call ted_get_pos_by_cursor |
||
3008 | jmp .end0 |
||
3009 | @@: |
||
3010 | mov edx,ted_tex |
||
3011 | call ted_iterat_next |
||
3012 | .end0: |
||
7583 | IgorA | 3013 | mov ebx,ted_buffer_find |
7576 | IgorA | 3014 | @@: |
7583 | IgorA | 3015 | mov eax,[f_opt] |
7576 | IgorA | 3016 | call ted_get_find_rezult |
7583 | IgorA | 3017 | cmp ah,1 |
7576 | IgorA | 3018 | je @f ; find |
3019 | call ted_iterat_next |
||
3020 | cmp edx,ted_tex_1 |
||
3021 | jle @f |
||
3022 | jmp @b |
||
3023 | @@: |
||
7577 | IgorA | 3024 | call _but_find_select |
7576 | IgorA | 3025 | ret |
3026 | endp |
||
3027 | |||
3028 | ;description: |
||
7577 | IgorA | 3029 | ; функция находит текст выше курсора |
7583 | IgorA | 3030 | ;input: |
3031 | ; f_opt = опции для поиска |
||
7577 | IgorA | 3032 | ;output: |
3033 | ; eax = был ли найден искомый текст (0 - нет, 1 - да) |
||
3034 | ; ebx, ecx, edx, edi, edi - портятся |
||
7576 | IgorA | 3035 | align 16 |
7583 | IgorA | 3036 | proc _but_find_perv, edit:dword, f_opt:dword |
7576 | IgorA | 3037 | mov edi,[edit] |
7583 | IgorA | 3038 | |
7576 | IgorA | 3039 | call ted_is_select |
3040 | or al,al |
||
3041 | jz @f |
||
3042 | call ted_sel_normalize |
||
3043 | mov edx,ted_sel_y0 |
||
3044 | mov ecx,ted_sel_x0 |
||
3045 | call ted_go_to_pos ;переход на начало выделения |
||
3046 | call ted_get_pos_by_cursor |
||
3047 | call ted_iterat_perv ;переход на 1-й символ перед выделением |
||
3048 | jmp .end0 |
||
3049 | @@: |
||
3050 | call ted_get_pos_by_cursor |
||
3051 | .end0: |
||
7583 | IgorA | 3052 | mov ebx,ted_buffer_find |
7576 | IgorA | 3053 | @@: |
7583 | IgorA | 3054 | mov eax,[f_opt] |
7576 | IgorA | 3055 | call ted_get_find_rezult |
7583 | IgorA | 3056 | cmp ah,1 |
7576 | IgorA | 3057 | je @f ; find |
3058 | call ted_iterat_perv |
||
3059 | cmp edx,ted_tex_1 |
||
3060 | jle @f |
||
3061 | jmp @b |
||
3062 | @@: |
||
7577 | IgorA | 3063 | call _but_find_select |
7576 | IgorA | 3064 | ret |
3065 | endp |
||
3066 | |||
3067 | ;description: |
||
7577 | IgorA | 3068 | ; функция находит текст ниже курсора |
7583 | IgorA | 3069 | ;input: |
3070 | ; f_opt = опции для поиска |
||
7577 | IgorA | 3071 | ;output: |
3072 | ; eax = был ли найден искомый текст (0 - нет, 1 - да) |
||
7583 | IgorA | 3073 | ; ebx, ecx, edx, edi, esi - портятся |
7576 | IgorA | 3074 | align 16 |
7583 | IgorA | 3075 | proc _but_find_next, edit:dword, f_opt:dword |
6274 | IgorA | 3076 | mov edi,[edit] |
1457 | IgorA | 3077 | |
3078 | call ted_get_pos_by_cursor |
||
7583 | IgorA | 3079 | mov ebx,ted_buffer_find |
1457 | IgorA | 3080 | @@: |
7583 | IgorA | 3081 | mov eax,[f_opt] |
1457 | IgorA | 3082 | call ted_get_find_rezult |
7583 | IgorA | 3083 | cmp ah,1 |
1457 | IgorA | 3084 | je @f ; find |
3085 | call ted_iterat_next |
||
3086 | cmp edx,ted_tex_1 |
||
3087 | jle @f |
||
3088 | jmp @b |
||
3089 | @@: |
||
7577 | IgorA | 3090 | call _but_find_select |
7576 | IgorA | 3091 | ret |
3092 | endp |
||
3093 | |||
7577 | IgorA | 3094 | ;description: |
3095 | ; вспомогательная функция, выделяет найденный текст |
||
7576 | IgorA | 3096 | ;input: |
7583 | IgorA | 3097 | ; ah = был ли найден искомый текст (0 - нет, 1 - да) |
7576 | IgorA | 3098 | ; esi = first symbol pointer |
3099 | align 16 |
||
7577 | IgorA | 3100 | _but_find_select: |
7583 | IgorA | 3101 | or ah,ah |
7576 | IgorA | 3102 | jz @f |
1457 | IgorA | 3103 | call ted_get_text_coords |
3104 | inc ebx ;move cursor right |
||
3105 | mov ted_sel_x1,ebx |
||
3106 | mov ted_sel_y1,eax |
||
3107 | mov edx,eax |
||
3108 | mov ecx,ebx |
||
3109 | call ted_go_to_pos |
||
7576 | IgorA | 3110 | mov edx,esi |
1457 | IgorA | 3111 | call ted_get_text_coords |
3112 | mov ted_sel_x0,ebx |
||
3113 | mov ted_sel_y0,eax |
||
7577 | IgorA | 3114 | xor eax,eax |
3115 | inc eax |
||
3116 | jmp .end0 |
||
1457 | IgorA | 3117 | @@: |
7577 | IgorA | 3118 | xor eax,eax ;текст не найден |
3119 | .end0: |
||
1457 | IgorA | 3120 | ret |
7576 | IgorA | 3121 | |
3122 | ;input: |
||
3123 | ; rpl_text = текст для замены |
||
3124 | ; r_opt = параметры поиска: |
||
7577 | IgorA | 3125 | ; (0 - искать ниже курсора, 1 - искать выше курсора, 2 - искать от начала файла) |
7576 | IgorA | 3126 | ; n_tim = фиксировать замену в изменениях (0 - нет, 1 - да) |
3127 | ;output: |
||
3128 | ; eax = 0 - не удачно, 1 - удачно |
||
3129 | align 16 |
||
3130 | proc ted_but_replace uses edx edi esi, edit:dword, rpl_text:dword, r_opt:dword, n_tim:dword |
||
3131 | mov edi,[edit] |
||
7577 | IgorA | 3132 | mov eax,[r_opt] |
3133 | bts eax,31 |
||
3134 | stdcall ted_but_find, edi,eax |
||
3135 | or eax,eax |
||
3136 | jz .end0 |
||
7576 | IgorA | 3137 | |
3138 | xor edx,edx |
||
3139 | cmp dword[n_tim],0 |
||
3140 | je @f |
||
7577 | IgorA | 3141 | call ted_set_undo |
7576 | IgorA | 3142 | mov edx,ted_opt_ed_change_time |
3143 | @@: |
||
3144 | stdcall ted_sel_text_del, edx |
||
3145 | or eax,0xff |
||
7577 | IgorA | 3146 | jz .end0 |
7576 | IgorA | 3147 | mov esi,[rpl_text] |
3148 | stdcall tl_strlen |
||
3149 | or eax,eax |
||
7577 | IgorA | 3150 | jz .end0 |
7576 | IgorA | 3151 | stdcall ted_text_add, edi,esi,eax,ted_opt_ed_move_cursor |
3152 | xor eax,eax |
||
3153 | inc eax |
||
7577 | IgorA | 3154 | .end0: |
7576 | IgorA | 3155 | ret |
1457 | IgorA | 3156 | endp |
3157 | |||
7583 | IgorA | 3158 | ;description: |
3159 | ; Функция проверяет совпадает ли текст в буфере ebx |
||
3160 | ; с текстом редактора по указателю edx. |
||
3161 | ; Стандартные функции (напр. strcmp) тут не подойдут, потому что |
||
3162 | ; в памяти редактора текст содержится не в виде ascii строк. |
||
1457 | IgorA | 3163 | ;input: |
7583 | IgorA | 3164 | ; eax - options to find |
3165 | ; ebx - text need find |
||
7577 | IgorA | 3166 | ; edx - first symbol pointer |
3167 | ; edi - pointer to tedit struct |
||
3168 | ;output: |
||
7583 | IgorA | 3169 | ; ah - rezult |
7577 | IgorA | 3170 | ; edx - last text position (if find sucess) |
3171 | ; esi - first symbol pointer |
||
3172 | align 16 |
||
7583 | IgorA | 3173 | proc ted_get_find_rezult uses ebx |
3174 | mov al,byte[ebx] |
||
3175 | bt eax,30 |
||
3176 | jnc @f |
||
3177 | call fb_char_toupper |
||
3178 | @@: |
||
3179 | mov ah,1 |
||
7577 | IgorA | 3180 | mov esi,edx ;copy edx |
7583 | IgorA | 3181 | .cycle0: |
3182 | mov cl,al |
||
3183 | mov al,byte[edx] |
||
3184 | bt eax,30 |
||
3185 | jnc @f |
||
3186 | call fb_char_toupper |
||
3187 | @@: |
||
3188 | cmp al,cl |
||
7577 | IgorA | 3189 | jne .no_text |
3190 | |||
7583 | IgorA | 3191 | inc ebx ;*** get next symbol (in find text) *** |
3192 | mov al,byte[ebx] |
||
3193 | or al,al |
||
3194 | jz .end_f ;end of find text |
||
3195 | bt eax,30 |
||
3196 | jnc @f |
||
3197 | call fb_char_toupper |
||
3198 | @@: |
||
7577 | IgorA | 3199 | |
3200 | call ted_iterat_next ;*** get next symbol (in editor text) *** |
||
3201 | cmp edx,ted_tex_1 |
||
7583 | IgorA | 3202 | jg .cycle0 |
7577 | IgorA | 3203 | align 4 |
3204 | .no_text: |
||
7583 | IgorA | 3205 | xor ah,ah |
7577 | IgorA | 3206 | mov edx,esi ;restore edx |
7583 | IgorA | 3207 | .end_f: |
7577 | IgorA | 3208 | ret |
7583 | IgorA | 3209 | endp |
7577 | IgorA | 3210 | |
3211 | ;input: |
||
1457 | IgorA | 3212 | ; edi = pointer to tedit struct |
6274 | IgorA | 3213 | align 16 |
1457 | IgorA | 3214 | ted_key_ctrl_home: |
3215 | mov ted_cur_x,0 |
||
3216 | mov ted_cur_y,0 |
||
3217 | push eax |
||
3218 | mov eax,ted_scr_w |
||
3219 | mov dword[eax+sb_offs_position],0 |
||
3220 | mov eax,ted_scr_h |
||
3221 | mov dword[eax+sb_offs_position],0 |
||
3222 | pop eax |
||
3223 | stdcall ted_draw,edi |
||
3224 | cmp ted_fun_draw_panel_buttons,0 |
||
3225 | je @f |
||
3226 | call ted_fun_draw_panel_buttons |
||
3227 | @@: |
||
3228 | ret |
||
3229 | |||
3230 | ;input: |
||
3231 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3232 | align 16 |
4988 | IgorA | 3233 | ted_key_ctrl_end: |
3234 | push eax ebx |
||
3235 | call ted_get_num_lines |
||
3236 | mov ebx,ted_scr_w |
||
7497 | IgorA | 3237 | mov [ebx+sb_offs_position],eax ;ставим ползунок на последнюю строку документа |
3238 | cmp eax,[ebx+sb_offs_cur_area] |
||
4988 | IgorA | 3239 | jle @f |
7497 | IgorA | 3240 | mov eax,[ebx+sb_offs_cur_area] ;получаем число строк влазящих в окно |
4988 | IgorA | 3241 | @@: |
7497 | IgorA | 3242 | sub [ebx+sb_offs_position],eax ;отнимаем от ползунка число строк влазящих в окно (но не больше тех, что есть в документе) |
4988 | IgorA | 3243 | dec eax |
3244 | mov ted_cur_y,eax ;ставим курсор на последнюю строку документа |
||
3245 | pop ebx eax |
||
3246 | call ted_cur_move_x_last_char |
||
3247 | stdcall ted_draw,edi |
||
3248 | cmp ted_fun_draw_panel_buttons,0 |
||
3249 | je @f |
||
3250 | call ted_fun_draw_panel_buttons |
||
3251 | @@: |
||
3252 | ret |
||
3253 | |||
3254 | ;input: |
||
3255 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3256 | align 16 |
1457 | IgorA | 3257 | proc ted_sel_key_up |
3258 | cmp ted_drag_k,1 |
||
3259 | je @f |
||
3260 | call ted_sel_start |
||
3261 | mov ted_drag_k,1 |
||
3262 | @@: |
||
3263 | push dx |
||
3264 | call ted_cur_move_up |
||
3265 | cmp dl,8 |
||
3266 | jne @f |
||
3267 | call ted_scroll_set_redraw |
||
3268 | @@: |
||
3269 | pop dx |
||
3270 | call ted_sel_move |
||
3271 | stdcall ted_draw,edi |
||
3272 | ret |
||
3273 | endp |
||
3274 | |||
3275 | ;input: |
||
3276 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3277 | align 16 |
1457 | IgorA | 3278 | proc ted_sel_key_down |
3279 | cmp ted_drag_k,1 |
||
3280 | je @f |
||
3281 | call ted_sel_start |
||
3282 | mov ted_drag_k,1 |
||
3283 | @@: |
||
3284 | push dx |
||
3285 | call ted_cur_move_down |
||
3286 | cmp dl,8 |
||
3287 | jne @f |
||
3288 | call ted_scroll_set_redraw |
||
3289 | @@: |
||
3290 | pop dx |
||
3291 | call ted_sel_move |
||
3292 | stdcall ted_draw,edi |
||
3293 | ret |
||
3294 | endp |
||
3295 | |||
3296 | ;input: |
||
3297 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3298 | align 16 |
1457 | IgorA | 3299 | proc ted_sel_key_left |
8036 | IgorA | 3300 | cmp ted_drag_k,1 |
3301 | je @f |
||
3302 | call ted_sel_start |
||
3303 | @@: |
||
3304 | push dx |
||
3305 | call ted_cur_move_left |
||
3306 | call ted_sel_move |
||
3307 | cmp ted_drag_k,1 |
||
3308 | je @f |
||
3309 | mov ted_drag_k,1 |
||
3310 | mov dl,8 |
||
3311 | @@: |
||
3312 | cmp dl,8 |
||
3313 | jne @f |
||
3314 | call ted_scroll_set_redraw |
||
3315 | stdcall ted_draw,edi |
||
3316 | jmp .end_f |
||
3317 | @@: |
||
3318 | stdcall ted_draw_cur_line,edi |
||
3319 | .end_f: |
||
3320 | pop dx |
||
3321 | ret |
||
1457 | IgorA | 3322 | endp |
3323 | |||
3324 | ;input: |
||
3325 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3326 | align 16 |
1457 | IgorA | 3327 | proc ted_sel_key_right |
8036 | IgorA | 3328 | cmp ted_drag_k,1 |
3329 | je @f |
||
3330 | call ted_sel_start |
||
3331 | @@: |
||
3332 | push dx |
||
3333 | call ted_cur_move_right |
||
3334 | call ted_sel_move |
||
3335 | cmp ted_drag_k,1 |
||
3336 | je @f |
||
3337 | mov ted_drag_k,1 |
||
3338 | mov dl,8 |
||
3339 | @@: |
||
3340 | cmp dl,8 |
||
3341 | jne @f |
||
3342 | call ted_scroll_set_redraw |
||
3343 | stdcall ted_draw,edi |
||
3344 | jmp .end_f |
||
3345 | @@: |
||
3346 | stdcall ted_draw_cur_line,edi |
||
3347 | .end_f: |
||
3348 | pop dx |
||
3349 | ret |
||
1457 | IgorA | 3350 | endp |
3351 | |||
3352 | ;input: |
||
3353 | ; edi = pointer to tedit struct |
||
3354 | ;description: |
||
3355 | ; this function need to optimize output |
||
6274 | IgorA | 3356 | align 16 |
1457 | IgorA | 3357 | proc ted_draw_cursor_sumb |
6256 | IgorA | 3358 | pushad |
3359 | mov ebx,ted_wnd_l |
||
3360 | add ebx,ted_rec_l |
||
3361 | mov edx,ted_cur_x |
||
3362 | imul edx,ted_rec_w |
||
3363 | add ebx,edx |
||
3364 | shl ebx,16 |
||
3365 | add ebx,ted_rec_w |
||
1457 | IgorA | 3366 | |
6256 | IgorA | 3367 | mov ecx,ted_wnd_t ;calc rect -> y0,y1 |
3368 | add ecx,ted_rec_t |
||
3369 | mov edx,ted_cur_y |
||
3370 | imul edx,ted_rec_h |
||
3371 | add ecx,edx |
||
3372 | shl ecx,16 |
||
3373 | add ecx,ted_rec_h |
||
1457 | IgorA | 3374 | |
6256 | IgorA | 3375 | mov edx,ted_color_wnd_work |
6274 | IgorA | 3376 | call ted_sel_normalize |
1457 | IgorA | 3377 | |
6274 | IgorA | 3378 | mov esi,ted_scr_w |
3379 | mov eax,[esi+sb_offs_position] |
||
3380 | sub ted_seln_y0,eax |
||
3381 | sub ted_seln_y1,eax |
||
1457 | IgorA | 3382 | |
6274 | IgorA | 3383 | mov eax,ted_cur_y |
3384 | cmp eax,ted_seln_y0 |
||
3385 | jl .no_cur_sel |
||
3386 | cmp eax,ted_seln_y1 |
||
3387 | jg .no_cur_sel |
||
6256 | IgorA | 3388 | mov edx,ted_color_select ;меняем цвет фона на цвет выделения |
3389 | mov esi,ted_scr_h |
||
6274 | IgorA | 3390 | cmp eax,ted_seln_y0 |
6256 | IgorA | 3391 | jne @f |
6274 | IgorA | 3392 | mov eax,ted_cur_x |
3393 | add eax,[esi+sb_offs_position] |
||
3394 | cmp eax,ted_seln_x0 |
||
6256 | IgorA | 3395 | jge @f |
3396 | mov edx,ted_color_wnd_work |
||
3397 | @@: |
||
6274 | IgorA | 3398 | mov eax,ted_cur_y |
3399 | cmp eax,ted_seln_y1 |
||
6256 | IgorA | 3400 | jne .no_cur_sel |
6274 | IgorA | 3401 | mov eax,ted_cur_x |
3402 | add eax,[esi+sb_offs_position] |
||
3403 | cmp eax,ted_seln_x1 |
||
6256 | IgorA | 3404 | jl .no_cur_sel |
3405 | mov edx,ted_color_wnd_work |
||
6274 | IgorA | 3406 | .no_cur_sel: |
3407 | mcall SF_DRAW_RECT |
||
1457 | IgorA | 3408 | |
6256 | IgorA | 3409 | call ted_get_pos_by_cursor ;берем позицию символа |
3410 | cmp ted_gp_opt,2 |
||
3411 | jne @f |
||
3412 | mov esi,1 |
||
3413 | ror ecx,16 |
||
3414 | mov bx,cx |
||
3415 | add ebx,0x10001 |
||
3416 | call ted_get_symb_color |
||
3417 | call ted_convert_invis_symb |
||
3418 | mcall SF_DRAW_TEXT ;рисование символа |
||
3419 | @@: |
||
3420 | popad |
||
3421 | ret |
||
1457 | IgorA | 3422 | endp |
3423 | |||
3424 | ;input: |
||
3425 | ; edx -> pointer to text |
||
3426 | ; edi -> указатель на структуру tedit |
||
3427 | ;output: |
||
3428 | ; ecx = color |
||
3429 | ; if ted_mode_color=0 then ecx=ted_color_wnd_text |
||
6274 | IgorA | 3430 | align 16 |
1457 | IgorA | 3431 | ted_get_symb_color: |
6256 | IgorA | 3432 | mov ecx,ted_color_wnd_text ;задаем цвет текста по умолчанию |
1457 | IgorA | 3433 | |
6256 | IgorA | 3434 | push eax edx |
3435 | cmp ted_mode_color,0 |
||
3436 | je .exit |
||
3437 | jmp .on_first |
||
3438 | @@: |
||
3439 | call ted_iterat_perv |
||
3440 | cmp edx,ted_tex_1 |
||
3441 | jle .exit |
||
3442 | .on_first: |
||
8533 | IgorA | 3443 | movzx eax,byte[edx+1] |
3444 | or eax,eax ;если al=0 то цвет не меняется |
||
6256 | IgorA | 3445 | jz @b |
1457 | IgorA | 3446 | |
6256 | IgorA | 3447 | cmp eax,ted_colors_text_count |
3448 | jge .exit |
||
1457 | IgorA | 3449 | |
6256 | IgorA | 3450 | mov ecx,ted_text_colors ;прибавляем смещение 1-го цвета |
8533 | IgorA | 3451 | lea ecx,[ecx+4*eax] |
7497 | IgorA | 3452 | mov ecx,[ecx] ;устанавливаем текущий цвет текста по смещению |
6256 | IgorA | 3453 | .exit: |
3454 | or ecx,ted_font_size |
||
3455 | pop edx eax |
||
3456 | ret |
||
1457 | IgorA | 3457 | |
3458 | ;input: |
||
3459 | ; edx = pointer to text |
||
3460 | ; edi = pointer to tedit struct |
||
3461 | ;description: |
||
3462 | ; Функция преобразует невидимые символы в печатаемые на экране |
||
6274 | IgorA | 3463 | align 16 |
1457 | IgorA | 3464 | ted_convert_invis_symb: |
1458 | IgorA | 3465 | cmp ted_mode_invis,1 |
6274 | IgorA | 3466 | jne .else |
1458 | IgorA | 3467 | cmp byte[edx],9 |
3468 | jne @f |
||
3469 | lea edx,[ted_symbol_tab] |
||
6274 | IgorA | 3470 | jmp .end_f |
3471 | align 4 |
||
1458 | IgorA | 3472 | @@: |
3473 | cmp byte[edx],13 |
||
3474 | jne @f |
||
3475 | mov edx,edi |
||
3476 | add edx,ted_offs_symbol_new_line |
||
3477 | @@: |
||
6274 | IgorA | 3478 | jmp .end_f |
3479 | align 4 |
||
3480 | .else: |
||
3481 | cmp byte[edx],9 |
||
3482 | je @f |
||
3483 | cmp byte[edx],13 |
||
8262 | IgorA | 3484 | jne .end_f |
6274 | IgorA | 3485 | @@: |
3486 | lea edx,[ted_symbol_space] |
||
1458 | IgorA | 3487 | .end_f: |
3488 | ret |
||
1457 | IgorA | 3489 | |
3490 | ;input: |
||
3491 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3492 | align 16 |
1457 | IgorA | 3493 | ted_scroll_set_redraw: |
3494 | push eax |
||
3495 | mov eax,ted_scr_w |
||
3496 | mov dword[eax+sb_offs_redraw],1 |
||
3497 | mov eax,ted_scr_h |
||
3498 | mov dword[eax+sb_offs_redraw],1 |
||
3499 | pop eax |
||
3500 | ret |
||
3501 | |||
6274 | IgorA | 3502 | align 16 |
1457 | IgorA | 3503 | proc ted_draw, edit:dword |
1458 | IgorA | 3504 | locals |
3505 | line_num dd ? |
||
3506 | endl |
||
3507 | pushad |
||
6274 | IgorA | 3508 | mov edi,[edit] |
1457 | IgorA | 3509 | |
6256 | IgorA | 3510 | mov eax,SF_DRAW_TEXT |
1458 | IgorA | 3511 | mov ecx,ted_text_colors |
7497 | IgorA | 3512 | mov ecx,[ecx] |
1457 | IgorA | 3513 | |
1458 | IgorA | 3514 | mov ebx,ted_wnd_l |
3515 | add ebx,ted_rec_l |
||
3516 | shl ebx,16 |
||
3517 | add ebx,ted_wnd_t |
||
3518 | add ebx,ted_rec_t |
||
3519 | add ebx,0x10001 ;добавляем отступы для выравнивания буквы по центру |
||
1457 | IgorA | 3520 | |
1458 | IgorA | 3521 | call ted_sel_normalize ;need before draw select |
3522 | mov esi,ted_scr_w |
||
6274 | IgorA | 3523 | mov esi,[esi+sb_offs_position] |
3524 | mov [line_num],esi |
||
1457 | IgorA | 3525 | |
1458 | IgorA | 3526 | stdcall ted_clear_line_before_draw, edi,ebx,1,esi |
3527 | call ted_get_first_visible_pos |
||
8262 | IgorA | 3528 | or edx,edx |
3529 | jz .no_draw_text |
||
1458 | IgorA | 3530 | mov esi,1 ;длинна выводимого текста по 1-му символу |
3531 | @@: |
||
3532 | call ted_iterat_next |
||
3533 | cmp edx,ted_tex_1 |
||
3534 | jle .no_draw_text |
||
1457 | IgorA | 3535 | |
1458 | IgorA | 3536 | ; *** цветовая разметка |
3537 | cmp ted_mode_color,0 |
||
3538 | je .no_col_change |
||
3539 | cmp byte[edx+1],0 |
||
3540 | je .no_col_change |
||
3541 | call ted_get_symb_color |
||
3542 | .no_col_change: |
||
1457 | IgorA | 3543 | |
6274 | IgorA | 3544 | cmp byte[edx],13 |
1458 | IgorA | 3545 | jne .no_13 |
3546 | cmp ted_mode_invis,1 |
||
3547 | jne .no_invis |
||
3548 | push edx |
||
3549 | mov edx,edi |
||
3550 | add edx,ted_offs_symbol_new_line |
||
3551 | int 0x40 |
||
3552 | pop edx |
||
3553 | .no_invis: |
||
3554 | add ebx,ted_rec_h |
||
3555 | ;optimized output \/ |
||
3556 | mov eax,ted_wnd_h |
||
3557 | add eax,ted_wnd_t |
||
3558 | cmp bx,ax |
||
3559 | jg .no_draw_text |
||
6256 | IgorA | 3560 | mov eax,SF_DRAW_TEXT |
1458 | IgorA | 3561 | ;optimized output /\ |
3562 | and ebx,0xffff |
||
3563 | ror ebx,16 |
||
3564 | add ebx,ted_wnd_l |
||
3565 | add ebx,ted_rec_l |
||
3566 | inc ebx |
||
3567 | ror ebx,16 |
||
3568 | inc dword[line_num] ;increment line number |
||
3569 | stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num] |
||
3570 | call ted_opt_draw_line_left |
||
3571 | jmp @b |
||
6256 | IgorA | 3572 | align 4 |
1458 | IgorA | 3573 | .no_13: |
1457 | IgorA | 3574 | |
1458 | IgorA | 3575 | int 0x40 |
3576 | ror ebx,16 |
||
3577 | add ebx,ted_rec_w |
||
3578 | mov esi,ted_wnd_l |
||
3579 | add esi,ted_wnd_w |
||
3580 | cmp bx,si |
||
3581 | jl .no_opt |
||
3582 | call ted_opt_draw_line_right |
||
3583 | .no_opt: |
||
3584 | mov si,1 |
||
3585 | ror ebx,16 |
||
3586 | jmp @b |
||
3587 | .no_draw_text: |
||
1457 | IgorA | 3588 | |
4988 | IgorA | 3589 | inc dword[line_num] |
1458 | IgorA | 3590 | stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num] |
3591 | call ted_draw_line_numbers |
||
3592 | call ted_draw_main_cursor |
||
1457 | IgorA | 3593 | |
3594 | ;--------------------------------------------- |
||
3595 | ; set all_redraw flag for draw all ScrollBar |
||
3596 | ; In some cases it is necessity to draw only the area |
||
3597 | ; of moving of a "runner", for acceleration of output - |
||
3598 | ; in this case the flag needs to be reset to 0 (zero). |
||
3599 | mov eax,ted_scr_h |
||
3600 | mov esi,ted_scr_w |
||
3601 | mov dword[eax+sb_offs_all_redraw],1 |
||
3602 | mov dword[esi+sb_offs_all_redraw],1 |
||
3603 | |||
3604 | ; рисование полос прокрутки |
||
3605 | stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw] |
||
3606 | stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw] |
||
3607 | ; reset all_redraw flag |
||
3608 | mov dword[eax+sb_offs_all_redraw],0 |
||
3609 | mov dword[esi+sb_offs_all_redraw],0 |
||
3610 | ;--------------------------------------------- |
||
3611 | |||
6087 | IgorA | 3612 | ;left-bottom square |
3613 | mov ebx,ted_wnd_l |
||
3614 | shl ebx,16 |
||
3615 | add ebx,ted_rec_l |
||
3616 | mov ecx,ted_wnd_t |
||
3617 | add ecx,ted_wnd_h |
||
3618 | shl ecx,16 |
||
3619 | mov cx,word[eax+sb_offs_size_y] |
||
3620 | inc cx |
||
6256 | IgorA | 3621 | mcall SF_DRAW_RECT,,,ted_color_wnd_capt ;[sc.work] |
1457 | IgorA | 3622 | |
3623 | ;right-bottom square |
||
3624 | mov ebx,ted_wnd_l |
||
3625 | add ebx,ted_wnd_w |
||
3626 | shl ebx,16 |
||
3627 | mov bx,word[esi+sb_offs_size_x] |
||
3628 | inc bx |
||
3629 | int 0x40 |
||
3630 | |||
7579 | IgorA | 3631 | cmp ted_fun_draw_panels,0 |
1457 | IgorA | 3632 | je @f |
7579 | IgorA | 3633 | stdcall ted_fun_draw_panels, edi |
1457 | IgorA | 3634 | @@: |
3635 | popad |
||
3636 | ret |
||
3637 | endp |
||
3638 | |||
3639 | ;input: |
||
3640 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3641 | align 16 |
1457 | IgorA | 3642 | proc ted_draw_main_cursor |
6274 | IgorA | 3643 | pushad |
3644 | mov eax,SF_DRAW_RECT ;draw cursor |
||
3645 | mov ecx,ted_wnd_t ;calc rect -> y0,y1 |
||
3646 | add ecx,ted_rec_t |
||
3647 | mov edx,ted_cur_y |
||
3648 | imul edx,ted_rec_h |
||
3649 | add ecx,edx |
||
1457 | IgorA | 3650 | |
6274 | IgorA | 3651 | shl ecx,16 |
3652 | add ecx,ted_rec_h |
||
1457 | IgorA | 3653 | |
6274 | IgorA | 3654 | mov ebx,ted_wnd_l ;calc rect -> x0,x1 |
3655 | add ebx,ted_rec_l |
||
3656 | mov edx,ted_cur_x |
||
3657 | imul edx,ted_rec_w |
||
3658 | add ebx,edx |
||
3659 | shl ebx,16 |
||
3660 | add ebx,ted_rec_w |
||
8532 | IgorA | 3661 | cmp ted_cur_ins,1 ;проверка режима работы курсора (обычный или вставка) |
3662 | jne @f |
||
3663 | shr bx,2 ;уменьшаем ширину курсора |
||
3664 | @@: |
||
1457 | IgorA | 3665 | |
6274 | IgorA | 3666 | mov edx,ted_color_cursor |
3667 | int 0x40 ;вывод курсора |
||
1457 | IgorA | 3668 | |
6274 | IgorA | 3669 | call ted_get_pos_by_cursor |
3670 | cmp ted_gp_opt,2 |
||
3671 | jne @f |
||
3672 | mov esi,1 |
||
3673 | ror ecx,16 |
||
3674 | mov bx,cx |
||
3675 | add ebx,0x10001 |
||
3676 | mov ecx,ted_color_cur_text |
||
3677 | or ecx,ted_font_size |
||
3678 | call ted_convert_invis_symb |
||
3679 | mcall SF_DRAW_TEXT |
||
3680 | @@: |
||
1457 | IgorA | 3681 | |
6274 | IgorA | 3682 | mov ebx,ted_wnd_l |
3683 | add ebx,ted_rec_l |
||
3684 | shl ebx,16 |
||
3685 | add ebx,ted_wnd_t |
||
3686 | add ebx,3 |
||
3687 | mov ecx,ted_color_wnd_bord |
||
3688 | or ecx,0x80000000 |
||
3689 | lea edx,[txtRow] |
||
3690 | mcall SF_DRAW_TEXT ;вывод подписи 'Строка' |
||
1457 | IgorA | 3691 | |
6274 | IgorA | 3692 | add ebx,0x500000 |
3693 | lea edx,[txtCol] |
||
3694 | int 0x40 ;вывод подписи 'Знак' |
||
1457 | IgorA | 3695 | |
6274 | IgorA | 3696 | cmp ted_tim_undo,0 |
3697 | je @f |
||
3698 | add ebx,0x500000 |
||
3699 | lea edx,[txtOtm] |
||
3700 | int 0x40 |
||
3701 | sub ebx,0x500000 |
||
3702 | @@: |
||
1457 | IgorA | 3703 | |
6274 | IgorA | 3704 | call ted_draw_buffer |
3705 | call ted_draw_help_f1 |
||
1457 | IgorA | 3706 | |
6274 | IgorA | 3707 | mov eax,47 ;draw cursor coords |
3708 | mov esi,ted_color_wnd_bord |
||
3709 | or esi,0x40000000 |
||
1457 | IgorA | 3710 | |
6274 | IgorA | 3711 | mov edx,ebx |
3712 | ror edx,16 |
||
3713 | sub edx,35 |
||
3714 | ror edx,16 |
||
3715 | ;add edx,3 |
||
3716 | mov ebx,0x40000 ;Row=... |
||
3717 | mov ecx,ted_scr_w |
||
3718 | mov ecx,[ecx+sb_offs_position] |
||
3719 | add ecx,ted_cur_y |
||
3720 | inc ecx |
||
1457 | IgorA | 3721 | |
3722 | push edi |
||
6274 | IgorA | 3723 | mov edi,ted_color_wnd_work |
3724 | int 0x40 ;вывод числа текущей строки |
||
1457 | IgorA | 3725 | pop edi |
3726 | |||
6274 | IgorA | 3727 | ;mov ebx,0x40000 ;Col=... |
3728 | mov ecx,ted_scr_h |
||
3729 | mov ecx,[ecx+sb_offs_position] |
||
3730 | add ecx,ted_cur_x |
||
3731 | inc ecx |
||
3732 | add edx,0x500000 |
||
1457 | IgorA | 3733 | push edi |
6274 | IgorA | 3734 | mov edi,ted_color_wnd_work |
3735 | int 0x40 ;вывод числа знаков |
||
1457 | IgorA | 3736 | pop edi |
3737 | |||
6274 | IgorA | 3738 | cmp ted_tim_undo,0 |
3739 | je @f |
||
3740 | mov ecx,ted_tim_undo |
||
3741 | add edx,0x500000 |
||
3742 | mov edi,ted_color_wnd_work ;портим регистр edi, но в конце функции это уже не важно |
||
3743 | int 0x40 ;вывод числа отмененных действий |
||
3744 | @@: |
||
1457 | IgorA | 3745 | |
6274 | IgorA | 3746 | popad |
3747 | ret |
||
1457 | IgorA | 3748 | endp |
3749 | |||
3750 | ;input: |
||
3751 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3752 | align 16 |
1457 | IgorA | 3753 | proc ted_draw_buffer |
3754 | pushad |
||
3755 | |||
3756 | mov eax,ted_buffer |
||
4228 | IgorA | 3757 | cmp dword[eax],1 ;смотрим размер буфера |
3758 | jl @f |
||
1458 | IgorA | 3759 | mov ebx,ted_rec_l |
1457 | IgorA | 3760 | add bx,300 |
1458 | IgorA | 3761 | cmp ebx,ted_wnd_w ;сравниваем координату для вывод текста |
3762 | jge @f ;подпись не влазит в окно |
||
3763 | |||
3764 | add ebx,ted_wnd_l |
||
1457 | IgorA | 3765 | shl ebx,16 |
3766 | add ebx,ted_wnd_t |
||
3767 | add ebx,3 |
||
3768 | mov ecx,ted_color_wnd_bord |
||
3769 | or ecx,0x40000000 |
||
3770 | |||
3771 | mov edx,ted_buffer |
||
4228 | IgorA | 3772 | add edx,12 |
1457 | IgorA | 3773 | mov esi,edx |
3774 | mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit |
||
3775 | call tl_strlen |
||
3776 | ;cmp eax,0 ;буфер пуст |
||
3777 | ;je @f |
||
3778 | cmp eax,20 |
||
3779 | jle .crop_buf |
||
3780 | mov eax,20 ;обрезка подписи до 20 символов |
||
3781 | .crop_buf: |
||
3782 | mov esi,eax |
||
6256 | IgorA | 3783 | mcall SF_DRAW_TEXT ;вывод содержимого буфера |
1457 | IgorA | 3784 | |
3785 | sub ebx,50 shl 16 |
||
3786 | lea edx,[txtBuf] |
||
3787 | mov esi,edx |
||
3788 | call tl_strlen |
||
3789 | mov esi,eax |
||
3790 | xor ecx,0x40000000 ;убираем цвет фона |
||
6256 | IgorA | 3791 | mcall SF_DRAW_TEXT ;вывод подписи для буфера |
1457 | IgorA | 3792 | @@: |
3793 | popad |
||
3794 | ret |
||
3795 | endp |
||
3796 | |||
3797 | ;input: |
||
3798 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3799 | align 16 |
1457 | IgorA | 3800 | proc ted_draw_help_f1 |
1458 | IgorA | 3801 | pushad |
3802 | cmp ted_rec_t,13 ;минимальная высота для рисования справки |
||
3803 | jle @f |
||
6087 | IgorA | 3804 | ;clear place before draw help |
1458 | IgorA | 3805 | mov ebx,ted_wnd_l |
3806 | add ebx,ted_rec_l |
||
3807 | shl ebx,16 |
||
3808 | add ebx,ted_wnd_w |
||
3809 | sub ebx,ted_rec_l |
||
3810 | mov ecx,ted_wnd_t |
||
3811 | add ecx,13 |
||
3812 | shl ecx,16 |
||
6256 | IgorA | 3813 | add ecx,9 ;9 - высота 0-го шрифта, ставить ted_rec_h пока еще рано |
3814 | mcall SF_DRAW_RECT,,,ted_color_wnd_capt |
||
1457 | IgorA | 3815 | |
1458 | IgorA | 3816 | cmp ted_help_id,-1 |
3817 | je @f |
||
3818 | mov eax,ted_help_id |
||
3819 | ColToIndexOffset eax,edx |
||
1457 | IgorA | 3820 | |
1458 | IgorA | 3821 | ;SetCoordinates |
3822 | mov ebx,ted_wnd_l |
||
3823 | add ebx,ted_rec_l |
||
3824 | shl ebx,16 |
||
3825 | add ebx,ted_wnd_t |
||
3826 | add ebx,13 ;=3+10 |
||
1457 | IgorA | 3827 | |
1458 | IgorA | 3828 | ;SetTextColor |
8533 | IgorA | 3829 | movzx eax,byte[edx+MAX_COLOR_WORD_LEN+7] |
3830 | shl eax,2 |
||
1458 | IgorA | 3831 | mov ecx,ted_text_colors |
3832 | add ecx,eax |
||
6274 | IgorA | 3833 | mov ecx,[ecx] |
1458 | IgorA | 3834 | or ecx,0xc0000000 ;SetTextStyles |
3835 | mov esi,edi |
||
6256 | IgorA | 3836 | mcall SF_DRAW_TEXT,,,,,ted_color_wnd_work |
1458 | IgorA | 3837 | mov edi,esi |
1457 | IgorA | 3838 | |
6087 | IgorA | 3839 | mov esi,edx |
3840 | call tl_strlen |
||
3841 | |||
1458 | IgorA | 3842 | ;*** draw help string *** |
3843 | mov ecx,ted_color_wnd_bord |
||
3844 | or ecx,0x80000000 |
||
6274 | IgorA | 3845 | mov edx,[edx+MAX_COLOR_WORD_LEN] |
3846 | or edx,edx |
||
3847 | jz @f |
||
1458 | IgorA | 3848 | add edx,ted_help_text_f1 |
6087 | IgorA | 3849 | inc eax |
3850 | imul eax,6 ;ширина символа в сист. шрифте |
||
3851 | shl eax,16 |
||
3852 | add ebx,eax |
||
6256 | IgorA | 3853 | mcall SF_DRAW_TEXT |
1458 | IgorA | 3854 | @@: |
3855 | popad |
||
3856 | ret |
||
1457 | IgorA | 3857 | endp |
3858 | |||
3859 | ;input: |
||
3860 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 3861 | align 16 |
1457 | IgorA | 3862 | proc ted_draw_line_numbers |
6256 | IgorA | 3863 | pushad |
3864 | ;top panel with caption |
||
3865 | mov ebx,ted_wnd_l |
||
6274 | IgorA | 3866 | ;add ebx,ted_rec_l |
6256 | IgorA | 3867 | shl ebx,16 |
3868 | add ebx,ted_wnd_w |
||
6274 | IgorA | 3869 | ;sub ebx,ted_rec_l |
6256 | IgorA | 3870 | mov edx,ted_color_wnd_work |
3871 | mov ecx,ted_wnd_t |
||
3872 | shl ecx,16 |
||
3873 | add ecx,ted_rec_t |
||
3874 | mov edx,ted_color_wnd_capt |
||
3875 | mcall SF_DRAW_RECT |
||
1457 | IgorA | 3876 | |
6256 | IgorA | 3877 | ;line numbers |
3878 | mov ebx,0x40000 ;format |
||
3879 | mov ecx,ted_scr_w |
||
6274 | IgorA | 3880 | mov ecx,[ecx+sb_offs_position] |
6256 | IgorA | 3881 | inc ecx |
3882 | mov edx,3 |
||
3883 | add edx,ted_wnd_l |
||
3884 | rol edx,16 |
||
3885 | add edx,ted_wnd_t |
||
3886 | add edx,ted_rec_t |
||
3887 | @@: |
||
1457 | IgorA | 3888 | |
3889 | push ebx ecx edx |
||
6256 | IgorA | 3890 | ;left panel with numbers |
3891 | mov ebx,ted_wnd_l |
||
3892 | shl ebx,16 |
||
3893 | add ebx,ted_rec_l |
||
3894 | mov ecx,ted_rec_h |
||
3895 | rol ecx,16 |
||
3896 | mov cx,dx |
||
3897 | rol ecx,16 |
||
3898 | mov edx,ted_color_wnd_capt |
||
3899 | mcall SF_DRAW_RECT ;рисуем прямоугольник под номером строки |
||
1457 | IgorA | 3900 | pop edx ecx ebx |
3901 | |||
6256 | IgorA | 3902 | mov esi,ted_color_wnd_bord |
6274 | IgorA | 3903 | mcall SF_DRAW_NUMBER ;рисуем номер строки |
6256 | IgorA | 3904 | inc ecx |
3905 | add edx,ted_rec_h |
||
3906 | sub edx,ted_wnd_t |
||
3907 | mov esi,edx |
||
3908 | and esi,0xffff |
||
3909 | cmp esi,ted_wnd_h |
||
3910 | jge @f |
||
3911 | add edx,ted_wnd_t |
||
3912 | jmp @b |
||
3913 | align 4 |
||
3914 | @@: |
||
3915 | popad |
||
3916 | ret |
||
1457 | IgorA | 3917 | endp |
3918 | |||
3919 | ;output: |
||
3920 | ; ah = symbol |
||
6274 | IgorA | 3921 | align 16 |
3922 | proc KeyConvertToASCII uses ebx, table:dword |
||
3923 | mov ebx,[table] ;convert scan to ascii |
||
7579 | IgorA | 3924 | shr ax,8 |
1464 | IgorA | 3925 | add bx,ax ;? ebx,eax |
3926 | mov ah,byte[ebx] |
||
3927 | ret |
||
1457 | IgorA | 3928 | endp |
3929 | |||
6274 | IgorA | 3930 | align 16 |
1457 | IgorA | 3931 | proc ted_draw_cur_line, edit:dword |
6274 | IgorA | 3932 | pushad |
3933 | mov edi,[edit] |
||
1457 | IgorA | 3934 | |
6274 | IgorA | 3935 | mov ebx,ted_wnd_l |
3936 | add ebx,ted_rec_l |
||
3937 | shl ebx,16 |
||
3938 | mov eax,ted_cur_y |
||
3939 | imul eax,ted_rec_h |
||
1457 | IgorA | 3940 | mov bx,ax |
6274 | IgorA | 3941 | add ebx,ted_wnd_t |
3942 | add ebx,ted_rec_t ;ebx - координаты для прямоугольника очистки линии |
||
1457 | IgorA | 3943 | add ebx,0x10001 ;добавляем отступы для выравнивания буквы по центру |
3944 | |||
6274 | IgorA | 3945 | call ted_sel_normalize ;need before draw select |
1457 | IgorA | 3946 | mov ecx,ted_cur_y |
3947 | mov eax,ted_scr_w |
||
6274 | IgorA | 3948 | add ecx,[eax+sb_offs_position] |
3949 | stdcall ted_clear_line_before_draw,edi,ebx,1,ecx |
||
1457 | IgorA | 3950 | |
6274 | IgorA | 3951 | mov eax,ted_scr_h |
3952 | mov esi,[eax+sb_offs_position] |
||
3953 | call ted_get_pos_by_coords |
||
1457 | IgorA | 3954 | |
6274 | IgorA | 3955 | cmp ted_gp_opt,2 |
3956 | jne .no_draw_text |
||
3957 | call ted_get_symb_color |
||
3958 | mov esi,1 ;draw 1 symbol |
||
3959 | @@: |
||
3960 | ;call ted_iterat_next |
||
3961 | cmp edx,ted_tex_1 |
||
3962 | jle .no_draw_text |
||
1457 | IgorA | 3963 | |
6274 | IgorA | 3964 | ; *** цветовая разметка |
3965 | cmp ted_mode_color,0 |
||
3966 | je .no_col_change |
||
3967 | cmp byte[edx+1],0 |
||
3968 | je .no_col_change |
||
3969 | call ted_get_symb_color |
||
3970 | .no_col_change: |
||
1457 | IgorA | 3971 | |
6274 | IgorA | 3972 | mov eax,SF_DRAW_TEXT |
3973 | cmp byte [edx],13 |
||
3974 | jne .no_13 |
||
3975 | cmp ted_mode_invis,1 |
||
3976 | jne .no_draw_text |
||
3977 | push edx |
||
3978 | mov edx,edi |
||
3979 | add edx,ted_offs_symbol_new_line |
||
3980 | int 0x40 |
||
3981 | pop edx |
||
3982 | jmp .no_draw_text |
||
3983 | align 4 |
||
3984 | .no_13: |
||
1457 | IgorA | 3985 | |
6274 | IgorA | 3986 | int 0x40 |
3987 | ror ebx,16 |
||
3988 | add ebx,ted_rec_w |
||
3989 | mov eax,ted_wnd_w |
||
3990 | add eax,ted_wnd_l ;ax = отступ по оси x |
||
3991 | cmp bx,ax |
||
3992 | jge .no_draw_text ;Opt |
||
3993 | ror ebx,16 |
||
3994 | call ted_iterat_next |
||
3995 | jmp @b |
||
3996 | align 4 |
||
3997 | .no_draw_text: |
||
1457 | IgorA | 3998 | |
6274 | IgorA | 3999 | call ted_draw_main_cursor |
4000 | popad |
||
4001 | ret |
||
1457 | IgorA | 4002 | endp |
4003 | |||
4004 | ;input: |
||
4005 | ; clear_o - если =1 очистить одну строку, =0 очистить все строки окна до низу |
||
6274 | IgorA | 4006 | align 16 |
1457 | IgorA | 4007 | proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword |
4008 | pushad |
||
6274 | IgorA | 4009 | mov edi,[edit] |
4010 | mov ebx,[coords] ;ebx = x*2^16+y coords to left up point clear line |
||
4011 | mov esi,[numb_lin] ;esi - number text line |
||
1457 | IgorA | 4012 | |
4013 | sub ebx,0x10001 ;отнимаем отступы для выравнивания буквы по центру |
||
4014 | cmp dword[clear_o],0 |
||
4015 | jne @f |
||
4016 | add ebx,ted_rec_h |
||
4017 | ror ebx,16 |
||
4018 | xor bx,bx |
||
4019 | add ebx,ted_wnd_l |
||
4020 | add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l |
||
4021 | ror ebx,16 |
||
4022 | @@: |
||
4023 | |||
4024 | mov eax,ted_wnd_h |
||
4025 | add eax,ted_wnd_t |
||
4026 | cmp ax,bx |
||
4027 | jl .no_clear |
||
4028 | sub ax,bx |
||
4029 | |||
4030 | mov cx,bx |
||
4031 | shl ecx,16 |
||
4032 | |||
4033 | xor bx,bx |
||
4034 | add ebx,ted_wnd_w |
||
4035 | sub ebx,ted_rec_l |
||
4036 | xor cx,cx |
||
4037 | add ecx,ted_rec_h |
||
4038 | mov edx,ted_color_wnd_work |
||
4039 | |||
4040 | cmp dword[clear_o],0 |
||
4041 | je .pusto |
||
4042 | cmp ax,cx |
||
4043 | jge @f |
||
4044 | .pusto: |
||
4045 | mov cx,ax |
||
4988 | IgorA | 4046 | jmp .no_select ;если очистка окна до низу, то всегда фоновым цветом |
1457 | IgorA | 4047 | @@: |
4048 | |||
4049 | call ted_is_select |
||
7576 | IgorA | 4050 | or al,al |
4051 | jz .no_select |
||
1457 | IgorA | 4052 | cmp ted_seln_y0,esi |
4988 | IgorA | 4053 | jg .no_select |
1457 | IgorA | 4054 | cmp ted_seln_y1,esi |
4988 | IgorA | 4055 | jl .no_select |
1457 | IgorA | 4056 | mov edx,ted_color_select ;draw selected line |
4988 | IgorA | 4057 | .no_select: |
1457 | IgorA | 4058 | |
6256 | IgorA | 4059 | mcall SF_DRAW_RECT ;закраска полной строки цветом фона или цветом выделения |
1457 | IgorA | 4060 | |
4061 | call ted_is_select |
||
6256 | IgorA | 4062 | or al,al |
4063 | jz .no_clear |
||
1457 | IgorA | 4064 | |
6256 | IgorA | 4065 | mov al,SF_DRAW_RECT |
1457 | IgorA | 4066 | xor cx,cx |
4067 | add ecx,ted_rec_h |
||
4068 | cmp ted_seln_y0,esi |
||
4069 | jne @f |
||
4070 | push bx esi |
||
4071 | mov edx,ted_seln_x0 ; верхняя полоса (затирает слева) |
||
4072 | mov esi,ted_scr_h |
||
6274 | IgorA | 4073 | cmp edx,[esi+sb_offs_position] |
1457 | IgorA | 4074 | jle .in_wnd |
6274 | IgorA | 4075 | sub edx,[esi+sb_offs_position] |
1457 | IgorA | 4076 | imul edx,ted_rec_w |
4077 | mov bx,dx |
||
4078 | jmp .no_wnd |
||
4079 | .in_wnd: |
||
7497 | IgorA | 4080 | xor bx,bx |
1457 | IgorA | 4081 | .no_wnd: |
4082 | mov edx,ted_color_wnd_work |
||
4083 | int 0x40 |
||
4084 | pop esi bx |
||
4085 | @@: |
||
4086 | cmp ted_seln_y1,esi |
||
4087 | jne @f |
||
4988 | IgorA | 4088 | ;push esi |
4089 | ;если выделен весь файл тут можно сделать выход, но тогда нужно выше убрать jmp .no_select |
||
1457 | IgorA | 4090 | mov edx,ted_seln_x1 ; нижняя полоса (затирает справа) |
4091 | mov esi,ted_scr_h |
||
6274 | IgorA | 4092 | cmp edx,[esi+sb_offs_position] |
1457 | IgorA | 4093 | jle .in_wnd2 |
6274 | IgorA | 4094 | sub edx,[esi+sb_offs_position] |
1457 | IgorA | 4095 | imul edx,ted_rec_w |
4096 | sub bx,dx |
||
4097 | shl edx,16 |
||
4098 | add ebx,edx |
||
4099 | .in_wnd2: |
||
4100 | mov edx,ted_color_wnd_work |
||
4101 | int 0x40 |
||
4988 | IgorA | 4102 | ;pop esi |
1457 | IgorA | 4103 | @@: |
4104 | |||
4105 | .no_clear: |
||
4106 | popad |
||
4107 | ret |
||
4108 | endp |
||
4109 | |||
4110 | ;input: |
||
4111 | ; edi = pointer to tedit struct |
||
4112 | ;output: |
||
4113 | ; ecx = новый цвет символа |
||
4114 | ; edx = pointer to symbol |
||
4115 | ; edx = 0 if text not in screen |
||
6274 | IgorA | 4116 | align 16 |
1457 | IgorA | 4117 | ted_get_first_visible_pos: |
4118 | push eax ecx |
||
4119 | mov eax,ted_scr_w |
||
4120 | mov edx,ted_tex |
||
4121 | xor ecx,ecx |
||
4122 | @@: |
||
6274 | IgorA | 4123 | cmp ecx,[eax+sb_offs_position] |
1457 | IgorA | 4124 | je @f |
4125 | call ted_iterat_next |
||
4126 | cmp edx,ted_tex_1 |
||
4127 | jle @f |
||
6256 | IgorA | 4128 | cmp byte[edx],13 |
1457 | IgorA | 4129 | jne @b |
4130 | inc ecx |
||
4131 | jmp @b |
||
6256 | IgorA | 4132 | align 4 |
1457 | IgorA | 4133 | @@: |
4134 | |||
6274 | IgorA | 4135 | cmp ecx,[eax+sb_offs_position] |
1457 | IgorA | 4136 | je @f |
4137 | xor edx,edx |
||
4138 | @@: |
||
6274 | IgorA | 4139 | cmp ecx,[eax+sb_offs_max_area] |
1457 | IgorA | 4140 | jle @f |
6274 | IgorA | 4141 | mov [eax+sb_offs_max_area],ecx |
1457 | IgorA | 4142 | @@: |
4143 | pop ecx eax |
||
4144 | call ted_opt_draw_line_left |
||
4145 | ret |
||
4146 | |||
4147 | ;input: |
||
4148 | ; edx = pointer to symbol |
||
4149 | ; edi = pointer to tedit struct |
||
4150 | ;output: |
||
4151 | ; ecx = цвет символа |
||
4152 | ; edx = указатель на первый левый символ |
||
4153 | ;description: |
||
4154 | ; функция нужна для оптимизации вывода текста |
||
6274 | IgorA | 4155 | align 16 |
6256 | IgorA | 4156 | proc ted_opt_draw_line_left uses ebx |
4157 | mov ebx,ted_scr_h |
||
6274 | IgorA | 4158 | mov ebx,[ebx+sb_offs_position] |
6256 | IgorA | 4159 | or ebx,ebx |
4160 | jz .ret_f |
||
4161 | push eax |
||
4162 | mov eax,edx |
||
1457 | IgorA | 4163 | |
6256 | IgorA | 4164 | cmp edx,ted_tex |
4165 | jne @f |
||
4166 | call ted_iterat_next |
||
4167 | jmp .beg_cycle |
||
4168 | @@: |
||
1457 | IgorA | 4169 | |
6256 | IgorA | 4170 | or ebx,ebx |
4171 | jz @f |
||
1457 | IgorA | 4172 | |
6256 | IgorA | 4173 | cmp byte[edx],13 |
4174 | jne @f |
||
4175 | call ted_iterat_next |
||
4176 | .beg_cycle: |
||
4177 | @@: |
||
4178 | cmp edx,ted_tex_1 |
||
4179 | jle @f |
||
4180 | cmp byte[edx],13 |
||
4181 | je @f |
||
4182 | or ebx,ebx |
||
4183 | jz @f |
||
1457 | IgorA | 4184 | ;-------------------------------------- |
8533 | IgorA | 4185 | ;eax будет меняться |
4186 | movzx eax,byte[edx+1] |
||
4187 | or eax,eax |
||
6256 | IgorA | 4188 | jz .no_color |
1457 | IgorA | 4189 | cmp eax,ted_colors_text_count |
4190 | jge .no_color |
||
8533 | IgorA | 4191 | movzx ecx,byte[edx+1] |
4192 | shl ecx,2 |
||
6256 | IgorA | 4193 | add ecx,ted_text_colors |
6274 | IgorA | 4194 | mov ecx,[ecx] |
1457 | IgorA | 4195 | .no_color: |
4196 | ;-------------------------------------- |
||
6256 | IgorA | 4197 | mov eax,edx |
4198 | call ted_iterat_next |
||
4199 | dec ebx |
||
4200 | jmp @b |
||
4201 | align 4 |
||
4202 | @@: |
||
4203 | mov edx,eax |
||
4204 | pop eax |
||
4205 | .ret_f: |
||
4206 | call ted_get_symb_color |
||
4207 | ret |
||
1457 | IgorA | 4208 | endp |
4209 | |||
4210 | ;input: |
||
4211 | ; edx = pointer to symbol |
||
4212 | ; edi = pointer to tedit struct |
||
4213 | ;output: |
||
4214 | ; ecx = symbol color |
||
4215 | ; edx = pointer to 13 symbol |
||
4216 | ;description: |
||
4217 | ; функция нужна для оптимизации вывода текста |
||
6274 | IgorA | 4218 | align 16 |
7583 | IgorA | 4219 | proc ted_opt_draw_line_right uses eax |
1457 | IgorA | 4220 | mov eax,edx |
4221 | @@: |
||
4222 | cmp edx,ted_tex_1 |
||
4223 | jle @f |
||
4224 | cmp byte[edx],13 |
||
4225 | je @f |
||
4226 | mov eax,edx |
||
4227 | call ted_iterat_next |
||
4228 | jmp @b |
||
4229 | @@: |
||
4230 | mov edx,eax ;perv sumbol |
||
4231 | call ted_get_symb_color |
||
4232 | ret |
||
4233 | endp |
||
4234 | |||
6274 | IgorA | 4235 | align 16 |
1457 | IgorA | 4236 | proc ted_mouse, edit:dword |
4237 | pushad |
||
6274 | IgorA | 4238 | mov edi,[edit] |
1457 | IgorA | 4239 | |
4240 | ;обрабатываем скроллинги |
||
4241 | mov edx,ted_scr_h |
||
4242 | mov ecx,ted_scr_w |
||
4243 | |||
4244 | cmp word[edx+sb_offs_delta2],0 |
||
4245 | jne .horizontal |
||
4246 | |||
6274 | IgorA | 4247 | mov eax,[ecx+sb_offs_max_area] |
4248 | cmp eax,[ecx+sb_offs_cur_area] |
||
1457 | IgorA | 4249 | jbe .horizontal |
4250 | ; mouse event for Vertical ScrollBar |
||
4251 | stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse] |
||
4252 | cmp dword[ecx+sb_offs_redraw],0 |
||
4253 | je @f |
||
4254 | mov dword[ecx+sb_offs_redraw],0 |
||
4255 | stdcall ted_draw,edi |
||
4256 | jmp .no_in_wnd |
||
4257 | @@: |
||
4258 | cmp word[ecx+sb_offs_delta2],0 |
||
4259 | jne .no_in_wnd |
||
4260 | .horizontal: |
||
6274 | IgorA | 4261 | mov eax,[edx+sb_offs_max_area] |
4262 | cmp eax,[edx+sb_offs_cur_area] |
||
1457 | IgorA | 4263 | jbe .other |
4264 | ; mouse event for Horizontal ScrollBar |
||
4265 | stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse] |
||
4266 | cmp dword[edx+sb_offs_redraw],0 |
||
4267 | je .other |
||
4268 | mov dword[edx+sb_offs_redraw],0 |
||
4269 | stdcall ted_draw,edi |
||
4270 | jmp .no_in_wnd |
||
4271 | .other: |
||
4272 | cmp word[ecx+sb_offs_delta2],0 |
||
4273 | jne .no_in_wnd |
||
4274 | cmp word[edx+sb_offs_delta2],0 |
||
4275 | jne .no_in_wnd |
||
4276 | |||
4277 | ;обрабатываем окно редактора |
||
6274 | IgorA | 4278 | mcall SF_MOUSE_GET,SSF_BUTTON |
1457 | IgorA | 4279 | cmp al,1 |
4280 | jne @f |
||
6274 | IgorA | 4281 | mcall SF_MOUSE_GET,SSF_WINDOW_POSITION |
1457 | IgorA | 4282 | mov ebx,ted_wnd_t |
4283 | add ebx,ted_rec_t |
||
4284 | cmp ax,bx |
||
4285 | jl @f ;y_mouse |
||
4286 | |||
4287 | sub ebx,ted_rec_t |
||
4288 | add ebx,ted_wnd_h |
||
4289 | cmp bx,ax |
||
4290 | jl @f ;y_mouse>y_wnd |
||
4291 | |||
4292 | mov ebx,ted_wnd_l |
||
4293 | add ebx,ted_rec_l |
||
4294 | mov ecx,eax |
||
4295 | shr ecx,16 |
||
4296 | cmp cx,bx |
||
4297 | jl @f ;x_mouse |
||
4298 | |||
4299 | sub ebx,ted_rec_l |
||
4300 | add ebx,ted_wnd_w |
||
4301 | cmp bx,cx |
||
4302 | jl @f ;x_mouse>x_wnd |
||
4303 | |||
4304 | call ted_draw_cursor_sumb |
||
4305 | call ted_wnd_main_click |
||
4306 | jmp .no_in_wnd |
||
4307 | @@: |
||
1458 | IgorA | 4308 | mov edx,ted_el_focus |
6274 | IgorA | 4309 | cmp [edx],edi |
1458 | IgorA | 4310 | jne @f |
4311 | call ted_wnd_main_mouse_scroll ;смотрим на прокрутку колеса мыши |
||
4312 | @@: |
||
1457 | IgorA | 4313 | cmp ted_drag_m,0 |
4314 | je .no_in_wnd |
||
4315 | mov ted_drag_m,0 |
||
4316 | stdcall ted_draw,edi |
||
4317 | cmp ted_fun_draw_panel_buttons,0 |
||
4318 | je .no_in_wnd |
||
4319 | call ted_fun_draw_panel_buttons |
||
4320 | .no_in_wnd: |
||
4321 | popad |
||
4322 | ret |
||
4323 | endp |
||
4324 | |||
4325 | ;input: |
||
4326 | ; eax -> (x,y) |
||
4327 | ; edi -> указатель на структуру tedit |
||
4328 | ;description: |
||
4329 | ; функция вызывется при нажатии кнопкой мыши и попадении курсором в окно редактора |
||
6274 | IgorA | 4330 | align 16 |
1457 | IgorA | 4331 | ted_wnd_main_click: |
1458 | IgorA | 4332 | push ebx ecx edx |
4333 | mov ebx,ted_el_focus |
||
6274 | IgorA | 4334 | mov [ebx],edi ;ставим фокус |
1457 | IgorA | 4335 | |
6087 | IgorA | 4336 | push eax |
4337 | shr eax,16 |
||
4338 | sub eax,ted_wnd_l |
||
4339 | sub eax,ted_rec_l |
||
1457 | IgorA | 4340 | |
6087 | IgorA | 4341 | xor edx,edx |
4342 | mov ecx,ted_rec_w |
||
4343 | div cx |
||
4344 | ;inc eax |
||
4345 | mov ebx,ted_scr_h |
||
6274 | IgorA | 4346 | cmp eax,[ebx+sb_offs_cur_area] |
6087 | IgorA | 4347 | jle @f |
6274 | IgorA | 4348 | mov eax,[ebx+sb_offs_cur_area] |
6087 | IgorA | 4349 | @@: |
4350 | ;dec eax |
||
4351 | mov ted_cur_x,eax |
||
4352 | pop eax |
||
1457 | IgorA | 4353 | |
6087 | IgorA | 4354 | push eax |
4355 | and eax,0xffff |
||
4356 | sub eax,ted_wnd_t |
||
4357 | sub eax,ted_rec_t |
||
1457 | IgorA | 4358 | |
6087 | IgorA | 4359 | xor edx,edx |
4360 | mov ecx,ted_rec_h |
||
4361 | div cx |
||
4362 | inc eax |
||
4363 | mov ebx,ted_scr_w |
||
6274 | IgorA | 4364 | cmp eax,[ebx+sb_offs_cur_area] |
6087 | IgorA | 4365 | jle @f |
6274 | IgorA | 4366 | mov eax,[ebx+sb_offs_cur_area] |
6087 | IgorA | 4367 | @@: |
4368 | dec eax |
||
4369 | mov ted_cur_y,eax |
||
4370 | pop eax |
||
1457 | IgorA | 4371 | |
1458 | IgorA | 4372 | cmp ted_drag_m,0 |
4373 | je @f |
||
4374 | call ted_sel_move |
||
4375 | jmp .sel_move |
||
4376 | @@: |
||
4377 | mov ted_drag_m,1 |
||
4378 | call ted_sel_start |
||
4379 | .sel_move: |
||
4380 | pop edx ecx ebx |
||
4381 | ret |
||
1457 | IgorA | 4382 | |
4383 | ;input: |
||
4384 | ; edi = pointer to tedit struct |
||
6274 | IgorA | 4385 | align 16 |
1457 | IgorA | 4386 | ted_wnd_main_mouse_scroll: |
4387 | push eax ebx ecx |
||
6274 | IgorA | 4388 | mcall SF_MOUSE_GET,SSF_SCROLL_DATA |
4389 | or ax,ax |
||
4390 | jz .no_scroll |
||
1457 | IgorA | 4391 | mov ecx,ted_scr_w |
7877 | IgorA | 4392 | movsx eax,ax |
4393 | lea eax,[eax+eax*2] ;умножаем на 3 (число строк прокрутки за одно движение колеса мыши) |
||
4394 | add eax,[ecx+sb_offs_position] |
||
4395 | mov ebx,[ecx+sb_offs_max_area] |
||
4396 | shl ebx,1 |
||
4397 | sub ebx,[ecx+sb_offs_cur_area] ;отнимаем половину высоты окна |
||
4398 | shr ebx,1 |
||
4399 | cmp eax,ebx |
||
4400 | jae .no_scroll |
||
8532 | IgorA | 4401 | mov ebx,ted_cur_y ;позиция курсора |
4402 | sub ebx,eax ;- новая позиция скроллинга |
||
4403 | add ebx,[ecx+sb_offs_position] ;+ старая позиция скроллинга |
||
4404 | bt ebx,31 |
||
4405 | jnc @f |
||
4406 | xor ebx,ebx ;если курсор стал выше окна, то ставим на верхнюю строку |
||
4407 | @@: |
||
4408 | inc ebx |
||
4409 | cmp ebx,[ecx+sb_offs_cur_area] |
||
4410 | jle @f |
||
4411 | mov ebx,[ecx+sb_offs_cur_area] ;если курсор стал ниже окна, то ставим на нижнюю строку |
||
4412 | @@: |
||
4413 | dec ebx |
||
4414 | mov ted_cur_y,ebx |
||
7877 | IgorA | 4415 | mov [ecx+sb_offs_position],eax |
1458 | IgorA | 4416 | stdcall ted_draw,edi |
1457 | IgorA | 4417 | .no_scroll: |
4418 | pop ecx ebx eax |
||
4419 | ret |
||
4420 | |||
6274 | IgorA | 4421 | align 16 |
4308 | IgorA | 4422 | proc ted_save_file, edit:dword, file:dword, f_name:dword |
6274 | IgorA | 4423 | pushad |
4424 | mov edi,[edit] |
||
1457 | IgorA | 4425 | |
6274 | IgorA | 4426 | stdcall ted_can_save,edi |
4427 | ;or al,al |
||
4428 | ;jz .no_save |
||
1457 | IgorA | 4429 | |
6274 | IgorA | 4430 | mov ecx,ted_max_chars |
4431 | invoke mem.alloc,ecx |
||
4432 | push eax ;запоминаем указатель на выделенную память |
||
1457 | IgorA | 4433 | |
6274 | IgorA | 4434 | mov edx,ted_tex |
4435 | xor ecx,ecx |
||
4436 | @@: |
||
4437 | call ted_iterat_next |
||
4438 | cmp edx,ted_tex_1 |
||
4439 | jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol |
||
4440 | mov bl,[edx] |
||
4441 | mov byte[eax],bl |
||
4442 | inc eax |
||
4443 | inc ecx |
||
4444 | jmp @b |
||
4445 | align 4 |
||
4446 | @@: |
||
1457 | IgorA | 4447 | |
6274 | IgorA | 4448 | or ecx,ecx |
4449 | jz @f |
||
4450 | mov ebx,[file] |
||
4451 | pop eax ;записываем указатель на выделенную память |
||
4452 | mov [ebx+16],eax |
||
4453 | push eax ;обратно запоминаем указатель на выделенную память |
||
4454 | mov dword[ebx], SSF_CREATE_FILE |
||
4455 | mov dword[ebx+4], 0 |
||
4456 | mov dword[ebx+8], 0 |
||
4457 | mov [ebx+12], ecx |
||
4458 | mov byte[ebx+20], 0 |
||
4459 | push dword[f_name] |
||
4460 | pop dword[ebx+21] |
||
4461 | mcall SF_FILE |
||
1457 | IgorA | 4462 | |
6274 | IgorA | 4463 | mov ted_err_save,al |
1457 | IgorA | 4464 | |
6274 | IgorA | 4465 | or eax,eax |
4466 | jz .no_msg |
||
4467 | cmp ax,10 |
||
4468 | jl .zifra_0_9 |
||
4469 | mov al,'?' |
||
4470 | sub ax,48 |
||
4471 | .zifra_0_9: |
||
4472 | add ax,48 |
||
4473 | cmp ted_fun_save_err,0 |
||
4474 | je @f |
||
4475 | call ted_fun_save_err |
||
4476 | jmp @f |
||
4477 | .no_msg: |
||
4478 | m2m ted_tim_ls,ted_tim_ch |
||
4479 | @@: |
||
1457 | IgorA | 4480 | |
6274 | IgorA | 4481 | pop ecx ;записываем указатель на выделенную память |
4482 | invoke mem.free,ecx |
||
4483 | .no_save: |
||
4484 | popad |
||
4485 | ret |
||
1457 | IgorA | 4486 | endp |