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