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