Rev 1390 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1338 | IgorA | 1 | struct f70 |
2 | func_n dd ? |
||
3 | param1 dd ? |
||
4 | param2 dd ? |
||
5 | param3 dd ? |
||
6 | param4 dd ? |
||
7 | rezerv db ? |
||
8 | name dd ? |
||
9 | ends |
||
10 | |||
11 | struct TexColViv |
||
12 | Text rb MAX_COLOR_WORD_LEN; // слово |
||
13 | f1 dd 0 |
||
14 | wwo db ? ; whole words only |
||
15 | endc db ? ; символ конца выделения (wwo&4) |
||
16 | color db ? ; номер цвета |
||
17 | ends |
||
18 | |||
19 | struct symbol |
||
20 | c db ? ; +0 символ |
||
21 | col db ? ; +1 цвет |
||
22 | perv dd ? ; +2 |
||
23 | next dd ? ; +6 указатели |
||
24 | tc dd ? ; +10 врем. создания |
||
25 | td dd ? ; +14 врем. удаления |
||
26 | ends |
||
27 | |||
28 | ColColor dd 1 |
||
29 | ColWords dd 0 |
||
30 | CURSOR_COLOR dd 0x808080 |
||
31 | WND_CAPT_COLOR dd 0x80 |
||
32 | WND_WORK_COLOR dd 0x0 |
||
33 | WND_BORD_COLOR dd 0xd0d0d0 |
||
34 | SELECT_COLOR dd 0x208080 |
||
35 | CUR_TEXT_COLOR dd 0xff0000 |
||
36 | WND_TEXT_COLOR dd 0xffff00 |
||
37 | |||
38 | options_file dd 0 |
||
39 | options_file_end dd 0 |
||
40 | tex_colors dd 0 |
||
41 | tex_help_f1 dd 0 |
||
42 | |||
43 | FkPos: rd 256 |
||
44 | Col dd 0 ;указатель на структуры ключевых слов TexColViv |
||
45 | |||
46 | conv_tabl rb 128 ; таблица для конвертирования scan-кода в ascii-код |
||
47 | keyUpr dd 0 |
||
1449 | IgorA | 48 | |
1338 | IgorA | 49 | err_sav db 0 ;ошибка сохранения файла |
50 | panel_id db 0 ;номер открытой панели |
||
51 | |||
52 | ch_tim dd ? ; количество изменений в файле |
||
53 | ls_tim dd ? ; время последнего сохранения |
||
54 | co_tim dd ? ; время последней цветовой разметки |
||
55 | tim_Undo dd ? ; количество отмененных действий |
||
56 | gpOpt db 0 |
||
57 | mode_colored db 1 ; режим выделения слов цветом (0-выкл. 1-вкл.) |
||
58 | |||
59 | key_new db 0 ; символ, который будет добавлятся с клавиатуры |
||
1390 | IgorA | 60 | tex dd 0 ;text memory pointer |
61 | tex_1 dd 0 ;text first symbol pointer |
||
1343 | IgorA | 62 | tex_end dd 0 ;text end memory pointer |
1338 | IgorA | 63 | |
64 | curMod db 1 |
||
65 | cur_x dd 0 |
||
66 | cur_y dd 0 |
||
67 | invis db 0 ;режим показа непечатаемых символов |
||
68 | symbol_new_line db 20 ;символ завершения строки |
||
69 | help_id dd -1 ;идентификатор для справки |
||
70 | |||
1449 | IgorA | 71 | hed db 'TextEditor 15.04.10',0 ;подпись окна |
72 | sc system_colors |
||
73 | |||
1338 | IgorA | 74 | fn_icon db 'te_icon.bmp',0 |
75 | bmp_icon dd 0 |
||
76 | run_file_70 f70 |
||
77 | |||
78 | |||
79 | ;input: |
||
80 | ; reg = index |
||
81 | ;output: |
||
82 | ; reg = pointer to 'tex' struct |
||
83 | macro ConvertIndexToPointer reg { |
||
84 | imul reg,sizeof.symbol |
||
85 | add reg,[tex] |
||
86 | } |
||
87 | |||
88 | |||
89 | ;output: |
||
90 | ; al = 1 - can save |
||
91 | CanSave: |
||
92 | push ecx |
||
93 | mov ecx,[ch_tim] |
||
94 | sub ecx,[tim_Undo] |
||
95 | mov al,1 |
||
96 | cmp [ls_tim],ecx |
||
97 | jne @f |
||
98 | dec al |
||
99 | @@: |
||
100 | pop ecx |
||
101 | ret |
||
102 | |||
103 | |||
104 | ;output: |
||
105 | ; al = 1 - selected |
||
1449 | IgorA | 106 | proc IsSel, edit:dword |
107 | push ebx edi |
||
108 | mov edi,dword[edit] |
||
1338 | IgorA | 109 | xor al,al |
1449 | IgorA | 110 | cmp ted_drag_m,1 |
1338 | IgorA | 111 | je @f |
112 | mov al,1 |
||
113 | mov ebx,[sel.x0] |
||
114 | cmp ebx,[sel.x1] |
||
115 | jne @f |
||
116 | mov ebx,[sel.y0] |
||
117 | cmp ebx,[sel.y1] |
||
118 | jne @f |
||
119 | xor al,al |
||
120 | @@: |
||
1449 | IgorA | 121 | pop edi ebx |
1338 | IgorA | 122 | ret |
1449 | IgorA | 123 | endp |
1338 | IgorA | 124 | |
125 | SelNormalize: |
||
126 | push ecx esi edi |
||
127 | mov esi,sel |
||
128 | mov edi,seln |
||
129 | mov ecx,sizeof.TexSelect |
||
130 | rep movsb |
||
131 | |||
132 | jmp @f |
||
133 | .swp_f: |
||
134 | mov ecx,[seln.x0] |
||
135 | m2m [seln.x0],[seln.x1] |
||
136 | mov [seln.x1],ecx |
||
137 | |||
138 | mov ecx,[seln.y0] |
||
139 | cmp ecx,[seln.y1] ;(sel.y0>sel.y1) |
||
140 | jle .end_f |
||
141 | m2m [seln.y0],[seln.y1] |
||
142 | mov [seln.y1],ecx |
||
143 | |||
144 | jmp .end_f |
||
145 | @@: |
||
146 | |||
147 | mov ecx,[seln.y0] |
||
148 | cmp ecx,[seln.y1] ;(sel.y0>sel.y1) |
||
149 | jg .swp_f |
||
150 | |||
151 | cmp ecx,[seln.y1] ;(sel.y0==sel.y1) |
||
152 | jne .end_f |
||
153 | mov ecx,[seln.x0] |
||
154 | cmp ecx,[seln.x1] ;(sel.x0>sel.x1) |
||
155 | jg .swp_f |
||
156 | |||
157 | .end_f: |
||
158 | pop edi esi ecx |
||
159 | ret |
||
160 | |||
161 | SelStart: |
||
162 | push ecx |
||
163 | mov ecx,[cur_x] |
||
164 | add ecx,[hScr.position] |
||
165 | mov [sel.x0],ecx |
||
166 | mov [sel.x1],ecx |
||
167 | |||
168 | mov ecx,[cur_y] |
||
169 | add ecx,[wScr.position] |
||
170 | mov [sel.y0],ecx |
||
171 | mov [sel.y1],ecx |
||
172 | pop ecx |
||
173 | ret |
||
174 | |||
1343 | IgorA | 175 | align 4 |
1338 | IgorA | 176 | SelMove: |
177 | push ecx |
||
178 | mov ecx,[cur_x] |
||
179 | add ecx,[hScr.position] |
||
180 | mov [sel.x1],ecx |
||
181 | |||
182 | mov ecx,[cur_y] |
||
183 | add ecx,[wScr.position] |
||
184 | mov [sel.y1],ecx |
||
185 | pop ecx |
||
1343 | IgorA | 186 | call draw_but_toolbar ;redraw toolbar (need to button Copy) |
1338 | IgorA | 187 | ret |
188 | |||
189 | ;input: |
||
190 | ; al = 1 - clear all memory |
||
191 | Clear: |
||
192 | mov [cur_x],0 |
||
193 | mov [cur_y],0 |
||
194 | mov [ch_tim],0 |
||
195 | mov [ls_tim],0 |
||
196 | mov [co_tim],0 |
||
197 | mov [tim_Undo],0 |
||
198 | mov [help_id],-1 |
||
199 | |||
200 | mov [wScr.position],0 |
||
201 | mov [wScr.max_area],100 |
||
202 | mov [wScr.redraw],1 |
||
203 | mov [hScr.position],0 |
||
204 | mov [hScr.max_area],100 |
||
205 | |||
206 | mov [sel.x0],0 |
||
207 | mov [sel.y0],0 |
||
208 | mov [sel.x1],0 |
||
209 | mov [sel.y1],0 |
||
210 | |||
211 | cmp al,0 |
||
212 | je .exit |
||
213 | |||
214 | push ecx edx |
||
215 | mov ecx,sizeof.symbol*maxChars |
||
216 | mov edx,[tex] |
||
217 | @@: |
||
218 | mov byte [edx],0 |
||
219 | inc edx |
||
220 | loop @b |
||
221 | mov edx,[tex] |
||
222 | mov dword [edx+6],1 |
||
223 | pop edx ecx |
||
224 | |||
225 | .exit: |
||
226 | ret |
||
227 | |||
228 | |||
229 | ;--- out_reg = Col[keyw[ind_reg]].Text[0] --- |
||
230 | macro ColToIndexOffset ind_reg,out_reg { |
||
231 | mov out_reg,ind_reg |
||
232 | imul out_reg,sizeof.TexColViv |
||
233 | add out_reg,[Col] |
||
234 | } |
||
235 | |||
236 | |||
237 | |||
238 | InitColText: |
||
239 | push eax ebx ecx esi edi |
||
240 | |||
241 | mov ebx,dword[fn_col_option] |
||
1390 | IgorA | 242 | copy_path ebx,fn_syntax_dir,file_name_rez,0x0 |
243 | copy_path file_name_rez,sys_path,file_name,0x0 |
||
1338 | IgorA | 244 | |
245 | mov eax,70 |
||
246 | mov [run_file_70.func_n], 0 |
||
247 | mov [run_file_70.param1], 0 |
||
248 | mov [run_file_70.param2], 0 |
||
249 | mov ebx,[options_file_end] |
||
250 | sub ebx,[options_file] |
||
251 | mov [run_file_70.param3], ebx |
||
252 | m2m [run_file_70.param4], [options_file] |
||
253 | mov [run_file_70.rezerv], 0 |
||
254 | mov [run_file_70.name], file_name |
||
255 | mov ebx,run_file_70 |
||
256 | int 0x40 |
||
257 | |||
258 | mov ecx,0x100 |
||
259 | mov edi,FkPos |
||
260 | @@: |
||
261 | mov dword[edi],-1 |
||
262 | add edi,4 |
||
263 | loop @b |
||
264 | |||
265 | ;init: ColColor, ColWords, ... |
||
266 | mov dword[ColColor],1 |
||
267 | mov dword[ColWords],0 |
||
268 | mov dword[tex_help_f1],0 |
||
269 | mov [help_id],-1 ;идентификатор слова для справки |
||
270 | |||
271 | cmp eax,6 |
||
272 | je @f |
||
273 | cmp eax,0 |
||
274 | je @f |
||
275 | cmp ax,10 |
||
276 | jl .zifra_0_9 |
||
277 | mov al,'?' |
||
278 | sub ax,48 |
||
279 | .zifra_0_9: |
||
280 | add ax,48 |
||
281 | |||
282 | mov byte[msgbox_3.err],al |
||
283 | push thread |
||
284 | push msgbox_3 |
||
285 | call [mb_create] ;message: Can-t open color options file! |
||
286 | jmp .no_colors |
||
287 | @@: |
||
288 | |||
289 | mov esi,[options_file] |
||
290 | mov edi,ColColor |
||
291 | mov ecx,9*4 |
||
292 | rep movsb |
||
293 | |||
294 | mov eax,[options_file] |
||
295 | add eax,32 |
||
296 | mov dword[tex_colors],eax |
||
297 | |||
298 | mov eax,dword[ColColor] ;init: Col (offset to key words) |
||
299 | add eax,8 |
||
300 | shl eax,2 |
||
301 | add eax,[options_file] |
||
302 | mov dword[Col],eax |
||
303 | |||
304 | mov ecx,dword[ColWords] ;init: FkPos (first key positions) |
||
305 | xor eax,eax |
||
306 | @@: |
||
307 | ColToIndexOffset eax,edi |
||
308 | xor ebx,ebx |
||
309 | mov bl,byte[edi] |
||
310 | shl bx,2 |
||
311 | mov esi,FkPos |
||
312 | add esi,ebx |
||
313 | cmp dword[esi],-1 |
||
314 | jne .no_ch_key |
||
315 | mov dword[esi],eax |
||
316 | .no_ch_key: |
||
317 | inc eax |
||
318 | loop @b |
||
319 | |||
320 | ;init: tex_help_f1 |
||
321 | mov ecx,dword[ColWords] |
||
322 | imul ecx,sizeof.TexColViv |
||
323 | add ecx,dword[Col] |
||
324 | mov dword[tex_help_f1],ecx |
||
325 | |||
326 | .no_colors: |
||
327 | pop edi esi ecx ebx eax |
||
328 | ret |
||
329 | |||
330 | |||
331 | ;input: |
||
332 | ; ebx = file size |
||
333 | OpenFile: |
||
334 | push eax ;destination |
||
335 | push ecx ;for cycle |
||
336 | push edx ;source |
||
337 | |||
338 | xor al,al |
||
339 | call Clear |
||
340 | mov eax,ebx |
||
341 | mov ecx,ebx |
||
342 | add eax,2 |
||
343 | ConvertIndexToPointer eax |
||
344 | mov edx,[tex] |
||
345 | add edx,ebx |
||
346 | push ebx |
||
347 | @@: |
||
348 | mov ebx,[edx] |
||
349 | mov byte [eax],bl |
||
350 | mov dword [eax+2],ecx |
||
351 | inc dword [eax+2] |
||
352 | mov dword [eax+6],ecx |
||
353 | add dword [eax+6],3 |
||
354 | ;mov byte[eax+1],0 ;col=0 |
||
355 | mov dword [eax+10],-1 ;tc=-1 |
||
356 | mov dword [eax+14],0 ;td=0 |
||
357 | |||
358 | cmp ecx,0 |
||
359 | je @f |
||
360 | dec ecx |
||
361 | dec edx |
||
362 | sub eax,sizeof.symbol |
||
363 | jmp @b |
||
364 | @@: |
||
365 | pop ebx |
||
366 | add eax,2 |
||
367 | mov dword [eax],0 ; first sumbol 'perv=0' |
||
368 | |||
369 | mov edx,[tex] |
||
370 | ; begining sumbol 'perv=0' 'next=2' |
||
371 | mov dword [edx+2],0 |
||
372 | mov dword [edx+6],2 |
||
373 | |||
374 | add edx,sizeof.symbol |
||
375 | mov dword [edx+6],0 ; last sumbol 'next=0' |
||
376 | mov dword [edx+2],ebx ; last sumbol 'perv=last' |
||
377 | inc dword [edx+2] |
||
378 | |||
379 | mov edx,ebx |
||
380 | inc edx ;2 = rezerv sumbols |
||
381 | imul edx,sizeof.symbol |
||
382 | add edx,[tex] |
||
383 | mov dword [edx+6],1 ; last sumbol 'next=1' |
||
384 | |||
385 | @@: ;clear memory, need if before was open big file |
||
386 | add edx,sizeof.symbol |
||
387 | cmp edx,[tex_end] |
||
388 | jge @f |
||
389 | mov dword[edx+10],0 |
||
390 | mov dword[edx+14],0 |
||
391 | jmp @b |
||
392 | @@: |
||
393 | |||
394 | call GetNumLines |
||
395 | cmp eax,100 |
||
396 | jge @f |
||
397 | mov eax,100 |
||
398 | @@: |
||
399 | mov [wScr.max_area],eax |
||
400 | ; mov [wScr.redraw],1 |
||
401 | pop edx ecx eax |
||
402 | call CmColored |
||
403 | ret |
||
404 | |||
405 | ;input: |
||
406 | ; edx = pointer to symbol struct |
||
407 | ;output: |
||
408 | ; edx = pointer to 'perv' visible symbol struct |
||
409 | IteratPerv: |
||
410 | cmp [tim_Undo],0 |
||
411 | je .else |
||
412 | push ebx |
||
413 | @@: |
||
414 | call GetTexPervPos |
||
415 | cmp edx,[tex] |
||
416 | je @f |
||
417 | call SymbNotVis |
||
418 | cmp bl,1 |
||
419 | je @b |
||
420 | cmp byte[edx],10 ;пропуск символа с кодом 10 |
||
421 | je @b |
||
422 | @@: |
||
423 | pop ebx |
||
424 | ret |
||
425 | .else: |
||
426 | call GetTexPervPos |
||
427 | cmp edx,[tex] |
||
428 | je .endif |
||
429 | cmp dword [edx+14],0 |
||
430 | jne .else |
||
431 | cmp byte[edx],10 ;пропуск символа с кодом 10 |
||
432 | je .else |
||
433 | .endif: |
||
434 | ret |
||
435 | |||
436 | |||
437 | ;input: |
||
438 | ; edx = pointer to symbol struct |
||
439 | ;output: |
||
440 | ; edx = pointer to 'next' visible symbol struct |
||
441 | IteratNext: |
||
442 | cmp [tim_Undo],0 |
||
443 | je .else |
||
444 | push ebx |
||
445 | @@: |
||
446 | call GetTexNextPos |
||
447 | cmp edx,[tex_1] |
||
448 | jle @f |
||
449 | call SymbNotVis |
||
450 | cmp bl,1 |
||
451 | je @b |
||
452 | cmp byte[edx],10 ;пропуск символа с кодом 10 |
||
453 | je @b |
||
454 | @@: |
||
455 | pop ebx |
||
456 | ret |
||
457 | .else: |
||
458 | call GetTexNextPos |
||
459 | cmp edx,[tex_1] |
||
460 | jle .endif |
||
461 | cmp dword [edx+14],0 |
||
462 | jne .else |
||
463 | cmp byte[edx],10 ;пропуск символа с кодом 10 |
||
464 | je .else |
||
465 | .endif: |
||
466 | ret |
||
467 | |||
468 | ;input: |
||
469 | ; edx = pointer to symbol struct |
||
470 | ; bl = symbol end of select |
||
471 | ItPoNextUc: |
||
472 | @@: |
||
473 | cmp bl,byte[edx] |
||
474 | je @f |
||
475 | cmp edx,[tex_1] |
||
476 | jle @f |
||
477 | call IteratNext |
||
478 | jmp @b |
||
479 | @@: |
||
480 | call IteratNext |
||
481 | ret |
||
482 | |||
483 | ;input: |
||
484 | ; edx = pointer to symbol struct |
||
485 | ItPervColorTag: |
||
486 | @@: |
||
487 | cmp byte[edx+1],0 |
||
488 | jne @f |
||
489 | call IteratPerv |
||
490 | cmp edx,[tex_1] |
||
491 | jle @f |
||
492 | jmp @b |
||
493 | @@: |
||
494 | ret |
||
495 | |||
496 | ;input: |
||
497 | ; edx = pointer to symbol struct |
||
498 | ItNextColorTag: |
||
499 | @@: |
||
500 | call IteratNext |
||
501 | cmp byte[edx+1],0 |
||
502 | jne @f |
||
503 | cmp edx,[tex_1] |
||
504 | jle @f |
||
505 | jmp @b |
||
506 | @@: |
||
507 | ;call IteratNext |
||
508 | ret |
||
509 | |||
510 | ;input: |
||
511 | ; edx = pointer to symbol struct |
||
512 | ;output: |
||
513 | ; bl = 1 if sumbol not visible |
||
514 | ; (tex[i].td+tim_Undo<=ch_tim && tex[i].td) || (tex[i].tc>ch_tim-tim_Undo) |
||
515 | SymbNotVis: |
||
516 | push eax |
||
517 | |||
518 | xor bl,bl |
||
519 | |||
520 | cmp dword [edx+14],0 |
||
521 | je @f |
||
522 | mov eax,[edx+14] ;eax=tex[i].td |
||
523 | add eax,[tim_Undo] |
||
524 | cmp eax,[ch_tim] |
||
525 | jg @f |
||
526 | mov bl,1 |
||
527 | pop eax |
||
528 | ret |
||
529 | @@: |
||
530 | |||
531 | mov eax,[ch_tim] |
||
532 | sub eax,[tim_Undo] |
||
533 | cmp [edx+10],eax |
||
534 | jle @f |
||
535 | or bl,1 |
||
536 | @@: |
||
537 | |||
538 | pop eax |
||
539 | ret |
||
540 | |||
541 | |||
542 | ;input: |
||
543 | ; bh = 1 - move cursor after text add |
||
544 | ; bl = 1 - change time when text add |
||
545 | ; esi = add text len |
||
546 | ; edi = pointer to text string |
||
547 | TextAdd: |
||
548 | push ebp |
||
549 | mov ebp,esp |
||
550 | sub esp,4*2 |
||
551 | |||
552 | push eax ;po_t |
||
553 | push ecx edx edi |
||
554 | |||
555 | call GetPos |
||
556 | call GetTexPervPos |
||
557 | call GetTexArrIndex ;eax=po_t |
||
558 | |||
559 | mov dword[ebp-4],0 ;count new spaces |
||
560 | cmp [gpOpt],2 |
||
561 | je @f |
||
562 | push eax ebx ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos); |
||
563 | mov eax,[cur_x] |
||
564 | add eax,[hScr.position] |
||
565 | mov dword[ebp-4],eax |
||
566 | |||
567 | mov eax,[cur_y] |
||
568 | add eax,[wScr.position] |
||
569 | call StrLen |
||
570 | sub dword[ebp-4],ebx |
||
571 | pop ebx eax |
||
572 | @@: |
||
573 | |||
574 | mov dword[ebp-8],0 ;count new lines |
||
575 | cmp [gpOpt],0 |
||
576 | jne @f |
||
577 | push eax |
||
578 | mov eax,[cur_y] |
||
579 | add eax,[wScr.position] |
||
580 | inc eax |
||
581 | mov dword[ebp-8],eax |
||
582 | |||
583 | call GetNumLines |
||
584 | sub dword[ebp-8],eax |
||
585 | pop eax |
||
586 | @@: |
||
587 | |||
588 | mov edx,sizeof.symbol |
||
589 | shl edx,1 |
||
590 | add edx,[tex] |
||
591 | @@: ;for(i=2;i |
||
592 | cmp dword [edx+10],0 ;if(!tex[i].tc && !tex[i].td) |
||
593 | jne .u1f |
||
594 | cmp dword [edx+14],0 |
||
595 | jne .u1f |
||
596 | cmp bl,0 ;if(n_tim) ch_tim++; |
||
597 | je .no_tim |
||
598 | inc [ch_tim] |
||
599 | .no_tim: |
||
600 | cmp bh,0 |
||
601 | je .no_cur_mov |
||
602 | cmp dword[ebp-8],0 ;если есть добавочные строки, то курсор еще не двигаем |
||
603 | jg .no_cur_mov |
||
604 | cmp dword[ebp-4],0 ;если нет добавочных пробелов, то курсор тоже не двигаем |
||
605 | jg .no_cur_mov |
||
606 | inc [cur_x] ;move cursor |
||
607 | ;call GoToPos |
||
608 | cmp byte [edi],13 |
||
609 | jne .no_cur_mov |
||
610 | mov [cur_x],0 |
||
611 | inc [cur_y] |
||
612 | .no_cur_mov: |
||
613 | |||
614 | xor bl,bl ;n_tim=false; |
||
615 | |||
616 | mov cl,byte [edi] ;tex[i].c=ta[ns]; |
||
617 | mov byte [edx],cl |
||
618 | m2m dword [edx+10],dword [ch_tim] ;tex[i].tc=ch_tim; |
||
619 | mov [edx+2],eax ;tex[i].perv=po_t; |
||
620 | |||
621 | mov ecx,eax |
||
622 | imul ecx,sizeof.symbol |
||
623 | add ecx,[tex] ; *** ecx = tex[po_t] *** |
||
624 | add ecx,6 ; *** ecx = tex[po_t].next *** |
||
625 | m2m dword [edx+6],dword [ecx] ;tex[i].next=tex[po_t].next; |
||
626 | |||
627 | call GetTexArrIndex ;*** eax = i *** |
||
628 | cmp eax,maxChars |
||
629 | jge @f |
||
630 | mov [ecx],eax ;tex[po_t].next=i; // ссылки перенаправляем |
||
631 | mov ecx,[edx+6] ; *** ecx = tex[i].next *** |
||
632 | imul ecx,sizeof.symbol |
||
633 | add ecx,[tex] ; *** ecx = tex[tex[i].next] *** |
||
634 | mov [ecx+2],eax ;tex[tex[i].next].perv=i; |
||
635 | |||
636 | cmp dword[ebp-8],0 ;add lines or text |
||
637 | jle .spc_add |
||
638 | dec dword[ebp-8] |
||
639 | mov byte [edx],13 |
||
640 | jmp .u1f |
||
641 | .spc_add: |
||
642 | cmp dword[ebp-4],0 ;add spaces or text |
||
643 | jle .tex_add |
||
644 | dec dword[ebp-4] |
||
645 | mov byte [edx],' ' |
||
646 | jmp .u1f |
||
647 | .tex_add: |
||
648 | inc edi |
||
649 | dec esi |
||
650 | .u1f: |
||
651 | add edx,sizeof.symbol |
||
652 | cmp edx,[tex_end] |
||
653 | jge @f ;out of memory |
||
654 | cmp esi,0 |
||
655 | jne @b |
||
656 | @@: |
||
657 | |||
658 | pop edi edx ecx eax |
||
659 | mov esp,ebp ; восстанавливаем стек |
||
660 | pop ebp |
||
661 | call CmColored |
||
662 | ret |
||
663 | |||
664 | |||
665 | |||
666 | ;input: |
||
667 | ; ecx = position to free insert cell |
||
668 | ; edx = pointer to sumbol, when insert |
||
669 | ; esi = pointer to added symbol |
||
670 | ;output: |
||
671 | ; ecx = position to inserted cell |
||
672 | CharAdd: |
||
673 | |||
674 | .loop_b: |
||
675 | cmp ecx,[tex_end] |
||
676 | jge .end_f |
||
677 | cmp dword[ecx+10],0 |
||
678 | jne @f |
||
679 | cmp dword[ecx+14],0 |
||
680 | je .loop_e |
||
681 | @@: |
||
682 | add ecx,sizeof.symbol |
||
683 | jmp .loop_b |
||
684 | .loop_e: |
||
685 | |||
686 | push eax ebx |
||
687 | mov eax,[ch_tim] |
||
688 | mov dword[ecx+10],eax |
||
689 | mov al,byte[esi] |
||
690 | mov byte[ecx],al |
||
691 | |||
692 | call GetTexArrIndex ; *** eax=pos *** |
||
693 | mov [ecx+2],eax ;tex[i].perv=pos; |
||
694 | m2m dword[ecx+6],dword[edx+6] ;tex[i].next=tex[pos].next; |
||
695 | |||
696 | push edx |
||
697 | mov edx,ecx |
||
698 | call GetTexArrIndex ; *** eax=i *** |
||
699 | pop edx |
||
700 | |||
701 | mov [edx+6],eax ;tex[pos].next=i; // ссылки перенаправляем |
||
702 | mov ebx,[ecx+6] |
||
703 | ConvertIndexToPointer ebx |
||
704 | mov [ebx+2],eax ;tex[tex[i].next].perv=i; // ... |
||
705 | pop ebx eax |
||
706 | |||
707 | .end_f: |
||
708 | call CmColored |
||
709 | ret |
||
710 | |||
711 | |||
712 | ;input: |
||
713 | ; conv_table = pointert to convert table |
||
714 | ;output: |
||
715 | ; edi = count converted symbols |
||
716 | ConvertSelText: |
||
717 | xor edi,edi |
||
718 | push eax ebx ecx edx esi |
||
1449 | IgorA | 719 | stdcall IsSel, tedit0 |
1338 | IgorA | 720 | cmp al,0 |
721 | je .end_f |
||
722 | call SetUndo |
||
723 | call SelNormalize |
||
724 | |||
725 | mov esi,[seln.x0] |
||
726 | mov ecx,[seln.y0] |
||
727 | call GetPosByParam |
||
728 | mov eax,edx |
||
729 | mov esi,[seln.x1] |
||
730 | mov ecx,[seln.y1] |
||
731 | call GetPosByParam |
||
732 | ;call GetTexPervPos |
||
733 | mov ebx,edx |
||
734 | |||
735 | cmp eax,ebx |
||
736 | je .end_f |
||
737 | |||
738 | inc [ch_tim] |
||
739 | mov edx,eax ;i=p0; |
||
740 | mov ecx,2 |
||
741 | ConvertIndexToPointer ecx |
||
742 | @@: |
||
743 | mov esi,[edx] |
||
744 | and esi,0xff |
||
745 | add esi,[conv_table] ;EvUpper |
||
746 | cmp byte [esi],0 |
||
747 | je .no_change |
||
748 | m2m dword [edx+14],dword [ch_tim] |
||
749 | call CharAdd ;b_pos=CharAdd(tex[i].c^32,i,false,b_pos); |
||
750 | call GetTexNextPos ;go to added symbol |
||
751 | inc edi |
||
752 | .no_change: |
||
753 | |||
754 | call IteratNext |
||
755 | cmp edx,[tex] |
||
756 | je @f |
||
757 | cmp edx,ebx |
||
758 | je @f |
||
759 | |||
760 | jmp @b |
||
761 | @@: |
||
762 | cmp edi,0 |
||
763 | jne @f |
||
764 | dec [ch_tim] |
||
765 | @@: |
||
766 | .end_f: |
||
767 | pop esi edx ecx ebx eax |
||
768 | |||
769 | ret |
||
770 | |||
771 | ;input: |
||
772 | ; bh = (0-backspace, 1-delete) |
||
773 | ; bl = 1 - change time |
||
774 | ;output: |
||
775 | ; bl = 0 - no delete |
||
776 | ; bl = 1 - delete |
||
777 | TextDel: |
||
778 | push edx cx |
||
779 | xor cl,cl |
||
780 | cmp bh,1 |
||
781 | je @f |
||
782 | call CurMoveLeft |
||
783 | cmp dl,0 |
||
784 | je .no_del |
||
785 | @@: |
||
786 | call GetPos |
||
787 | cmp [gpOpt],1 |
||
788 | je .no_del |
||
789 | cmp bl,0 |
||
790 | je @f |
||
791 | inc [ch_tim] |
||
792 | @@: |
||
793 | m2m dword [edx+14], dword [ch_tim] |
||
794 | mov cl,1 |
||
795 | .no_del: |
||
796 | mov bl,cl |
||
797 | pop cx edx |
||
798 | ret |
||
799 | |||
800 | |||
801 | |||
802 | ;input: |
||
803 | ; eax = pointer to begin select |
||
804 | ; ebx = pointer to end select |
||
805 | Revers: |
||
806 | cmp eax,ebx |
||
807 | jne @f |
||
808 | ret |
||
809 | @@: |
||
810 | |||
811 | push ecx edx |
||
812 | |||
813 | mov edx,[tex_1] |
||
814 | cmp edx,ebx ;if(p1==1)p1=tex[1].perv; |
||
815 | jne @f |
||
816 | call GetTexPervPos |
||
817 | mov ebx,edx |
||
818 | @@: |
||
819 | |||
820 | push esi |
||
821 | mov edx,[eax+2] ; *** edx = tex[p0].perv *** |
||
822 | ConvertIndexToPointer edx |
||
823 | add edx,6 |
||
824 | mov ecx,[edx] ;tmp = tex[tex[p0].perv].next; |
||
825 | |||
826 | mov esi,[ebx+6] ; *** esi = tex[p1].next *** |
||
827 | ConvertIndexToPointer esi |
||
828 | add esi,2 |
||
829 | m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv; |
||
830 | |||
831 | mov [esi],ecx ;tex[tex[p1].next].perv = tmp; |
||
832 | pop esi |
||
833 | |||
834 | mov ecx,[eax+2] ;tmp = tex[p0].perv; |
||
835 | m2m dword[eax+2],dword[ebx+6] ;tex[p0].perv = tex[p1].next; |
||
836 | mov [ebx+6],ecx ;tex[p1].next = tmp; |
||
837 | |||
838 | mov edx,eax ;i=p0; |
||
839 | @@: |
||
840 | mov ecx,[edx+6] ;tmp = tex[i].next; |
||
841 | m2m dword[edx+6],dword[edx+2] ;tex[i].next = tex[i].perv; |
||
842 | mov [edx+2],ecx ;tex[i].perv = tmp; |
||
843 | cmp edx,ebx ;if(i==p1)break; |
||
844 | je @f |
||
845 | ; --- |
||
846 | ;cmp edx,[tex] |
||
847 | ;je @f |
||
848 | ; --- |
||
849 | mov edx,ecx ;i = tmp; |
||
850 | ConvertIndexToPointer edx |
||
851 | jmp @b |
||
852 | @@: |
||
853 | pop edx ecx |
||
854 | call CmColored |
||
855 | ret |
||
856 | |||
857 | |||
858 | ;output: |
||
859 | ; dl = 0 not move |
||
860 | ; dl = 2 if move up |
||
861 | ; dl = 8 if scroll move up |
||
862 | CurMoveUp: |
||
863 | cmp [cur_y],0 |
||
864 | je @f |
||
865 | dec [cur_y] |
||
866 | mov dl,2 |
||
867 | ret |
||
868 | @@: |
||
869 | cmp [wScr.position],0 |
||
870 | je @f |
||
871 | dec [wScr.position] |
||
872 | mov dl,8 |
||
873 | ret |
||
874 | @@: |
||
875 | mov dl,0 |
||
876 | ret |
||
877 | |||
878 | ;output: |
||
879 | ; dl = 0 not move |
||
880 | ; dl = 2 if move down |
||
881 | ; dl = 8 if scroll move down |
||
882 | CurMoveDown: |
||
883 | push eax |
||
884 | mov dl,0 |
||
885 | mov eax,[wScr.cur_area] |
||
886 | dec eax |
||
887 | cmp [cur_y],eax |
||
888 | jge @f |
||
889 | inc [cur_y] |
||
890 | mov dl,2 |
||
891 | jmp .ret_f |
||
892 | @@: |
||
893 | mov eax,[cur_y] |
||
894 | add eax,[wScr.position] |
||
895 | inc eax |
||
896 | cmp [wScr.max_area],eax |
||
897 | jle @f |
||
898 | inc [wScr.position] |
||
899 | mov dl,8 |
||
900 | @@: |
||
901 | .ret_f: |
||
902 | pop eax |
||
903 | ret |
||
904 | |||
905 | |||
906 | ;output: |
||
907 | ; dl = 0 not move |
||
908 | ; dl = 1 if move up |
||
909 | CurMovePageUp: |
||
910 | push eax |
||
911 | mov eax,[wScr.cur_area] |
||
912 | xor dl,dl |
||
913 | cmp eax,[wScr.position] |
||
914 | jg @f |
||
915 | sub [wScr.position],eax |
||
916 | mov dl,1 |
||
917 | @@: |
||
918 | cmp [wScr.position],0 |
||
919 | je @f |
||
920 | cmp dl,1 |
||
921 | je @f |
||
922 | mov [wScr.position],0 |
||
923 | mov dl,1 |
||
924 | @@: |
||
925 | pop eax |
||
926 | ret |
||
927 | |||
928 | CurMovePageDown: |
||
929 | push eax ebx |
||
930 | xor dl,dl |
||
931 | mov eax,[wScr.max_area] |
||
932 | sub eax,[wScr.cur_area] |
||
933 | cmp [wScr.position],eax |
||
934 | jge @f |
||
935 | mov ebx,[wScr.cur_area] |
||
936 | add [wScr.position],ebx |
||
937 | mov dl,1 |
||
938 | mov [wScr.redraw],1 |
||
939 | cmp [wScr.position],eax |
||
940 | jle @f |
||
941 | mov [wScr.position],eax |
||
942 | @@: |
||
943 | pop ebx eax |
||
944 | ret |
||
945 | |||
946 | ;output: |
||
947 | ; dl = 0 not move |
||
948 | ; dl = 1 if move left |
||
949 | ; dl = 3 if move left and up |
||
950 | ; dl = 8 if scroll move up |
||
951 | CurMoveLeft: |
||
952 | cmp [cur_x],0 |
||
953 | je @f |
||
954 | dec [cur_x] |
||
955 | mov dl,1 |
||
956 | ret |
||
957 | @@: |
||
958 | cmp [hScr.position],0 |
||
959 | je @f |
||
960 | dec [hScr.position] |
||
961 | mov dl,8 |
||
962 | ret |
||
963 | @@: |
||
964 | cmp [cur_y],0 |
||
965 | jne @f |
||
966 | mov dl,0 |
||
967 | cmp [wScr.position],0 |
||
968 | je .ret_f |
||
969 | dec [wScr.position] |
||
970 | call OnInitialUpdate |
||
971 | call CurMoveX_LastChar |
||
972 | mov dl,8 |
||
973 | jmp .ret_f |
||
974 | @@: |
||
975 | cmp [cur_y],0 |
||
976 | je @f |
||
977 | dec [cur_y] |
||
978 | call CurMoveX_LastChar |
||
979 | cmp dl,8 |
||
980 | je .ret_f |
||
981 | mov dl,3 |
||
982 | ret |
||
983 | @@: |
||
984 | mov dl,0 |
||
985 | .ret_f: |
||
986 | ret |
||
987 | |||
988 | CurMoveRight: |
||
989 | push eax |
||
990 | xor dl,dl |
||
991 | mov eax,[hScr.cur_area] |
||
992 | cmp [cur_x],eax |
||
993 | jge @f |
||
994 | inc [cur_x] |
||
995 | mov dl,1 |
||
996 | jmp .ret_f |
||
997 | @@: |
||
998 | inc [hScr.position] |
||
999 | mov dl,8 |
||
1000 | .ret_f: |
||
1001 | pop eax |
||
1002 | ret |
||
1003 | |||
1004 | CurMoveX_LastChar: |
||
1005 | ;[hScr.position] |
||
1006 | ;[hScr.cur_area] |
||
1007 | ;dl-??? |
||
1008 | push eax ebx |
||
1009 | mov eax,[cur_y] |
||
1010 | add eax,[wScr.position] |
||
1011 | call StrLen |
||
1012 | xor dl,dl |
||
1013 | |||
1014 | cmp ebx,[hScr.position] |
||
1015 | jge @f |
||
1016 | mov dl,8 |
||
1017 | mov [hScr.position],ebx |
||
1018 | @@: |
||
1019 | sub ebx,[hScr.position] |
||
1020 | |||
1021 | cmp ebx,[hScr.cur_area] |
||
1022 | jle @f ; b---[---]---e |
||
1023 | add [hScr.position],ebx |
||
1024 | mov ebx,[hScr.cur_area] |
||
1025 | sub [hScr.position],ebx |
||
1026 | mov dl,8 |
||
1027 | @@: |
||
1028 | mov [cur_x],ebx |
||
1029 | pop ebx eax |
||
1030 | ret |
||
1031 | |||
1032 | ;output: |
||
1033 | ; dl = 0 not move |
||
1034 | ; dl = 1 move cursor |
||
1035 | ; dl = 8 move cursor and scroll |
||
1036 | CurMoveX_FirstChar: |
||
1037 | xor dl,dl |
||
1038 | cmp [cur_x],0 |
||
1039 | je @f |
||
1040 | mov [cur_x],0 |
||
1041 | mov dl,1 |
||
1042 | @@: |
||
1043 | cmp [hScr.position],0 |
||
1044 | je @f |
||
1045 | mov [hScr.position],0 |
||
1046 | mov dl,8 |
||
1047 | @@: |
||
1048 | ret |
||
1049 | |||
1050 | ;input: |
||
1051 | ; edx = pointer to symbol struct |
||
1052 | ;output: |
||
1053 | ; eax = array index |
||
1054 | GetTexArrIndex: |
||
1055 | push ecx edx |
||
1056 | |||
1057 | mov eax,edx |
||
1058 | sub eax,[tex] |
||
1059 | xor edx,edx |
||
1060 | mov ecx,sizeof.symbol |
||
1061 | div ecx |
||
1062 | |||
1063 | pop edx ecx |
||
1064 | ret |
||
1065 | |||
1066 | ;input: |
||
1067 | ; edx = pointer to symbol struct |
||
1068 | ;output: |
||
1069 | ; edx = pointer to 'perv' struct |
||
1070 | GetTexPervPos: |
||
1071 | push dword [edx+2] |
||
1072 | pop edx |
||
1073 | imul edx,sizeof.symbol |
||
1074 | add edx,[tex] |
||
1075 | ret |
||
1076 | |||
1077 | ;input: |
||
1078 | ; edx = pointer to symbol struct |
||
1079 | ;output: |
||
1080 | ; edx = pointer to 'next' symbol struct |
||
1081 | GetTexNextPos: |
||
1082 | push dword [edx+6] |
||
1083 | pop edx |
||
1084 | imul edx,sizeof.symbol |
||
1085 | add edx,[tex] |
||
1086 | ret |
||
1087 | |||
1088 | |||
1089 | ;output: |
||
1090 | ; edx = symbol under cursor |
||
1091 | ; gpOpt = 1,2 |
||
1092 | ; edx = tex[1].perv if error |
||
1093 | ; gpOpt = 0 |
||
1094 | GetPos: |
||
1095 | push esi ecx |
||
1096 | mov esi,[cur_x] |
||
1097 | add esi,[hScr.position] |
||
1098 | mov ecx,[cur_y] |
||
1099 | add ecx,[wScr.position] |
||
1100 | call GetPosByParam |
||
1101 | pop ecx esi |
||
1102 | ret |
||
1103 | |||
1104 | |||
1105 | ;input: |
||
1106 | ; esi = XPos |
||
1107 | ; ecx = YPos |
||
1108 | ;output: |
||
1109 | ; edx = symbol under cursor |
||
1110 | ; gpOpt = 1 if found text line |
||
1111 | ; gpOpt = 2 if found text line and column |
||
1112 | ; edx = tex[1] if error |
||
1113 | ; gpOpt = 0 if text no found |
||
1114 | GetPosByParam: |
||
1115 | push eax ;Row |
||
1116 | push ebx ;Col |
||
1117 | |||
1118 | xor eax,eax |
||
1119 | xor ebx,ebx |
||
1120 | mov [gpOpt],0 |
||
1121 | mov edx,[tex] |
||
1122 | @@: |
||
1123 | call IteratNext |
||
1124 | cmp edx,[tex_1] |
||
1125 | jle @f |
||
1126 | cmp ebx,esi |
||
1127 | jne .u1_0 ;Col <> cur_x |
||
1128 | mov [gpOpt],1 |
||
1129 | cmp eax,ecx |
||
1130 | jge @f ; Row >= cur_y |
||
1131 | .u1_0: |
||
1132 | mov [gpOpt],0 |
||
1133 | inc ebx |
||
1134 | cmp byte [edx],13 |
||
1135 | jne @b |
||
1136 | cmp eax,ecx |
||
1137 | jge @f ; Row >= cur_y |
||
1138 | inc eax |
||
1139 | xor ebx,ebx |
||
1140 | jmp @b |
||
1141 | @@: |
||
1142 | cmp eax,ecx |
||
1143 | jne @f ; Row = cur_y |
||
1144 | inc [gpOpt] |
||
1145 | @@: |
||
1146 | cmp [gpOpt],0 |
||
1147 | jne @f |
||
1148 | mov edx,[tex_1] |
||
1149 | ;call GetTexPervPos |
||
1150 | @@: |
||
1151 | pop ebx eax |
||
1152 | ret |
||
1153 | |||
1154 | |||
1155 | ;input: |
||
1156 | ; eax = Row |
||
1157 | ;output: |
||
1158 | ; ebx = str len |
||
1159 | StrLen: |
||
1160 | push edx ecx |
||
1161 | ;ecx = Row, from cycle |
||
1162 | |||
1163 | xor ebx,ebx |
||
1164 | xor ecx,ecx |
||
1165 | mov edx,[tex] |
||
1166 | @@: |
||
1167 | call IteratNext |
||
1168 | cmp edx,[tex_1] |
||
1169 | jle @f |
||
1170 | inc ebx |
||
1171 | cmp byte [edx],13 |
||
1172 | jne @b |
||
1173 | dec ebx ;lenght minus 1 sumbol to paragraph |
||
1174 | cmp eax,ecx |
||
1175 | je @f |
||
1176 | xor ebx,ebx |
||
1177 | inc ecx |
||
1178 | jmp @b |
||
1179 | @@: |
||
1180 | |||
1181 | cmp eax,ecx |
||
1182 | je @f |
||
1183 | xor ebx,ebx |
||
1184 | @@: |
||
1185 | |||
1186 | pop ecx edx |
||
1187 | ret |
||
1188 | |||
1189 | |||
1190 | ;output: |
||
1191 | ; edx = symbol position |
||
1192 | ;output: |
||
1193 | ; eax = number of line |
||
1194 | ; ebx = symbol position in line |
||
1195 | GetTexCoords: |
||
1196 | push edx |
||
1197 | xor eax,eax |
||
1198 | xor ebx,ebx |
||
1199 | @@: |
||
1200 | call IteratPerv |
||
1201 | |||
1202 | cmp eax,0 |
||
1203 | jne .no_col_mov |
||
1204 | inc ebx |
||
1205 | .no_col_mov: |
||
1206 | |||
1207 | cmp edx,[tex_1] |
||
1208 | jle @f |
||
1209 | cmp byte [edx],13 |
||
1210 | jne @b |
||
1211 | inc eax |
||
1212 | jmp @b |
||
1213 | @@: |
||
1214 | dec ebx |
||
1215 | pop edx |
||
1216 | ret |
||
1217 | |||
1218 | ;output: |
||
1219 | ; eax = num lines |
||
1220 | GetNumLines: |
||
1221 | push edx |
||
1222 | mov eax,1 |
||
1223 | mov edx,[tex] |
||
1224 | @@: |
||
1225 | call IteratNext |
||
1226 | cmp edx,[tex_1] |
||
1227 | jle @f |
||
1228 | cmp byte [edx],13 |
||
1229 | jne @b |
||
1230 | inc eax |
||
1231 | jmp @b |
||
1232 | @@: |
||
1233 | ;... |
||
1234 | ;dec eax |
||
1235 | pop edx |
||
1236 | ret |
||
1237 | |||
1238 | SetUndo: |
||
1239 | mov [dragk],0 ;заканчиваем выделение от клавиатуры |
||
1240 | cmp [tim_Undo],1 |
||
1241 | jl .no_work |
||
1242 | |||
1243 | push eax ebx edx |
||
1244 | mov edx,[tex] |
||
1245 | call GetTexNextPos ;long i=tex[0].next; |
||
1246 | mov eax,[tim_Undo] |
||
1247 | sub [ch_tim],eax ;ch_tim-=tim_Undo; |
||
1248 | mov eax,[ch_tim] |
||
1249 | cmp [ls_tim],eax ;if(ls_tim>ch_tim) |
||
1250 | jle @f |
||
1251 | mov dword [ls_tim],0 |
||
1252 | @@: |
||
1253 | cmp edx,[tex] |
||
1254 | je @f |
||
1255 | |||
1256 | ;if(tex[i].tc>ch_tim){ // если создание символа было отменено |
||
1257 | cmp [edx+10],eax |
||
1258 | jle .no_u1 |
||
1259 | mov dword [edx+10],0 |
||
1260 | mov dword [edx+14],0 |
||
1261 | |||
1262 | mov ebx,[edx+2] |
||
1263 | imul ebx,sizeof.symbol |
||
1264 | add ebx,[tex];.next |
||
1265 | m2m dword [ebx+6],dword [edx+6] ;tex[tex[i].perv].next=tex[i].next; |
||
1266 | |||
1267 | mov ebx,[edx+6] |
||
1268 | imul ebx,sizeof.symbol |
||
1269 | add ebx,[tex];.perv |
||
1270 | m2m dword [ebx+2],dword [edx+2] ;tex[tex[i].next].perv=tex[i].perv; |
||
1271 | |||
1272 | .no_u1: |
||
1273 | |||
1274 | ;else if(tex[i].td>ch_tim) tex[i].td=0; // если удаление символа было отменено |
||
1275 | cmp [edx+14],eax |
||
1276 | jle .no_u2 |
||
1277 | mov dword [edx+14],0 |
||
1278 | .no_u2: |
||
1279 | |||
1280 | call GetTexNextPos |
||
1281 | jmp @b |
||
1282 | @@: |
||
1283 | mov dword [tim_Undo],0 |
||
1284 | mov eax,[co_tim] |
||
1285 | cmp [ch_tim],eax |
||
1286 | jge @f |
||
1287 | mov [co_tim],0 |
||
1288 | @@: |
||
1289 | pop edx ebx eax |
||
1290 | .no_work: |
||
1291 | ret |
||
1292 | |||
1293 | ;input: |
||
1294 | ; ecx = Col |
||
1295 | ; edx = Row |
||
1296 | GoToPos: |
||
1297 | mov [cur_x],ecx |
||
1298 | sub edx,[wScr.position] |
||
1299 | |||
1300 | cmp edx,[wScr.cur_area] ;[cur_y] > [.cur_area] |
||
1301 | jl @f |
||
1302 | push ebx |
||
1303 | mov ebx,edx |
||
1304 | sub ebx,[wScr.cur_area] |
||
1305 | inc ebx |
||
1306 | add [wScr.position],ebx |
||
1307 | sub edx,ebx |
||
1308 | pop ebx |
||
1309 | ; ??? redrav |
||
1310 | @@: |
||
1311 | mov [cur_y],edx |
||
1312 | ret |
||
1313 | |||
1314 | ;input: |
||
1315 | ; bl = 1 change time when delete text |
||
1316 | ;output: |
||
1317 | ; al = 1 if delete |
||
1318 | SelTextDel: |
||
1449 | IgorA | 1319 | stdcall IsSel, tedit0 |
1338 | IgorA | 1320 | cmp al,0 |
1321 | jne @f |
||
1322 | ret |
||
1323 | @@: |
||
1324 | ;call SelEnd |
||
1325 | call SelNormalize |
||
1326 | push esi edi ecx edx |
||
1327 | mov esi,[seln.x1] |
||
1328 | mov ecx,[seln.y1] |
||
1329 | call GetPosByParam |
||
1330 | mov edi,edx |
||
1331 | |||
1332 | mov esi,[seln.x0] |
||
1333 | mov ecx,[seln.y0] |
||
1334 | call GetPosByParam |
||
1335 | |||
1336 | cmp bl,0 |
||
1337 | je @f |
||
1338 | inc [ch_tim] |
||
1339 | |||
1340 | @@: |
||
1341 | cmp edx,[tex] |
||
1342 | je @f |
||
1343 | cmp edx,edi ;if(i==te)break; |
||
1344 | je @f |
||
1345 | m2m dword[edx+14],dword[ch_tim] |
||
1346 | xor bl,bl ;n_tim=false; |
||
1347 | call IteratNext |
||
1348 | jmp @b |
||
1349 | @@: |
||
1350 | cmp bl,0 |
||
1351 | je @f |
||
1352 | dec [ch_tim] |
||
1353 | xor al,al |
||
1354 | @@: |
||
1355 | cmp bl,0 |
||
1356 | jne @f |
||
1357 | mov ecx,[seln.x0] |
||
1358 | mov edx,[seln.y0] |
||
1359 | call GoToPos |
||
1360 | mov [sel.x0],0 |
||
1361 | mov [sel.y0],0 |
||
1362 | mov [sel.x1],0 |
||
1363 | mov [sel.y1],0 |
||
1364 | @@: |
||
1365 | pop edx ecx edi esi |
||
1366 | |||
1367 | ret |
||
1368 | |||
1369 | |||
1370 | CmColored: |
||
1371 | push eax edx |
||
1372 | mov eax,[ch_tim] |
||
1373 | sub eax,[tim_Undo] |
||
1374 | mov dword[co_tim],eax |
||
1375 | mov edx,[tex] |
||
1376 | @@: |
||
1377 | call IteratNext |
||
1378 | cmp edx,[tex_1] |
||
1379 | jle @f |
||
1380 | mov byte[edx+1],0 |
||
1381 | jmp @b |
||
1382 | @@: |
||
1383 | |||
1384 | cmp dword[ColWords],1 |
||
1385 | jl .no_colors |
||
1386 | mov edx,[tex] |
||
1387 | @@: |
||
1388 | call TextFSColor |
||
1389 | cmp edx,[tex_1] |
||
1390 | jle .no_colors |
||
1391 | jmp @b |
||
1392 | .no_colors: |
||
1393 | pop edx eax |
||
1394 | ret |
||
1395 | |||
1396 | |||
1397 | |||
1398 | ;input: |
||
1399 | ; edx = pointer to start symbol |
||
1400 | ;output: |
||
1401 | ; edx = pointer to next symbol |
||
1402 | TextFSColor: |
||
1403 | ;eax = word_n |
||
1404 | ;ecx = l_pos |
||
1405 | push ebp |
||
1406 | mov ebp,esp |
||
1407 | sub esp,10 ;2*4+2*1 |
||
1408 | ;bP = dword[ebp-4] |
||
1409 | ;eP = dword[ebp-8] |
||
1410 | ;fnd = byte[ebp-12] |
||
1411 | ;f_color = byte[ebp-13] |
||
1412 | |||
1413 | push eax ebx ecx esi edi |
||
1414 | mov dword[ebp-4],1 |
||
1415 | mov dword[ebp-4],1 |
||
1416 | mov byte[ebp-12],0 |
||
1417 | mov byte[ebp-13],1 |
||
1418 | @@: |
||
1419 | call IteratNext |
||
1420 | cmp edx,[tex_1] |
||
1421 | jle @f |
||
1422 | |||
1423 | xor ebx,ebx |
||
1424 | mov bl,byte[edx] |
||
1425 | ;mov byte[buf],bl |
||
1426 | ;mov byte[buf+1],0 |
||
1427 | shl bx,2 ;ebx*=4 |
||
1428 | add ebx,FkPos |
||
1429 | mov eax,dword[ebx] |
||
1430 | cmp eax,0 |
||
1431 | jl @b ;if( (word_n=FkPos[(unsigned char)tex[i].c])>-1 ){ |
||
1432 | |||
1433 | mov ecx,eax |
||
1434 | ;while(l_pos |
||
1435 | .wh_1b: |
||
1436 | cmp ecx,dword[ColWords] |
||
1437 | jge .wh_1e |
||
1438 | ColToIndexOffset ecx,esi |
||
1439 | mov bh,byte[esi] |
||
1440 | ColToIndexOffset eax,esi |
||
1441 | mov bl,byte[esi] |
||
1442 | cmp bh,bl |
||
1443 | jne .wh_1e |
||
1444 | inc ecx |
||
1445 | jmp .wh_1b |
||
1446 | .wh_1e: |
||
1447 | |||
1448 | mov dword[ebp-4],edx ;bP=i; |
||
1449 | mov edi,1 |
||
1450 | |||
1451 | .wh_2b: ;while(1){ |
||
1452 | call IteratNext |
||
1453 | |||
1454 | ;while(l_pos>word_n && Col[keyw[l_pos-1]].Text[pos]!=tex[i].c) |
||
1455 | .wh_3b: |
||
1456 | cmp ecx,eax |
||
1457 | jle .wh_3e |
||
1458 | dec ecx |
||
1459 | ColToIndexOffset ecx,ebx |
||
1460 | inc ecx |
||
1461 | ;cmp byte[ebx+edi],byte[edx] |
||
1462 | push ax |
||
1463 | mov al,byte[ebx+edi] |
||
1464 | mov bl,al |
||
1465 | pop ax |
||
1466 | cmp bl,byte[edx] |
||
1467 | je .wh_3e |
||
1468 | dec ecx |
||
1469 | jmp .wh_3b |
||
1470 | .wh_3e: |
||
1471 | |||
1472 | ColToIndexOffset eax,ebx |
||
1473 | cmp byte[ebx+edi],0 |
||
1474 | jne .if_0 ;if(Col[keyw[word_n]].Text[pos]==0){ |
||
1475 | mov dword[ebp-8],edx ;eP=i; |
||
1476 | ColToIndexOffset eax,esi |
||
1477 | mov bl,byte[esi+MAX_COLOR_WORD_LEN+6] |
||
1478 | mov byte[ebp-13],bl ;f_color=Col[keyw[word_n]].color; |
||
1479 | |||
1480 | mov byte[ebp-12],1 |
||
1481 | ;... esi = Col[keyw[word_n]] |
||
1482 | mov bl,byte[esi+MAX_COLOR_WORD_LEN+4] |
||
1483 | cmp bl,0 ;if(Col[keyw[word_n]].wwo) |
||
1484 | je .if_2n |
||
1485 | push edx |
||
1486 | mov edx,dword[ebp-4] |
||
1487 | call IteratPerv |
||
1488 | ; mov bh,bl |
||
1489 | |||
1490 | btr bx,0 ;1-1 |
||
1491 | jae .if_3e ;if(Col[keyw[word_n]].wwo&1) |
||
1492 | ;u1= !(isalnum(cont_s)||cont_s=='_') |
||
1493 | call isalnum |
||
1494 | jae .if_3e |
||
1495 | mov byte[ebp-12],0 |
||
1496 | .if_3e: |
||
1497 | |||
1498 | btr bx,3 ;4-1 |
||
1499 | jae .if_4e ;if(Col[keyw[word_n]].wwo&8) |
||
1500 | ;u1= !isalpha(cont_s); |
||
1501 | call isalpha |
||
1502 | jae .if_4e |
||
1503 | mov byte[ebp-12],0 |
||
1504 | .if_4e: |
||
1505 | |||
1506 | |||
1507 | mov edx,dword[ebp-8] |
||
1508 | ; call IteratNext |
||
1509 | |||
1510 | btr bx,1 ;2-1 |
||
1511 | jae .if_5e ;if(Col[keyw[word_n]].wwo&2) |
||
1512 | ;u1= !(isalnum(cont_s)||cont_s=='_') |
||
1513 | call isalnum |
||
1514 | jae .if_5e |
||
1515 | mov byte[ebp-12],0 |
||
1516 | .if_5e: |
||
1517 | |||
1518 | btr bx,4 ;5-1 |
||
1519 | jae .if_6e ;if(Col[keyw[word_n]].wwo&16) |
||
1520 | ;u1= !isalpha(cont_s); |
||
1521 | call isalpha |
||
1522 | jae .if_6e |
||
1523 | mov byte[ebp-12],0 |
||
1524 | .if_6e: |
||
1525 | |||
1526 | btr bx,2 ;3-1 |
||
1527 | jae .if_7e ;if(Col[keyw[word_n]].wwo&4) |
||
1528 | mov bl,byte[esi+MAX_COLOR_WORD_LEN+5] |
||
1529 | call ItPoNextUc |
||
1530 | cmp edx,[tex_1] |
||
1531 | jle .if_7e |
||
1532 | mov dword[ebp-8],edx |
||
1533 | .if_7e: |
||
1534 | |||
1535 | pop edx |
||
1536 | .if_2n: |
||
1537 | ; if(i!=1){ // не конец документа |
||
1538 | ; cont_s=tex[eP].c; |
||
1539 | ; if(Col[keyw[word_n]].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_'); // не букв.-числ. символ |
||
1540 | ; if(u2 && Col[keyw[word_n]].wwo&16) u2= !isalpha(cont_s); // не числ. символ |
||
1541 | ; if(Col[keyw[word_n]].wwo&4) eP=ItPoNextUc(eP,Col[keyw[word_n]].endc); |
||
1542 | |||
1543 | cmp eax,ecx |
||
1544 | je .wh_2e ;if(word_n==l_pos) break; // do double - если слово точно последнее |
||
1545 | .if_0: |
||
1546 | |||
1547 | cmp edx,[tex_1] |
||
1548 | jle .wh_2e ;if(i==1) break; |
||
1549 | |||
1550 | ;while(l_pos>word_n && Col[keyw[word_n]].Text[pos]!=tex[i].c) |
||
1551 | .wh_4b: |
||
1552 | cmp ecx,eax |
||
1553 | jle .wh_4e |
||
1554 | ColToIndexOffset eax,ebx |
||
1555 | ;cmp byte[ebx+edi],byte[edx] |
||
1556 | push ax |
||
1557 | mov al,byte[ebx+edi] |
||
1558 | mov bl,al |
||
1559 | pop ax |
||
1560 | cmp bl,byte[edx] |
||
1561 | je .wh_4e |
||
1562 | inc eax |
||
1563 | jmp .wh_4b |
||
1564 | .wh_4e: |
||
1565 | |||
1566 | cmp eax,ecx |
||
1567 | je .wh_2e;if(word_n==l_pos) break; |
||
1568 | inc edi ;pos++; |
||
1569 | jmp .wh_2b |
||
1570 | .wh_2e: |
||
1571 | |||
1572 | cmp byte[ebp-12],1 ;if(fnd)break; |
||
1573 | je @f |
||
1574 | mov edx,dword[ebp-4];i=bP; |
||
1575 | jmp @b |
||
1576 | @@: |
||
1577 | |||
1578 | cmp byte[ebp-12],1 |
||
1579 | jne .if_1e ;if(fnd){ // выделение найденого текста |
||
1580 | ; if(!mode_sf1 || (mode_sf1 && strlen(Col[keyw[word_n]].f1->c_str())>0)){ |
||
1581 | mov eax,dword[ebp-4] |
||
1582 | mov bl,byte[ebp-13] |
||
1583 | mov byte[eax+1],bl ;tex[bP].col=f_color; |
||
1584 | mov eax,dword[ebp-8] |
||
1585 | mov byte[eax+1],0xff ;tex[eP].col=255; |
||
1586 | ; return ItPoPerv(eP); // возвращаем позицию конца вхождения |
||
1587 | mov edx,dword[ebp-8] |
||
1588 | call GetTexPervPos |
||
1589 | jmp @f |
||
1590 | .if_1e: |
||
1591 | mov edx,[tex] |
||
1592 | @@: |
||
1593 | |||
1594 | pop edi esi ecx ebx eax |
||
1595 | mov esp,ebp |
||
1596 | pop ebp |
||
1597 | ret |
||
1598 | |||
1599 | |||
1600 | ;input: |
||
1601 | ; edx = pointer to char (byte) |
||
1602 | ;output: |
||
1603 | ; cf=1 if symbol is... |
||
1604 | tab_all_num db 0,0,0,0,0,0,11111111b,11b,11111110b,0xff,0xff,111b,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 |
||
1605 | tab_alpha db 0,0,0,0,0,0,0,0,11111110b,0xff,0xff,111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
||
1606 | ;db 0,0,0,0,0,0,11111111b,11b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
||
1607 | isalnum: |
||
1608 | push eax ebx |
||
1609 | mov al,byte[edx] ;al=offset |
||
1610 | shr al,3 |
||
1611 | and eax,11111b |
||
1612 | mov ebx,tab_all_num |
||
1613 | add ebx,eax |
||
1614 | mov ah,byte[ebx] |
||
1615 | mov al,byte[edx] ;al=bit |
||
1616 | and ax,111b |
||
1617 | m2m bx,word[ebx] |
||
1618 | btr bx,ax |
||
1619 | pop ebx eax |
||
1620 | ret |
||
1621 | isalpha: |
||
1622 | push eax ebx |
||
1623 | mov al,byte[edx] ;al=offset |
||
1624 | shr al,3 |
||
1625 | and eax,11111b |
||
1626 | mov ebx,tab_alpha |
||
1627 | add ebx,eax |
||
1628 | mov ah,byte[ebx] |
||
1629 | mov al,byte[edx] ;al=bit |
||
1630 | and ax,111b |
||
1631 | m2m bx,word[ebx] |
||
1632 | btr bx,ax |
||
1633 | pop ebx eax |
||
1634 | ret |
||
1635 | |||
1636 | |||
1637 | ShowHelpF1: |
||
1638 | push eax edx |
||
1639 | |||
1640 | call GetPos |
||
1641 | push edx |
||
1642 | call ItNextColorTag |
||
1643 | mov eax,edx |
||
1644 | pop edx |
||
1645 | call ItPervColorTag |
||
1646 | |||
1647 | cmp eax,[tex] |
||
1648 | jle @f |
||
1649 | cmp edx,[tex_1] |
||
1650 | jle @f |
||
1651 | call FindHelpId |
||
1652 | @@: |
||
1653 | pop edx eax |
||
1449 | IgorA | 1654 | ;stdcall draw_main_cursor, tedit0 |
1655 | stdcall draw_help_f1, tedit0 |
||
1338 | IgorA | 1656 | ret |
1657 | |||
1658 | ;input: |
||
1659 | ; edx = position begin 'symbol' struct |
||
1660 | ; eax = position end 'symbol' struct |
||
1661 | FindHelpId: |
||
1662 | ; ecx = word_n |
||
1663 | ; ebx = l_pos |
||
1664 | mov [help_id],-1 |
||
1665 | |||
1666 | push ebx ecx |
||
1667 | xor ebx,ebx |
||
1668 | mov bl,byte[edx] |
||
1669 | shl bx,2 ;ebx*=4 |
||
1670 | add ebx,FkPos |
||
1671 | mov ecx,dword[ebx] |
||
1672 | cmp ecx,0 |
||
1673 | jl .if_0e ;if( (word_n=FkPos[(unsigned char)tf[0]])>-1 ){ |
||
1674 | push esi edi |
||
1675 | mov ebx,ecx ;l_pos=word_n; |
||
1676 | ColToIndexOffset ecx,esi |
||
1677 | push cx |
||
1678 | mov cl,byte[esi] |
||
1679 | @@: |
||
1680 | cmp ebx,dword[ColWords] ;while(l_pos |
||
1681 | jge @f |
||
1682 | ;ColToIndexOffset ecx,esi |
||
1683 | ColToIndexOffset ebx,edi |
||
1684 | cmp cl,byte[edi] ;&& Col[keyw[l_pos]].Text[0]==Col[keyw[word_n]].Text[0]) |
||
1685 | jne @f |
||
1686 | inc ebx ;l_pos++; |
||
1687 | jmp @b |
||
1688 | @@: |
||
1689 | pop cx |
||
1690 | call IteratNext ;pos=1; |
||
1691 | mov esi,1 |
||
1692 | @@: |
||
1693 | push dx |
||
1694 | push word[edx] |
||
1695 | pop dx |
||
1696 | .wh_0b: |
||
1697 | cmp ebx,ecx ;while(l_pos>word_n |
||
1698 | jle .wh_0e |
||
1699 | dec ebx |
||
1700 | ColToIndexOffset ebx,edi |
||
1701 | inc ebx |
||
1702 | cmp byte[edi+esi],dl ;&& Col[keyw[l_pos-1]].Text[pos]!=tf[i]) |
||
1703 | je .wh_0e |
||
1704 | dec ebx ;l_pos--; |
||
1705 | jmp .wh_0b |
||
1706 | .wh_0e: |
||
1707 | |||
1708 | .wh_1b: |
||
1709 | cmp ebx,ecx ;while(l_pos>word_n |
||
1710 | jle .wh_1e |
||
1711 | ColToIndexOffset ecx,edi |
||
1712 | cmp byte[edi+esi],dl |
||
1713 | je .wh_1e |
||
1714 | inc ecx ;word_n++; |
||
1715 | jmp .wh_1b |
||
1716 | .wh_1e: |
||
1717 | pop dx |
||
1718 | |||
1719 | cmp ecx,ebx ;if(word_n==l_pos) break; |
||
1720 | je @f |
||
1721 | call IteratNext ;pos++; |
||
1722 | cmp edx,eax ;for(...;i |
||
1723 | je @f ;jge |
||
1724 | inc esi |
||
1725 | jmp @b |
||
1726 | @@: |
||
1727 | pop edi esi |
||
1728 | |||
1729 | mov dword[help_id],ecx |
||
1730 | ;return keyw[word_n]; |
||
1731 | |||
1732 | .if_0e: |
||
1733 | pop ecx ebx |
||
1734 | ret |
||
1735 | |||
1390 | IgorA | 1736 | ;----------------------------------------------------------------------------- |
1737 | ;функция для выделения памяти |
||
1738 | ;input: |
||
1739 | ; ecx = size data |
||
1740 | ;otput: |
||
1741 | ; eax = pointer to memory |
||
1742 | align 4 |
||
1743 | mem_Alloc: |
||
1744 | push ebx |
||
1745 | mov eax,68 |
||
1746 | mov ebx,12 |
||
1747 | int 0x40 |
||
1748 | pop ebx |
||
1749 | ret |
||
1750 | ;----------------------------------------------------------------------------- |
||
1751 | ;функция для освобождения памяти |
||
1752 | ;input: |
||
1753 | ; ecx = pointer to memory |
||
1754 | align 4 |
||
1755 | mem_Free: |
||
1756 | push eax ebx |
||
1757 | cmp ecx,0 |
||
1758 | jz @f |
||
1759 | mov eax,68 |
||
1760 | mov ebx,13 |
||
1761 | int 0x40 |
||
1762 | @@: |
||
1763 | pop ebx eax |
||
1764 | ret |