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