Subversion Repositories Kolibri OS

Rev

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