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