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