Subversion Repositories Kolibri OS

Rev

Rev 1449 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  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.  
  29. hed db 'TextEditor 22.04.10',0 ;ïîäïèñü îêíà
  30. sc system_colors
  31.  
  32. fn_icon db 'te_icon.bmp',0
  33. bmp_icon dd 0
  34. run_file_70 f70          
  35.  
  36.  
  37. ;input:
  38. ; edi = pointer to tedit struct
  39. ; reg = index
  40. ;output:
  41. ; reg = pointer to 'tex' struct
  42. macro ConvertIndexToPointer reg {
  43.   imul reg,sizeof.symbol
  44.   add reg,ted_tex
  45. }
  46.  
  47. align 4
  48. proc ted_init, edit:dword
  49.   push eax ecx edi
  50.   mov edi,dword[edit]
  51.  
  52.   mov ecx,sizeof.symbol*maxChars
  53.   call mem_Alloc ;âûäåëÿåì ïàìÿòü
  54.   mov ted_tex,eax
  55.   mov ted_tex_1,eax
  56.   add ted_tex_1,sizeof.symbol
  57.   mov ted_tex_end,eax
  58.   add ted_tex_end,sizeof.symbol*maxChars
  59.  
  60.   stdcall ted_clear, edi,1
  61.  
  62. ;-------------------------------------------------
  63.   mov ecx,maxColWords*sizeof.TexColViv+40
  64.   ;add ecx,40
  65.   call mem_Alloc
  66.   mov ted_syntax_file,eax
  67.   mov ted_syntax_file_end,eax
  68.   add ted_syntax_file_end,ecx
  69.  
  70.   pop edi ecx eax
  71.   ret
  72. endp
  73.  
  74. align 4
  75. proc ted_delete, edit:dword
  76.   push ecx edi
  77.   mov edi,dword[edit]
  78.  
  79.   mov ecx,ted_tex
  80.   call mem_Free
  81.   mov ecx,ted_syntax_file
  82.   call mem_Free
  83.  
  84.   pop edi ecx
  85.   ret
  86. endp
  87.  
  88.  
  89. ;input:
  90. ; eax = key kodes
  91. ; ebx = key control
  92. align 4
  93. proc ted_key, edit:dword, table:dword
  94.   pushad
  95.   mov edi,dword[edit]
  96.  
  97.   cmp ah,KEY_F1 ;[F1]
  98.   jne @f
  99.     stdcall ted_show_help_f1,edi
  100.     jmp .end_key_fun
  101.   @@:
  102.   cmp ah,KEY_F3 ;[F3]
  103.   jne @f
  104.     stdcall but_FindText,edi
  105.     jmp .end_key_fun
  106.   @@:
  107.  
  108.   test ebx,KM_CTRL ;Ctrl+...
  109.   jz .key_Ctrl
  110.  
  111.     cmp ah,24 ;Ctrl+O
  112.     jne @f
  113.       call but_OpenFile
  114.     @@:
  115.     cmp ah,33 ;Ctrl+F
  116.     jne @f
  117.     cmp ted_panel_id,TE_PANEL_FIND
  118.     je @f
  119.       stdcall but_find,edi
  120.     @@:
  121.     cmp ah,44 ;Ctrl+Z
  122.         jne @f
  123.       stdcall ted_but_undo,edi
  124.         @@:
  125.     cmp ah,46 ;Ctrl+C
  126.     jne @f
  127.       stdcall ted_but_copy,edi
  128.     @@:
  129.     cmp ah,47 ;Ctrl+V
  130.     jne @f
  131.       stdcall ted_but_paste,edi
  132.     @@:
  133.     cmp ah,49 ;Ctrl+N
  134.     jne @f
  135.       call but_NewFile
  136.     @@:
  137.     cmp ah,199 ;Ctrl+Home
  138.     jne @f
  139.       call but_CtrlHome
  140.     @@:
  141.     ;jmp .end_key_fun
  142.   .key_Ctrl:
  143.  
  144.   test ebx,KM_SHIFT ;Shift+...
  145.   jz .key_Shift
  146.     cmp ah,72 ;Shift+Up
  147.     jne @f
  148.       stdcall ted_sel_key_up,edi
  149.     @@:
  150.     cmp ah,75 ;Shift+Left
  151.     jne @f
  152.       stdcall ted_sel_key_left,edi
  153.     @@:
  154.     cmp ah,77 ;Shift+Right
  155.     jne @f
  156.       stdcall ted_sel_key_right,edi
  157.     @@:
  158.     cmp ah,80 ;Shift+Down
  159.     jne @f
  160.       stdcall ted_sel_key_down,edi
  161.     @@:
  162.     ;mov ted_drag_k,1 ;íà÷èíàåì âûäåëåíèå îò êëàâèàòóðû
  163.     jmp .key_MoveCur
  164.   .key_Shift:
  165. ;-------------------------------------------------
  166.   cmp ah,72 ;178 ;Up
  167.   jne @f
  168.     stdcall draw_cursor_sumb,edi
  169.     call CurMoveUp
  170.     cmp dl,8
  171.     jne .no_red_0
  172.       call OnInitialUpdate
  173.       stdcall draw_main_win,edi
  174.       jmp @f
  175.     .no_red_0:
  176.     stdcall draw_main_cursor,edi
  177.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  178.   @@:
  179.   cmp ah,80 ;177 ;Down
  180.   jne @f
  181.     stdcall draw_cursor_sumb,edi
  182.     call CurMoveDown
  183.     cmp dl,8
  184.     jne .no_red_1
  185.       call OnInitialUpdate
  186.       stdcall draw_main_win,edi
  187.       jmp @f
  188.     .no_red_1:
  189.     stdcall draw_main_cursor,edi
  190.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  191.   @@:
  192.   cmp ah,75 ;176 ;Left
  193.   jne @f
  194.     stdcall draw_cursor_sumb,edi
  195.     call CurMoveLeft
  196.     cmp dl,8
  197.     jne .no_red_2
  198.       call OnInitialUpdate
  199.       stdcall draw_main_win,edi
  200.       jmp @f
  201.     .no_red_2:
  202.     stdcall draw_main_cursor,edi
  203.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  204.   @@:
  205.   cmp ah,77 ;179 ;Right
  206.   jne @f
  207.     stdcall draw_cursor_sumb,edi
  208.     call CurMoveRight
  209.     cmp dl,8
  210.     jne .no_red_3
  211.       call OnInitialUpdate
  212.       stdcall draw_main_win,edi
  213.       jmp @f
  214.     .no_red_3:
  215.     stdcall draw_main_cursor,edi
  216.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  217.   @@:
  218.   cmp ah,71 ;180 ;Home
  219.   jne @f
  220.     stdcall draw_cursor_sumb,edi
  221.     call CurMoveX_FirstChar
  222.     cmp dl,8
  223.     jne .no_red_4
  224.       call OnInitialUpdate
  225.       stdcall draw_main_win,edi
  226.       jmp @f
  227.     .no_red_4:
  228.     stdcall draw_main_cursor,edi
  229.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  230.   @@:
  231.   cmp ah,79 ;181 ;End
  232.   jne @f
  233.     stdcall draw_cursor_sumb,edi
  234.     call CurMoveX_LastChar
  235.     cmp dl,8
  236.     jne .no_red_5
  237.       call OnInitialUpdate
  238.       stdcall draw_main_win,edi
  239.       jmp @f
  240.     .no_red_5:
  241.     stdcall draw_main_cursor,edi
  242.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  243.   @@:
  244.   cmp ah,73 ;184 ;PageUp
  245.   jne @f
  246.     call CurMovePageUp
  247.     cmp dl,0
  248.     je @f
  249.     call OnInitialUpdate
  250.     stdcall draw_main_win,edi
  251.   @@:
  252.   cmp ah,81 ;183 ;PageDown
  253.   jne @f
  254.     call CurMovePageDown
  255.     cmp dl,0
  256.     je @f
  257.     call OnInitialUpdate
  258.     stdcall draw_main_win,edi
  259.     mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  260.   @@:
  261. ;-------------------------------------------------
  262. ;    cmp ebx,0
  263. ;    jne .end_key_fun
  264.   .key_MoveCur:
  265.  
  266.   cmp ah,69 ;[Pause Break]
  267.   je .end_key_fun
  268.   cmp ah,120 ;[Fn]
  269.   je .end_key_fun
  270.   cmp ah,0x80 ;if key up
  271.   ja .end_key_fun
  272.  
  273.   cmp dword[table],0
  274.   je @f
  275.     stdcall KeyConvertToASCII, dword[table]
  276.   @@:
  277.  
  278.   ;mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  279.  
  280.   xor edx,edx
  281.   mov dl,ah
  282.   add edx,EvChar ;add char to text
  283.   cmp byte [edx],1
  284.   jne @f
  285.     mov ted_key_new,ah
  286.     stdcall ted_set_undo,edi
  287.     mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  288.     stdcall SelTextDel,edx
  289.     cmp al,1
  290.     jne .del
  291.       mov edx,ted_opt_ed_move_cursor
  292.     .del:
  293.     cmp ted_cur_ins,1
  294.     je .no_ins_mod
  295.       stdcall TextDel,edi,ted_opt_ed_change_time
  296.           mov edx,ted_opt_ed_move_cursor
  297.     .no_ins_mod:
  298.         mov ecx,edi
  299.         add ecx,ted_offs_key_new
  300.     stdcall ted_text_add,edi,ecx,1,edx ;äîáàâëÿåì ñèìâîë ââåäåííûé ñ êëàâèàòóðû
  301.     call draw_but_toolbar
  302.     cmp ted_key_new,13
  303.     jne .dr_m_win
  304.       stdcall draw_main_win,edi
  305.       jmp .dr_cur_l
  306.     .dr_m_win:
  307.       stdcall draw_cur_line,edi
  308.     .dr_cur_l:
  309.   @@:
  310.  
  311.   cmp ah,8 ;[<-]
  312.   jne @f
  313.     stdcall ted_set_undo,edi
  314.     stdcall SelTextDel,ted_opt_ed_change_time
  315.     cmp al,1
  316.     je .del_one_b
  317.       stdcall TextDel,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  318.     .del_one_b:
  319.     call draw_but_toolbar
  320.     stdcall draw_main_win,edi
  321.     jmp .end_key_fun
  322.   @@:
  323.  
  324.   cmp ah,182 ;Delete
  325.   jne @f
  326.     stdcall ted_set_undo,edi
  327.     stdcall SelTextDel,ted_opt_ed_change_time
  328.     cmp al,1
  329.     je .del_one_d
  330.       stdcall TextDel,edi,ted_opt_ed_change_time
  331.     .del_one_d:
  332.     call draw_but_toolbar
  333.     stdcall draw_main_win,edi
  334.     jmp .end_key_fun
  335.   @@:
  336.  
  337.   cmp ah,185 ;Ins
  338.   jne @f
  339.     stdcall draw_cursor_sumb,edi
  340.     xor ted_cur_ins,1
  341.     stdcall draw_main_cursor,edi
  342.   @@:
  343.  
  344.   .end_key_fun:
  345.   popad
  346.   ret
  347. endp
  348.  
  349. ;output:
  350. ; al = 1 - can save
  351. align 4
  352. proc ted_can_save, edit:dword
  353.   push ecx edi
  354.   mov edi,dword[edit]
  355.  
  356.   mov ecx,ted_tim_ch
  357.   sub ecx,ted_tim_undo
  358.   mov al,1
  359.   cmp ted_tim_ls,ecx
  360.   jne @f
  361.     dec al
  362.   @@:
  363.   pop edi ecx
  364.   ret
  365. endp
  366.  
  367. ;output:
  368. ; al = 1 - selected
  369. align 4
  370. proc IsSel, edit:dword
  371.   push ebx edi
  372.   mov edi,dword[edit]
  373.   xor al,al
  374.   cmp ted_drag_m,1
  375.   je @f
  376.     mov al,1
  377.     mov ebx,ted_sel_x0
  378.     cmp ebx,ted_sel_x1
  379.     jne @f
  380.     mov ebx,ted_sel_y0
  381.     cmp ebx,ted_sel_y1
  382.     jne @f
  383.     xor al,al
  384.   @@:
  385.   pop edi ebx
  386.   ret
  387. endp
  388.  
  389. align 4
  390. proc SelNormalize, edit:dword
  391.   push ecx esi edi
  392.     mov edi,dword[edit]
  393.     mov esi,edi
  394.     add esi,ted_offs_sel
  395.     add edi,ted_offs_seln
  396.     mov ecx,sizeof.TexSelect
  397.     rep movsb
  398.  
  399.         mov edi,dword[edit]
  400.  
  401.     jmp @f
  402.     .swp_f:
  403.       mov ecx,ted_seln_x0
  404.       m2m ted_seln_x0,ted_seln_x1
  405.       mov ted_seln_x1,ecx
  406.  
  407.       mov ecx,ted_seln_y0
  408.       cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
  409.       jle .end_f
  410.       m2m ted_seln_y0,ted_seln_y1
  411.       mov ted_seln_y1,ecx
  412.  
  413.     jmp .end_f
  414.     @@:
  415.  
  416.     mov ecx,ted_seln_y0
  417.     cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
  418.     jg .swp_f
  419.  
  420.     cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
  421.     jne .end_f
  422.       mov ecx,ted_seln_x0
  423.       cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
  424.       jg .swp_f
  425.  
  426.     .end_f:
  427.   pop edi esi ecx
  428.   ret
  429. endp
  430.  
  431. align 4
  432. proc SelStart, edit:dword
  433.   push ecx edi
  434.     mov edi,dword[edit]
  435.  
  436.     mov ecx,ted_cur_x
  437.     add ecx,[hScr.position]
  438.     mov ted_sel_x0,ecx
  439.     mov ted_sel_x1,ecx
  440.  
  441.     mov ecx,ted_cur_y
  442.     add ecx,[wScr.position]
  443.     mov ted_sel_y0,ecx
  444.     mov ted_sel_y1,ecx
  445.   pop edi ecx
  446.   ret
  447. endp
  448.  
  449. align 4
  450. proc SelMove, edit:dword
  451.   push ecx edi
  452.     mov edi,dword[edit]
  453.  
  454.     mov ecx,ted_cur_x
  455.     add ecx,[hScr.position]
  456.     mov ted_sel_x1,ecx
  457.  
  458.     mov ecx,ted_cur_y
  459.     add ecx,[wScr.position]
  460.     mov ted_sel_y1,ecx
  461.   pop edi ecx
  462.   call draw_but_toolbar ;redraw toolbar (need to button Copy)
  463.   ret
  464. endp
  465.  
  466. ;input:
  467. ; cl_al_mem = 1 - clear all memory
  468. align 4
  469. proc ted_clear, edit:dword, cl_al_mem:dword
  470.   push edi
  471.   mov edi,dword[edit]
  472.  
  473.   mov ted_cur_x,0
  474.   mov ted_cur_y,0
  475.   mov ted_tim_ch,0
  476.   mov ted_tim_ls,0
  477.   mov ted_tim_co,0
  478.   mov ted_tim_undo,0
  479.   mov ted_help_id,-1
  480.  
  481.   mov [wScr.position],0
  482.   mov [wScr.max_area],100
  483.   mov [wScr.redraw],1
  484.   mov [hScr.position],0
  485.   mov [hScr.max_area],100
  486.  
  487.   mov ted_sel_x0,0
  488.   mov ted_sel_y0,0
  489.   mov ted_sel_x1,0
  490.   mov ted_sel_y1,0
  491.  
  492.   cmp dword[cl_al_mem],0
  493.   je .exit
  494.  
  495.   push ecx edx
  496.   mov ecx,sizeof.symbol*maxChars
  497.   mov edx,ted_tex
  498.   @@:
  499.     mov byte [edx],0
  500.     inc edx
  501.   loop @b
  502.   mov edx,ted_tex
  503.   mov dword [edx+6],1
  504.   pop edx ecx
  505.  
  506.   .exit:
  507.   pop edi
  508.   ret
  509. endp
  510.  
  511. ;--- out_reg = Col[ind_reg].Text[0] ---
  512. macro ColToIndexOffset ind_reg,out_reg {
  513.   mov out_reg,ind_reg
  514.   imul out_reg,sizeof.TexColViv
  515.   add out_reg,ted_key_words_data
  516. }
  517.  
  518.  
  519. align 4
  520. proc InitColText, edit:dword
  521.   pushad
  522.   mov edi,dword[edit]
  523.  
  524.   mov ebx,dword[fn_col_option]
  525.   copy_path ebx,fn_syntax_dir,file_name_rez,0x0
  526.   copy_path file_name_rez,sys_path,file_name,0x0
  527.  
  528.   mov eax,70
  529.   mov [run_file_70.func_n], 0
  530.   mov [run_file_70.param1], 0
  531.   mov [run_file_70.param2], 0
  532.   mov ebx,ted_syntax_file_end
  533.   sub ebx,ted_syntax_file
  534.   mov [run_file_70.param3], ebx
  535.   m2m [run_file_70.param4], ted_syntax_file
  536.   mov [run_file_70.rezerv], 0
  537.   mov [run_file_70.name], file_name
  538.   mov ebx,run_file_70
  539.   int 0x40
  540.  
  541.   mov ecx,0x100
  542.   mov edx,FkPos
  543.   @@:
  544.     mov dword[edx],-1
  545.     add edx,4
  546.   loop @b
  547.  
  548.   ;init: ted_colors_text_count, ted_key_words_count, ...
  549.   mov ted_colors_text_count,1
  550.   mov ted_key_words_count,0
  551.     mov ted_help_text_f1,0
  552.   mov ted_help_id,-1 ;èäåíòèôèêàòîð ñëîâà äëÿ ñïðàâêè
  553.  
  554.   cmp eax,6
  555.   je @f
  556.   cmp eax,0
  557.   je @f
  558.     cmp ax,10
  559.     jl .zifra_0_9
  560.       mov al,'?'
  561.       sub ax,48
  562.     .zifra_0_9:
  563.     add ax,48
  564.  
  565.     mov byte[msgbox_3.err],al
  566.     stdcall [mb_create],msgbox_3,thread ;message: Can-t open color options file!
  567.     jmp .no_colors
  568.   @@:
  569.  
  570.   mov eax,edi ;ñîõðàíÿåì çíà÷åíèå edi
  571.   mov esi,ted_syntax_file
  572.   add edi,ted_offs_count_colors
  573.   mov ecx,9*4
  574.   rep movsb
  575.   mov edi,eax ;âîñòàíàâëèâàåì çíà÷åíèå edi
  576.  
  577.   mov eax,ted_syntax_file
  578.   add eax,32
  579.   mov ted_text_colors,eax
  580.  
  581.   mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
  582.   add eax,8
  583.   shl eax,2
  584.   add eax,ted_syntax_file
  585.   mov ted_key_words_data,eax
  586.  
  587.   mov ecx,ted_key_words_count ;init: FkPos (first key positions)
  588.   xor eax,eax
  589.   @@:
  590.     ColToIndexOffset eax,edx
  591.     xor ebx,ebx
  592.     mov bl,byte[edx]
  593.     shl bx,2
  594.     mov esi,FkPos
  595.     add esi,ebx
  596.     cmp dword[esi],-1
  597.     jne .no_ch_key
  598.       mov dword[esi],eax
  599.     .no_ch_key:
  600.     inc eax
  601.   loop @b
  602.  
  603.   ;init: ted_help_text_f1
  604.   mov ecx,ted_key_words_count
  605.   imul ecx,sizeof.TexColViv
  606.   add ecx,ted_key_words_data
  607.   mov ted_help_text_f1,ecx
  608.  
  609.   .no_colors:
  610.   popad
  611.   ret
  612. endp
  613.  
  614. ;input:
  615. ; ebx = file size
  616. ; edi = pointer to tedit struct
  617. align 4
  618. proc OpenFile
  619.   push eax ;destination
  620.   push ecx ;for cycle
  621.   push edx ;source
  622.  
  623.     stdcall ted_clear,edi,0 ;÷èñòèì íå âñþ ïàìÿòü, ïîòîìó ÷òî íèæå áóäåì åå çàïîëíÿòü íîâûìè äàíûìè
  624.     mov eax,ebx
  625.     mov ecx,ebx
  626.     add eax,2
  627.     ConvertIndexToPointer eax
  628.     mov edx,ted_tex
  629.     add edx,ebx
  630.   push ebx
  631.     @@:
  632.       mov ebx,[edx]
  633.       mov byte [eax],bl
  634.       mov dword [eax+2],ecx
  635.       inc dword [eax+2]
  636.       mov dword [eax+6],ecx
  637.       add dword [eax+6],3
  638.       ;mov byte[eax+1],0 ;col=0
  639.       mov dword [eax+10],-1 ;tc=-1
  640.       mov dword [eax+14],0 ;td=0
  641.  
  642.       cmp ecx,0
  643.       je @f
  644.       dec ecx
  645.       dec edx
  646.       sub eax,sizeof.symbol
  647.       jmp @b
  648.     @@:
  649.   pop ebx
  650.     add eax,2
  651.     mov dword [eax],0 ; first sumbol 'perv=0'
  652.  
  653.     mov edx,ted_tex
  654.     ; begining sumbol 'perv=0' 'next=2'
  655.     mov dword [edx+2],0
  656.     mov dword [edx+6],2
  657.  
  658.     add edx,sizeof.symbol
  659.     mov dword [edx+6],0 ; last sumbol 'next=0'
  660.     mov dword [edx+2],ebx ; last sumbol 'perv=last'
  661.     inc dword [edx+2]
  662.  
  663.     mov edx,ebx
  664.     inc edx ;2 = rezerv sumbols
  665.     imul edx,sizeof.symbol
  666.     add edx,ted_tex
  667.     mov dword [edx+6],1 ; last sumbol 'next=1'
  668.  
  669.     @@: ;clear memory, need if before was open big file
  670.       add edx,sizeof.symbol
  671.       cmp edx,ted_tex_end
  672.       jge @f
  673.         mov dword[edx+10],0
  674.         mov dword[edx+14],0
  675.       jmp @b
  676.     @@:
  677.  
  678.     call GetNumLines
  679.     cmp eax,100
  680.     jge @f
  681.       mov eax,100
  682.     @@:
  683.     mov [wScr.max_area],eax
  684. ;    mov [wScr.redraw],1
  685.   pop edx ecx eax
  686.  
  687.   call CmColored
  688.   call draw_but_toolbar
  689.   stdcall draw_main_win,edi
  690.   ret
  691. endp
  692.  
  693. ;input:
  694. ; edx = pointer to symbol struct
  695. ; edi = pointer to tedit struct
  696. ;output:
  697. ; edx = pointer to 'perv' visible symbol struct
  698. align 4
  699. IteratPerv:
  700.   cmp ted_tim_undo,0
  701.   je .else
  702.   push ebx
  703.   @@:
  704.     call GetTexPervPos
  705.     cmp edx,ted_tex
  706.     je @f
  707.     call SymbNotVis
  708.     cmp bl,1
  709.     je @b
  710.     cmp byte[edx],10 ;ïðîïóñê ñèìâîëà ñ êîäîì 10
  711.     je @b
  712.   @@:
  713.   pop ebx
  714.   ret
  715.   .else:
  716.     call GetTexPervPos
  717.     cmp edx,ted_tex
  718.     je .endif
  719.     cmp dword [edx+14],0
  720.     jne .else
  721.     cmp byte[edx],10 ;ïðîïóñê ñèìâîëà ñ êîäîì 10
  722.     je .else
  723.   .endif:
  724.   ret
  725.  
  726.  
  727. ;input:
  728. ; edx = pointer to symbol struct
  729. ; edi = pointer to tedit struct
  730. ;output:
  731. ; edx = pointer to 'next' visible symbol struct
  732. align 4
  733. IteratNext:
  734.   cmp ted_tim_undo,0
  735.   je .else
  736.   push ebx
  737.   @@:
  738.     call GetTexNextPos
  739.     cmp edx,ted_tex_1
  740.     jle @f
  741.     call SymbNotVis
  742.     cmp bl,1
  743.     je @b
  744.     cmp byte[edx],10 ;ïðîïóñê ñèìâîëà ñ êîäîì 10
  745.     je @b
  746.   @@:
  747.   pop ebx
  748.   ret
  749.   .else:
  750.     call GetTexNextPos
  751.     cmp edx,ted_tex_1
  752.     jle .endif
  753.     cmp dword [edx+14],0
  754.     jne .else
  755.     cmp byte[edx],10 ;ïðîïóñê ñèìâîëà ñ êîäîì 10
  756.     je .else
  757.   .endif:
  758.   ret
  759.  
  760. ;input:
  761. ; bl = symbol end of select
  762. ; edx = pointer to symbol struct
  763. ; edi = pointer to tedit struct
  764. align 4
  765. ItPoNextUc:
  766.   @@:
  767.     cmp bl,byte[edx]
  768.     je @f
  769.     cmp edx,ted_tex_1
  770.     jle @f
  771.     call IteratNext
  772.     jmp @b
  773.   @@:
  774.   call IteratNext
  775.   ret
  776.  
  777. ;input:
  778. ; edx = pointer to symbol struct
  779. ; edi = pointer to tedit struct
  780. align 4
  781. ItPervColorTag:
  782.   @@:
  783.     cmp byte[edx+1],0
  784.     jne @f
  785.     call IteratPerv
  786.     cmp edx,ted_tex_1
  787.     jle @f
  788.     jmp @b
  789.   @@:
  790.   ret
  791.  
  792. ;input:
  793. ; edx = pointer to symbol struct
  794. ; edi = pointer to tedit struct
  795. align 4
  796. ItNextColorTag:
  797.   @@:
  798.     call IteratNext
  799.     cmp byte[edx+1],0
  800.     jne @f
  801.     cmp edx,ted_tex_1
  802.     jle @f
  803.     jmp @b
  804.   @@:
  805.   ;call IteratNext
  806.   ret
  807.  
  808. ;input:
  809. ; edx = pointer to symbol struct
  810. ; edi = pointer to tedit struct
  811. ;output:
  812. ; bl = 1 if sumbol not visible
  813. ; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
  814. align 4
  815. SymbNotVis:
  816.   push eax
  817.  
  818.   xor bl,bl
  819.  
  820.   cmp dword [edx+14],0
  821.   je @f
  822.   mov eax,[edx+14] ;eax=tex[i].td
  823.   add eax,ted_tim_undo
  824.   cmp eax,ted_tim_ch
  825.   jg @f
  826.     mov bl,1
  827.     pop eax
  828.     ret
  829.   @@:
  830.  
  831.   mov eax,ted_tim_ch
  832.   sub eax,ted_tim_undo
  833.   cmp [edx+10],eax
  834.   jle @f
  835.     or bl,1
  836.   @@:
  837.  
  838.   pop eax
  839.   ret
  840.  
  841.  
  842. ;input:
  843. ; text:dword - pointer to text string
  844. ; add_opt:dword - options
  845. align 4
  846. proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
  847.   locals
  848.     new_spc dd ? ;count new spaces
  849.         new_lin dd ? ;count new lines
  850.   endl
  851. ;èñïîëüçîâàíèå ðåãèñòðîâ âíóòðè ôóíêöèè:
  852. ;eax - ïîçèöèÿ äëÿ âñòàâêè òåêñòà
  853. ;ebx - äëÿ âðåìåííûõ íóæä, äëèííà âñòàâëÿåìîãî òåêñòà
  854. ;ecx - äëÿ âðåìåííûõ íóæä
  855. ;edx - óêàçàòåëü íà ñòðóêòóðó ñèìâîëà
  856.   pushad
  857.   mov edi,dword[edit]
  858.   mov esi,dword[text]
  859.  
  860.   call GetPos
  861.   call GetTexPervPos
  862.   call GetTexArrIndex ;eax=po_t
  863.  
  864.   mov dword[new_spc],0
  865.   cmp ted_gp_opt,2
  866.   je @f
  867.     push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
  868.       mov eax,ted_cur_x
  869.       add eax,[hScr.position]
  870.       mov dword[new_spc],eax
  871.  
  872.       mov eax,ted_cur_y
  873.       add eax,[wScr.position]
  874.       call ted_strlen ;ebx = line len
  875.       sub dword[new_spc],ebx
  876.     pop eax
  877.   @@:
  878.  
  879.   mov ebx,dword[t_len]
  880.  
  881.   mov dword[new_lin],0
  882.   cmp ted_gp_opt,0
  883.   jne @f
  884.     push eax
  885.       mov eax,ted_cur_y
  886.       add eax,[wScr.position]
  887.       inc eax
  888.       mov dword[new_lin],eax
  889.  
  890.       call GetNumLines
  891.       sub dword[new_lin],eax
  892.     pop eax
  893.   @@:
  894.  
  895.   mov edx,sizeof.symbol
  896.   shl edx,1
  897.   add edx,ted_tex
  898.   @@: ;for(i=2;i<texMax;i++)
  899.     cmp dword [edx+10],0 ;if(!tex[i].tc && !tex[i].td)
  900.     jne .u1f
  901.     cmp dword [edx+14],0
  902.     jne .u1f
  903.       test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
  904.       jz .no_tim
  905.         inc ted_tim_ch
  906.       .no_tim:
  907.       test dword[add_opt],ted_opt_ed_move_cursor
  908.       jz .no_cur_mov
  909.       cmp dword[new_lin],0 ;åñëè åñòü äîáàâî÷íûå ñòðîêè, òî êóðñîð åùå íå äâèãàåì
  910.       jg .no_cur_mov
  911.       cmp dword[new_spc],0 ;åñëè íåò äîáàâî÷íûõ ïðîáåëîâ, òî êóðñîð òîæå íå äâèãàåì
  912.       jg .no_cur_mov
  913.         inc ted_cur_x ;move cursor
  914.         ;call GoToPos
  915.         cmp byte [esi],13
  916.         jne .no_cur_mov
  917.           mov ted_cur_x,0
  918.           inc ted_cur_y
  919.       .no_cur_mov:
  920.  
  921.       mov ecx,ted_opt_ed_change_time
  922.           not ecx
  923.           and dword[add_opt],ecx ;n_tim=false;
  924.  
  925.       mov cl,byte [esi] ;tex[i].c=ta[ns];
  926.       mov byte [edx],cl
  927.       m2m dword [edx+10],ted_tim_ch ;tex[i].tc=ted_tim_ch;
  928.       mov [edx+2],eax ;tex[i].perv=po_t;
  929.  
  930.       mov ecx,eax
  931.       imul ecx,sizeof.symbol
  932.       add ecx,ted_tex ; *** ecx = tex[po_t] ***
  933.       add ecx,6   ; *** ecx = tex[po_t].next ***
  934.       m2m dword [edx+6],dword [ecx] ;tex[i].next=tex[po_t].next;
  935.  
  936.       call GetTexArrIndex ;*** eax = i ***
  937.       cmp eax,maxChars
  938.       jge @f
  939.       mov [ecx],eax ;tex[po_t].next=i; // ññûëêè ïåðåíàïðàâëÿåì
  940.       mov ecx,[edx+6] ; *** ecx = tex[i].next ***
  941.       imul ecx,sizeof.symbol
  942.       add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
  943.       mov [ecx+2],eax ;tex[tex[i].next].perv=i;
  944.  
  945.       cmp dword[new_lin],0 ;add lines or text
  946.       jle .spc_add
  947.         dec dword[new_lin]
  948.         mov byte [edx],13
  949.         jmp .u1f
  950.       .spc_add:
  951.       cmp dword[new_spc],0 ;add spaces or text
  952.       jle .tex_add
  953.         dec dword[new_spc]
  954.         mov byte [edx],' '
  955.         jmp .u1f
  956.       .tex_add:
  957.       inc esi
  958.       dec ebx
  959.     .u1f:
  960.     add edx,sizeof.symbol
  961.     cmp edx,ted_tex_end
  962.     jge @f ;out of memory
  963.     cmp ebx,0
  964.     jne @b
  965.   @@:
  966.  
  967.   call CmColored
  968.   popad
  969.   ret
  970. endp
  971.  
  972.  
  973. ;input:
  974. ;  ecx = position to free insert cell
  975. ;  edx = pointer to sumbol, when insert
  976. ;  esi = pointer to added symbol
  977. ;  edi = pointer to tedit struct
  978. ;output:
  979. ;  ecx = position to inserted cell
  980. align 4
  981. CharAdd:
  982.  
  983.   .loop_b:
  984.     cmp ecx,ted_tex_end
  985.     jge .end_f
  986.     cmp dword[ecx+10],0
  987.     jne @f
  988.       cmp dword[ecx+14],0
  989.       je .loop_e
  990.     @@:
  991.     add ecx,sizeof.symbol
  992.     jmp .loop_b
  993.   .loop_e:
  994.  
  995.   push eax ebx
  996.   mov eax,ted_tim_ch
  997.   mov dword[ecx+10],eax
  998.   mov al,byte[esi]
  999.   mov byte[ecx],al
  1000.  
  1001.   call GetTexArrIndex ; *** eax=pos ***
  1002.   mov [ecx+2],eax ;tex[i].perv=pos;
  1003.   m2m dword[ecx+6],dword[edx+6] ;tex[i].next=tex[pos].next;
  1004.  
  1005.   push edx
  1006.     mov edx,ecx
  1007.     call GetTexArrIndex ; *** eax=i ***
  1008.   pop edx
  1009.  
  1010.   mov [edx+6],eax ;tex[pos].next=i; // ññûëêè ïåðåíàïðàâëÿåì
  1011.   mov ebx,[ecx+6]
  1012.   ConvertIndexToPointer ebx
  1013.   mov [ebx+2],eax ;tex[tex[i].next].perv=i; // ...
  1014.   pop ebx eax
  1015.  
  1016.   .end_f:
  1017.   call CmColored
  1018.   ret
  1019.  
  1020.  
  1021. ;input:
  1022. ; conv_table = pointert to convert table
  1023. ; edi = pointer to tedit struct
  1024. ;output:
  1025. ; esi = count converted symbols
  1026. align 4
  1027. proc ConvertSelText
  1028.   locals
  1029.     conv_cou dd ?
  1030.   endl
  1031.   mov dword[conv_cou],0
  1032.   pushad
  1033.  
  1034.   stdcall IsSel,edi
  1035.   cmp al,0
  1036.   je .end_f
  1037.     stdcall ted_set_undo,edi
  1038.     stdcall SelNormalize,edi
  1039.  
  1040.     mov esi,ted_seln_x0
  1041.     mov ecx,ted_seln_y0
  1042.     call GetPosByParam
  1043.     mov eax,edx
  1044.     mov esi,ted_seln_x1
  1045.     mov ecx,ted_seln_y1
  1046.     call GetPosByParam
  1047.     ;call GetTexPervPos
  1048.     mov ebx,edx
  1049.  
  1050.     cmp eax,ebx
  1051.     je .end_f
  1052.  
  1053.     inc ted_tim_ch
  1054.     mov edx,eax ;i=p0;
  1055.     mov ecx,2
  1056.     ConvertIndexToPointer ecx
  1057.     @@:
  1058.       mov esi,[edx]
  1059.       and esi,0xff
  1060.       add esi,[conv_table] ;EvUpper
  1061.       cmp byte [esi],0
  1062.       je .no_change
  1063.         m2m dword [edx+14],ted_tim_ch
  1064.         call CharAdd ;b_pos=CharAdd(tex[i].c^32,i,false,b_pos);
  1065.         call GetTexNextPos ;go to added symbol
  1066.         inc dword[conv_cou]
  1067.       .no_change:
  1068.  
  1069.       call IteratNext
  1070.       cmp edx,ted_tex
  1071.       je @f
  1072.       cmp edx,ebx
  1073.       je @f
  1074.  
  1075.       jmp @b
  1076.     @@:
  1077.     cmp dword[conv_cou],0
  1078.     jne @f
  1079.       dec ted_tim_ch
  1080.     @@:
  1081.   .end_f:
  1082.   popad
  1083.   mov esi,dword[conv_cou]
  1084.   ret
  1085. endp
  1086.  
  1087. ;output:
  1088. ; bl = 0 - no delete
  1089. ; bl = 1 - delete
  1090. align 4
  1091. proc TextDel, edit:dword, del_opt:dword
  1092.   push cx edx edi
  1093.   mov edi,dword[edit]
  1094.   mov ebx,dword[del_opt]
  1095.  
  1096.   xor cl,cl
  1097.   test ebx,ted_opt_ed_move_cursor
  1098.   jz @f
  1099.     call CurMoveLeft
  1100.     cmp dl,0
  1101.     je .no_del
  1102.   @@:
  1103.   call GetPos
  1104.   cmp ted_gp_opt,1
  1105.   je .no_del
  1106.     test ebx,ted_opt_ed_change_time
  1107.     jz @f
  1108.       inc ted_tim_ch
  1109.     @@:
  1110.     m2m dword [edx+14], ted_tim_ch
  1111.     mov cl,1
  1112.   .no_del:
  1113.   mov bl,cl
  1114.   pop edi edx cx
  1115.   ret
  1116. endp
  1117.  
  1118. ;input:
  1119. ; edi = pointer to tedit struct
  1120. ;output:
  1121. ; al = 1 if delete
  1122. ;description:
  1123. ; Ôóíêöèÿ óäàëÿåò âûäåëåííûé òåêñò
  1124. align 4
  1125. proc SelTextDel, del_opt:dword
  1126.         push ebx ecx edx esi
  1127.  
  1128.         stdcall IsSel,edi
  1129.         cmp al,0
  1130.         je .end_f
  1131.  
  1132.                 stdcall SelNormalize,edi
  1133.  
  1134.                 mov esi,ted_seln_x1
  1135.                 mov ecx,ted_seln_y1
  1136.                 call GetPosByParam
  1137.                 mov ebx,edx
  1138.  
  1139.                 mov esi,ted_seln_x0
  1140.                 mov ecx,ted_seln_y0
  1141.                 call GetPosByParam
  1142.  
  1143.                 test dword[del_opt],ted_opt_ed_change_time
  1144.                 jz @f
  1145.                         inc ted_tim_ch
  1146.                 @@:
  1147.                 cmp edx,ted_tex
  1148.                 je @f
  1149.                 cmp edx,ebx ;if(i==te)break;
  1150.                 je @f
  1151.                         m2m dword[edx+14],ted_tim_ch
  1152.                         mov esi,ted_opt_ed_change_time
  1153.                         not esi
  1154.                         and dword[del_opt],esi ;n_tim=false;
  1155.                         call IteratNext
  1156.                         jmp @b
  1157.                 @@:
  1158.                 test dword[del_opt],ted_opt_ed_change_time
  1159.                 jz @f
  1160.                         dec ted_tim_ch
  1161.                         xor al,al
  1162.                 @@:
  1163.                 test dword[del_opt],ted_opt_ed_change_time
  1164.                 jnz @f
  1165.                         mov ecx,ted_seln_x0
  1166.                         mov edx,ted_seln_y0
  1167.                         call GoToPos
  1168.                         mov ted_sel_x0,0
  1169.                         mov ted_sel_y0,0
  1170.                         mov ted_sel_x1,0
  1171.                         mov ted_sel_y1,0
  1172.                 @@:
  1173.         .end_f:
  1174.         pop esi edx ecx ebx
  1175.         ret
  1176. endp
  1177.  
  1178.  
  1179. ;input:
  1180. ; eax = pointer to begin select
  1181. ; ebx = pointer to end select
  1182. ; edi = pointer to tedit struct
  1183. align 4
  1184. Revers:
  1185.   cmp eax,ebx
  1186.   jne @f
  1187.     ret
  1188.   @@:
  1189.  
  1190.   push ecx edx
  1191.  
  1192.   mov edx,ted_tex_1
  1193.   cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
  1194.   jne @f
  1195.     call GetTexPervPos
  1196.     mov ebx,edx
  1197.   @@:
  1198.  
  1199.   push esi
  1200.     mov edx,[eax+2] ; *** edx = tex[p0].perv ***
  1201.     ConvertIndexToPointer edx
  1202.     add edx,6
  1203.     mov ecx,[edx] ;tmp = tex[tex[p0].perv].next;
  1204.  
  1205.     mov esi,[ebx+6] ; *** esi = tex[p1].next ***
  1206.     ConvertIndexToPointer esi
  1207.     add esi,2
  1208.     m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv;
  1209.  
  1210.     mov [esi],ecx ;tex[tex[p1].next].perv = tmp;
  1211.   pop esi
  1212.  
  1213.   mov ecx,[eax+2] ;tmp = tex[p0].perv;
  1214.   m2m dword[eax+2],dword[ebx+6] ;tex[p0].perv = tex[p1].next;
  1215.   mov [ebx+6],ecx ;tex[p1].next = tmp;
  1216.  
  1217.   mov edx,eax ;i=p0;
  1218.   @@:
  1219.     mov ecx,[edx+6] ;tmp = tex[i].next;
  1220.     m2m dword[edx+6],dword[edx+2] ;tex[i].next = tex[i].perv;
  1221.     mov [edx+2],ecx ;tex[i].perv = tmp;
  1222.     cmp edx,ebx ;if(i==p1)break;
  1223.     je @f
  1224. ; ---
  1225. ;cmp edx,ted_tex
  1226. ;je @f
  1227. ; ---
  1228.     mov edx,ecx ;i = tmp;
  1229.     ConvertIndexToPointer edx
  1230.     jmp @b
  1231.   @@:
  1232.   pop edx ecx
  1233.   call CmColored
  1234.   ret
  1235.  
  1236.  
  1237. ;input:
  1238. ; edi = pointer to tedit struct
  1239. ;output:
  1240. ; dl = 0 not move
  1241. ; dl = 2 if move up
  1242. ; dl = 8 if scroll move up
  1243. align 4
  1244. CurMoveUp:
  1245.   cmp ted_cur_y,0
  1246.   je @f
  1247.     dec ted_cur_y
  1248.     mov dl,2
  1249.     ret
  1250.   @@:
  1251.   cmp [wScr.position],0
  1252.   je @f
  1253.     dec [wScr.position]
  1254.     mov dl,8
  1255.     ret
  1256.   @@:
  1257.   mov dl,0
  1258.   ret
  1259.  
  1260. ;input:
  1261. ; edi = pointer to tedit struct
  1262. ;output:
  1263. ; dl = 0 not move
  1264. ; dl = 2 if move down
  1265. ; dl = 8 if scroll move down
  1266. align 4
  1267. CurMoveDown:
  1268.   push eax ebx
  1269.   mov dl,0
  1270.   mov ebx,ted_scr_w
  1271.   mov eax,dword[ebx+sb_offs_cur_area]
  1272.   dec eax
  1273.   cmp ted_cur_y,eax
  1274.   jge @f
  1275.     inc ted_cur_y
  1276.     mov dl,2
  1277.     jmp .ret_f
  1278.   @@:
  1279.   mov eax,ted_cur_y
  1280.   add eax,dword[ebx+sb_offs_position]
  1281.   inc eax
  1282.   cmp dword[ebx+sb_offs_max_area],eax
  1283.   jle @f
  1284.     inc dword[ebx+sb_offs_position]
  1285.     mov dl,8
  1286.   @@:
  1287.   .ret_f:
  1288.   pop ebx eax
  1289.   ret
  1290.  
  1291.  
  1292. ;output:
  1293. ; dl = 0 not move
  1294. ; dl = 1 if move up
  1295. align 4
  1296. CurMovePageUp:
  1297.   push eax
  1298.   mov eax,[wScr.cur_area]
  1299.   xor dl,dl
  1300.   cmp eax,[wScr.position]
  1301.   jg @f
  1302.     sub [wScr.position],eax
  1303.     mov dl,1
  1304.   @@:
  1305.   cmp [wScr.position],0
  1306.   je @f
  1307.   cmp dl,1
  1308.   je @f
  1309.     mov [wScr.position],0
  1310.     mov dl,1
  1311.   @@:
  1312.   pop eax
  1313.   ret
  1314.  
  1315. ;input:
  1316. ; edi = pointer to tedit struct
  1317. align 4
  1318. CurMovePageDown:
  1319.         push eax ebx ecx
  1320.         mov ecx,ted_scr_w
  1321.  
  1322.         xor dl,dl
  1323.         mov eax,dword[ecx+sb_offs_max_area]
  1324.         sub eax,dword[ecx+sb_offs_cur_area]
  1325.         cmp dword[ecx+sb_offs_position],eax
  1326.         jge @f
  1327.                 mov ebx,dword[ecx+sb_offs_cur_area]
  1328.                 add dword[ecx+sb_offs_position],ebx
  1329.                 mov dl,1
  1330.                 mov dword[ecx+sb_offs_redraw],1
  1331.                 cmp dword[ecx+sb_offs_position],eax
  1332.                 jle @f
  1333.                         mov dword[ecx+sb_offs_position],eax
  1334.         @@:
  1335.         pop ecx ebx eax
  1336.         ret
  1337.  
  1338. ;input:
  1339. ; edi = pointer to tedit struct
  1340. ;output:
  1341. ; dl = 0 not move
  1342. ; dl = 1 if move left
  1343. ; dl = 3 if move left and up
  1344. ; dl = 8 if scroll move up
  1345. align 4
  1346. CurMoveLeft:
  1347.   cmp ted_cur_x,0
  1348.   je @f
  1349.     dec ted_cur_x
  1350.     mov dl,1
  1351.     ret
  1352.   @@:
  1353.   cmp [hScr.position],0
  1354.   je @f
  1355.     dec [hScr.position]
  1356.     mov dl,8
  1357.     ret
  1358.   @@:
  1359.   cmp ted_cur_y,0
  1360.   jne @f
  1361.     mov dl,0
  1362.     cmp [wScr.position],0
  1363.     je .ret_f
  1364.       dec [wScr.position]
  1365.       call OnInitialUpdate
  1366.       call CurMoveX_LastChar
  1367.       mov dl,8
  1368.     jmp .ret_f
  1369.   @@:
  1370.   cmp ted_cur_y,0
  1371.   je @f
  1372.   dec ted_cur_y
  1373.   call CurMoveX_LastChar
  1374.   cmp dl,8
  1375.   je .ret_f
  1376.   mov dl,3
  1377.   ret
  1378.   @@:
  1379.   mov dl,0
  1380.   .ret_f:
  1381.   ret
  1382.  
  1383. ;input:
  1384. ; edi = pointer to tedit struct
  1385. align 4
  1386. CurMoveRight:
  1387.   push eax
  1388.   xor dl,dl
  1389.   mov eax,[hScr.cur_area]
  1390.   cmp ted_cur_x,eax
  1391.   jge @f
  1392.     inc ted_cur_x
  1393.     mov dl,1
  1394.     jmp .ret_f
  1395.   @@:
  1396.     inc [hScr.position]
  1397.     mov dl,8
  1398.   .ret_f:
  1399.   pop eax
  1400.   ret
  1401.  
  1402. ;input:
  1403. ; edi = pointer to tedit struct
  1404. align 4
  1405. CurMoveX_LastChar:
  1406. ;[hScr.position]
  1407. ;[hScr.cur_area]
  1408. ;dl-???
  1409.   push eax ebx
  1410.   mov eax,ted_cur_y
  1411.   add eax,[wScr.position]
  1412.   call ted_strlen
  1413.   xor dl,dl
  1414.  
  1415.   cmp ebx,[hScr.position]
  1416.   jge @f
  1417.     mov dl,8
  1418.     mov [hScr.position],ebx
  1419.   @@:
  1420.   sub ebx,[hScr.position]
  1421.  
  1422.   cmp ebx,[hScr.cur_area]
  1423.   jle @f ; b---[---]---e
  1424.     add [hScr.position],ebx
  1425.     mov ebx,[hScr.cur_area]
  1426.     sub [hScr.position],ebx
  1427.     mov dl,8
  1428.   @@:
  1429.   mov ted_cur_x,ebx
  1430.   pop ebx eax
  1431.   ret
  1432.  
  1433. ;input:
  1434. ; edi = pointer to tedit struct
  1435. ;output:
  1436. ; dl = 0 not move
  1437. ; dl = 1 move cursor
  1438. ; dl = 8 move cursor and scroll
  1439. align 4
  1440. CurMoveX_FirstChar:
  1441.   xor dl,dl
  1442.   cmp ted_cur_x,0
  1443.   je @f
  1444.   mov ted_cur_x,0
  1445.   mov dl,1
  1446.   @@:
  1447.   cmp [hScr.position],0
  1448.   je @f
  1449.     mov [hScr.position],0
  1450.     mov dl,8
  1451.   @@:
  1452.   ret
  1453.  
  1454. ;input:
  1455. ; edx = pointer to symbol struct
  1456. ; edi = pointer to tedit struct
  1457. ;output:
  1458. ; eax = array index
  1459. align 4
  1460. GetTexArrIndex:
  1461.   push ecx edx
  1462.  
  1463.   mov eax,edx
  1464.   sub eax,ted_tex
  1465.   xor edx,edx
  1466.   mov ecx,sizeof.symbol
  1467.   div ecx
  1468.  
  1469.   pop edx ecx
  1470.   ret
  1471.  
  1472. ;input:
  1473. ; edx = pointer to symbol struct
  1474. ; edi = pointer to tedit struct
  1475. ;output:
  1476. ; edx = pointer to 'perv' struct
  1477. align 4
  1478. GetTexPervPos:
  1479.   push dword [edx+2]
  1480.   pop edx
  1481.   imul edx,sizeof.symbol
  1482.   add edx,ted_tex
  1483.   ret
  1484.  
  1485. ;input:
  1486. ; edx = pointer to symbol struct
  1487. ;output:
  1488. ; edx = pointer to 'next' symbol struct
  1489. align 4
  1490. GetTexNextPos:
  1491.   push dword [edx+6]
  1492.   pop edx
  1493.   imul edx,sizeof.symbol
  1494.   add edx,ted_tex
  1495.   ret
  1496.  
  1497. ;input:
  1498. ; edi = pointer to tedit struct
  1499. ;output:
  1500. ; edx = symbol under cursor
  1501. ; ted_gp_opt = 1,2
  1502. ; edx = tex[1].perv if error
  1503. ; ted_gp_opt = 0
  1504. align 4
  1505. GetPos:
  1506.   push esi ecx
  1507.     mov esi,ted_cur_x
  1508.     add esi,[hScr.position]
  1509.     mov ecx,ted_cur_y
  1510.     add ecx,[wScr.position]
  1511.     call GetPosByParam
  1512.   pop ecx esi
  1513.   ret
  1514.  
  1515.  
  1516. ;input:
  1517. ; esi = XPos
  1518. ; ecx = YPos
  1519. ; edi = pointer to tedit struct
  1520. ;output:
  1521. ; edx = symbol under cursor
  1522. ; ted_gp_opt = 1 if found text line
  1523. ; ted_gp_opt = 2 if found text line and column
  1524. ; edx = tex[1] if error
  1525. ; ted_gp_opt = 0 if text no found
  1526. align 4
  1527. GetPosByParam:
  1528.   push eax ;Row
  1529.   push ebx ;Col
  1530.  
  1531.   xor eax,eax
  1532.   xor ebx,ebx
  1533.   mov ted_gp_opt,0
  1534.   mov edx,ted_tex
  1535.   @@:
  1536.     call IteratNext
  1537.     cmp edx,ted_tex_1
  1538.     jle @f
  1539.     cmp ebx,esi
  1540.     jne .u1_0 ;Col <> ted_cur_x
  1541.       mov ted_gp_opt,1
  1542.       cmp eax,ecx
  1543.       jge @f ; Row >= ted_cur_y
  1544.     .u1_0:
  1545.     mov ted_gp_opt,0
  1546.     inc ebx
  1547.     cmp byte [edx],13
  1548.     jne @b
  1549.     cmp eax,ecx
  1550.     jge @f ; Row >= ted_cur_y
  1551.     inc eax
  1552.     xor ebx,ebx
  1553.     jmp @b
  1554.   @@:
  1555.   cmp eax,ecx
  1556.   jne @f ; Row = ted_cur_y
  1557.     inc ted_gp_opt
  1558.   @@:
  1559.   cmp ted_gp_opt,0
  1560.   jne @f
  1561.     mov edx,ted_tex_1
  1562.     ;call GetTexPervPos
  1563.   @@:
  1564.   pop ebx eax
  1565.   ret
  1566.  
  1567.  
  1568. ;input:
  1569. ; eax = Row
  1570. ; edi = pointer to tedit struct
  1571. ;output:
  1572. ; ebx = str len
  1573. align 4
  1574. ted_strlen:
  1575.   push edx ecx
  1576.   ;ecx = Row, from cycle
  1577.  
  1578.   xor ebx,ebx
  1579.   xor ecx,ecx
  1580.   mov edx,ted_tex
  1581.   @@:
  1582.     call IteratNext
  1583.     cmp edx,ted_tex_1
  1584.     jle @f
  1585.     inc ebx
  1586.     cmp byte [edx],13
  1587.     jne @b
  1588.     dec ebx ;lenght minus 1 sumbol to paragraph
  1589.     cmp eax,ecx
  1590.     je @f
  1591.     xor ebx,ebx
  1592.     inc ecx
  1593.     jmp @b
  1594.   @@:
  1595.  
  1596.   cmp eax,ecx
  1597.   je @f
  1598.     xor ebx,ebx
  1599.   @@:
  1600.  
  1601.   pop ecx edx
  1602.   ret
  1603.  
  1604.  
  1605. ;input:
  1606. ; edx = symbol position
  1607. ; edi = pointer to tedit struct
  1608. ;output:
  1609. ; eax = number of line
  1610. ; ebx = symbol position in line
  1611. align 4
  1612. GetTexCoords:
  1613.   push edx
  1614.   xor eax,eax
  1615.   xor ebx,ebx
  1616.   @@:
  1617.     call IteratPerv
  1618.  
  1619.     cmp eax,0
  1620.     jne .no_col_mov
  1621.     inc ebx
  1622.     .no_col_mov:
  1623.  
  1624.     cmp edx,ted_tex_1
  1625.     jle @f
  1626.     cmp byte [edx],13
  1627.     jne @b
  1628.     inc eax
  1629.     jmp @b
  1630.   @@:
  1631.   dec ebx
  1632.   pop edx
  1633.   ret
  1634.  
  1635. ;input:
  1636. ; edi = pointer to tedit struct
  1637. ;output:
  1638. ; eax = num lines
  1639. align 4
  1640. GetNumLines:
  1641.   push edx
  1642.   mov eax,1
  1643.   mov edx,ted_tex
  1644.   @@:
  1645.     call IteratNext
  1646.     cmp edx,ted_tex_1
  1647.     jle @f
  1648.     cmp byte [edx],13
  1649.     jne @b
  1650.     inc eax
  1651.     jmp @b
  1652.   @@:
  1653. ;...
  1654. ;dec eax
  1655.   pop edx
  1656.   ret
  1657.  
  1658.  
  1659. align 4
  1660. proc ted_set_undo, edit:dword
  1661.   push edi
  1662.   mov edi,dword[edit]
  1663.  
  1664.   mov ted_drag_k,0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  1665.   cmp ted_tim_undo,1
  1666.   jl .no_work
  1667.  
  1668.   push eax ebx edx
  1669.   mov edx,ted_tex
  1670.   call GetTexNextPos ;long i=tex[0].next;
  1671.   mov eax,ted_tim_undo
  1672.   sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
  1673.   mov eax,ted_tim_ch
  1674.   cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
  1675.   jle @f
  1676.     mov ted_tim_ls,0
  1677.   @@:
  1678.     cmp edx,ted_tex
  1679.     je @f
  1680.  
  1681.     ;if(tex[i].tc>ted_tim_ch){ // åñëè ñîçäàíèå ñèìâîëà áûëî îòìåíåíî
  1682.     cmp [edx+10],eax
  1683.     jle .no_u1
  1684.       mov dword [edx+10],0
  1685.       mov dword [edx+14],0
  1686.  
  1687.       mov ebx,[edx+2]
  1688.       imul ebx,sizeof.symbol
  1689.       add ebx,ted_tex;.next
  1690.       m2m dword [ebx+6],dword [edx+6] ;tex[tex[i].perv].next=tex[i].next;
  1691.  
  1692.       mov ebx,[edx+6]
  1693.       imul ebx,sizeof.symbol
  1694.       add ebx,ted_tex;.perv
  1695.       m2m dword [ebx+2],dword [edx+2] ;tex[tex[i].next].perv=tex[i].perv;
  1696.  
  1697.     .no_u1:
  1698.  
  1699.     ;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // åñëè óäàëåíèå ñèìâîëà áûëî îòìåíåíî
  1700.     cmp [edx+14],eax
  1701.     jle .no_u2
  1702.       mov dword [edx+14],0
  1703.     .no_u2:
  1704.  
  1705.     call GetTexNextPos
  1706.     jmp @b
  1707.   @@:
  1708.   mov ted_tim_undo,0
  1709.   mov eax,ted_tim_co
  1710.   cmp ted_tim_ch,eax
  1711.   jge @f
  1712.     mov ted_tim_co,0
  1713.   @@:
  1714.   pop edx ebx eax
  1715.   .no_work:
  1716.   pop edi
  1717.   ret
  1718. endp
  1719.  
  1720. ;input:
  1721. ; ecx = Col
  1722. ; edx = Row
  1723. ; edi = pointer to tedit struct
  1724. align 4
  1725. GoToPos:
  1726.   mov ted_cur_x,ecx
  1727.   sub edx,[wScr.position]
  1728.  
  1729.   cmp edx,[wScr.cur_area] ;ted_cur_y > [.cur_area]
  1730.   jl @f
  1731.     push ebx
  1732.     mov ebx,edx
  1733.     sub ebx,[wScr.cur_area]
  1734.     inc ebx
  1735.     add [wScr.position],ebx
  1736.     sub edx,ebx
  1737.     pop ebx
  1738.     ; ??? redrav
  1739.   @@:
  1740.   mov ted_cur_y,edx
  1741.   ret
  1742.  
  1743. ;input:
  1744. ; edi = pointer to tedit struct
  1745. align 4
  1746. CmColored:
  1747.   push eax edx
  1748.   mov eax,ted_tim_ch
  1749.   sub eax,ted_tim_undo
  1750.   mov ted_tim_co,eax
  1751.   mov edx,ted_tex
  1752.   @@:
  1753.     call IteratNext
  1754.     cmp edx,ted_tex_1
  1755.     jle @f
  1756.     mov byte[edx+1],0
  1757.     jmp @b
  1758.   @@:
  1759.  
  1760.   cmp ted_key_words_count,1
  1761.   jl .no_colors
  1762.   mov edx,ted_tex
  1763.   @@:
  1764.     call TextFSColor
  1765.     cmp edx,ted_tex_1
  1766.     jle .no_colors
  1767.     jmp @b
  1768.   .no_colors:
  1769.   pop edx eax
  1770.   ret
  1771.  
  1772.  
  1773. ;input:
  1774. ; edx = pointer to start symbol
  1775. ; edi = pointer to tedit struct
  1776. ;output:
  1777. ; edx = pointer to next symbol
  1778. ;description:
  1779. ; Ôóíêöèÿ äëÿ ïîèñêà è âûäåëåíèÿ ïîäñâå÷åíûõ ñëîâ
  1780. align 4
  1781. proc TextFSColor
  1782. locals
  1783.   begPos dd ? ;íà÷àëüíàÿ ïîçèöèÿ
  1784.   endPos dd ? ;êîíå÷íàÿ ïîçèöèÿ
  1785.   find db ? ;íàéäåíî / íå íàéäåíî
  1786.   f_color db ? ;èíäåêñ öâåòà íàéäåíîãî ñëîâà
  1787. endl
  1788.   push eax ebx ecx esi
  1789. ;eax = word_n òåêóùèé íîìåð (ïîçèöèÿ) ïðîâåðÿåìîãî ñëîâà â ñïèñêå
  1790. ;ebx = äëÿ ðàçíûõ öåëåé
  1791. ;ecx = l_pos ïîñëåäíèé íîìåð (ïîçèöèÿ) ïîäõîäÿùåãî ñëîâà â ñïèñêå
  1792. ;esi = äëÿ ðàçíûõ öåëåé, íîìåð ïðîâåðÿåìîãî ñèìâîëà â ñëîâå
  1793.   mov dword[begPos],1
  1794.   mov dword[endPos],1
  1795.   mov byte[find],0
  1796.   mov byte[f_color],1
  1797.   @@:
  1798.     call IteratNext
  1799.     cmp edx,ted_tex_1
  1800.     jle @f
  1801.  
  1802.     xor eax,eax
  1803.     mov al,byte[edx]
  1804.     shl ax,2 ;eax*=4
  1805.     add eax,FkPos
  1806.     mov eax,dword[eax]
  1807.     cmp eax,0
  1808.     jl @b ;if( (word_n=FkPos[(unsigned char)tex[i].c])>-1 ){
  1809.  
  1810.     mov ecx,eax
  1811.     ;while(l_pos<ted_key_words_count && Col[l_pos].Text[0]==Col[word_n].Text[0])
  1812.     .wh_1b:
  1813.       cmp ecx,ted_key_words_count
  1814.       jge .wh_1e
  1815.       ColToIndexOffset ecx,esi
  1816.       mov bl,byte[esi]
  1817.       ColToIndexOffset eax,esi
  1818.       cmp bl,byte[esi]
  1819.       jne .wh_1e
  1820.         inc ecx
  1821.       jmp .wh_1b
  1822.     .wh_1e:
  1823.  
  1824.     mov dword[begPos],edx ;bP=i;
  1825.     mov esi,1
  1826.  
  1827.     .wh_2b: ;while(1){
  1828.       call IteratNext
  1829.  
  1830.       ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
  1831.       .wh_3b:
  1832.         cmp ecx,eax
  1833.         jle .wh_3e
  1834.         dec ecx
  1835.         ColToIndexOffset ecx,ebx
  1836.         inc ecx
  1837.         ;cmp byte[ebx+esi],byte[edx]
  1838.         mov bl,byte[ebx+esi]
  1839.         cmp bl,byte[edx]
  1840.         je .wh_3e
  1841.           dec ecx
  1842.         jmp .wh_3b
  1843.       .wh_3e:
  1844.  
  1845.       ColToIndexOffset eax,ebx
  1846.       cmp byte[ebx+esi],0
  1847.       jne .if_0 ;if(Col[word_n].Text[pos]==0){
  1848.         mov dword[endPos],edx ;eP=i;
  1849.         ColToIndexOffset eax,ebx
  1850.         mov bl,byte[ebx+MAX_COLOR_WORD_LEN+6]
  1851.         mov byte[f_color],bl ;f_color=Col[word_n].color;
  1852.  
  1853. mov byte[find],1
  1854.           ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
  1855.           mov bl,byte[ebx+MAX_COLOR_WORD_LEN+4]
  1856.           cmp bl,0 ;if(Col[word_n].wwo)
  1857.           je .if_2n
  1858.             push edx
  1859.             mov edx,dword[begPos]
  1860.      call IteratPerv
  1861.  
  1862.             btr bx,0 ;1-1
  1863.             jae .if_3e ;if(Col[word_n].wwo&1)
  1864.               ;u1= !(isalnum(cont_s)||cont_s=='_')
  1865.               call isalnum
  1866.               jae .if_3e
  1867.                 mov byte[find],0
  1868.             .if_3e:
  1869.  
  1870.             btr bx,3 ;4-1
  1871.             jae .if_4e ;if(Col[word_n].wwo&8)
  1872.               ;u1= !isalpha(cont_s);
  1873.               call isalpha
  1874.               jae .if_4e
  1875.                 mov byte[find],0
  1876.             .if_4e:
  1877.  
  1878.             mov edx,dword[endPos]
  1879. ;     call IteratNext
  1880.  
  1881.             btr bx,1 ;2-1
  1882.             jae .if_5e ;if(Col[word_n].wwo&2)
  1883.               ;u1= !(isalnum(cont_s)||cont_s=='_')
  1884.               call isalnum
  1885.               jae .if_5e
  1886.                 mov byte[find],0
  1887.             .if_5e:
  1888.  
  1889.             btr bx,4 ;5-1
  1890.             jae .if_6e ;if(Col[word_n].wwo&16)
  1891.               ;u1= !isalpha(cont_s);
  1892.               call isalpha
  1893.               jae .if_6e
  1894.                 mov byte[find],0
  1895.             .if_6e:
  1896.  
  1897.             btr bx,2 ;3-1
  1898.             jae .if_7e ;if(Col[word_n].wwo&4)
  1899.             ColToIndexOffset eax,ebx
  1900.             mov bl,byte[ebx+MAX_COLOR_WORD_LEN+5]
  1901.             call ItPoNextUc
  1902.        cmp edx,ted_tex_1
  1903.        jle .if_7e
  1904.        mov dword[endPos],edx
  1905.             .if_7e:
  1906.  
  1907.             pop edx
  1908.           .if_2n:
  1909. ;                 if(i!=1){ // íå êîíåö äîêóìåíòà
  1910. ;                   cont_s=tex[eP].c;
  1911. ;                   if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // íå áóêâ.-÷èñë. ñèìâîë
  1912. ;                   if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // íå ÷èñë. ñèìâîë
  1913. ;                   if(Col[word_n].wwo&4) eP=ItPoNextUc(eP,Col[word_n].endc);
  1914.  
  1915.         cmp eax,ecx
  1916.         je .wh_2e ;if(word_n==l_pos) break; // do double - åñëè ñëîâî òî÷íî ïîñëåäíåå
  1917.       .if_0:
  1918.  
  1919.       cmp edx,ted_tex_1
  1920.       jle .wh_2e ;if(i==1) break;
  1921.  
  1922.       ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
  1923.       .wh_4b:
  1924.         cmp ecx,eax
  1925.         jle .wh_4e
  1926.         ColToIndexOffset eax,ebx
  1927.         ;cmp byte[ebx+esi],byte[edx]
  1928.         mov bl,byte[ebx+esi]
  1929.         cmp bl,byte[edx]
  1930.         je .wh_4e
  1931.           inc eax
  1932.         jmp .wh_4b
  1933.       .wh_4e:
  1934.  
  1935.       cmp eax,ecx
  1936.       je .wh_2e;if(word_n==l_pos) break;
  1937.       inc esi ;pos++;
  1938.       jmp .wh_2b
  1939.     .wh_2e:
  1940.  
  1941.     cmp byte[find],1 ;if(fnd)break;
  1942.     je @f
  1943.     mov edx,dword[begPos];i=bP;
  1944.     jmp @b
  1945.   @@:
  1946.  
  1947.   cmp byte[find],1
  1948.   jne .if_1e ;if(fnd){ // âûäåëåíèå íàéäåíîãî òåêñòà
  1949. ;    if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
  1950.     mov eax,dword[begPos]
  1951.     mov bl,byte[f_color]
  1952.     mov byte[eax+1],bl ;tex[bP].col=f_color;
  1953.     mov eax,dword[endPos]
  1954.     mov byte[eax+1],0xff ;tex[eP].col=255;
  1955. ;    return ItPoPerv(eP); // âîçâðàùàåì ïîçèöèþ êîíöà âõîæäåíèÿ
  1956.     mov edx,dword[endPos]
  1957.     call GetTexPervPos
  1958.     jmp @f
  1959.   .if_1e:
  1960.     mov edx,ted_tex
  1961.   @@:
  1962.  
  1963.   pop esi ecx ebx eax
  1964.   ret
  1965. endp
  1966.  
  1967. ;input:
  1968. ; edx = pointer to char (byte)
  1969. ;output:
  1970. ; cf=1 if symbol is...
  1971. align 4
  1972. 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,0,0
  1973. 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
  1974.  
  1975. align 4
  1976. isalnum:
  1977.   push eax ebx
  1978.   mov al,byte[edx] ;al=offset
  1979.   shr al,3
  1980.   and eax,11111b
  1981.   mov ebx,tab_all_num
  1982.   add ebx,eax
  1983.   mov ah,byte[ebx]
  1984.   mov al,byte[edx] ;al=bit
  1985.   and ax,111b
  1986.   mov bx,word[ebx]
  1987.   btr bx,ax
  1988.   pop ebx eax
  1989.   ret
  1990. align 4
  1991. isalpha:
  1992.   push eax ebx
  1993.   mov al,byte[edx] ;al=offset
  1994.   shr al,3
  1995.   and eax,11111b
  1996.   mov ebx,tab_alpha
  1997.   add ebx,eax
  1998.   mov ah,byte[ebx]
  1999.   mov al,byte[edx] ;al=bit
  2000.   and ax,111b
  2001.   mov bx,word[ebx]
  2002.   btr bx,ax
  2003.   pop ebx eax
  2004.   ret
  2005.  
  2006. align 4
  2007. proc ted_show_help_f1, edit:dword
  2008.   push eax edx edi
  2009.   mov edi,dword[edit]
  2010.  
  2011.   call GetPos
  2012.   push edx
  2013.     call ItNextColorTag
  2014.     mov eax,edx
  2015.   pop edx
  2016.   call ItPervColorTag
  2017.  
  2018.   cmp eax,ted_tex
  2019.   jle @f
  2020.   cmp edx,ted_tex_1
  2021.   jle @f
  2022.     stdcall FindHelpId,eax
  2023.   @@:
  2024.   ;stdcall draw_main_cursor,edi
  2025.   stdcall draw_help_f1
  2026.   pop edi edx eax
  2027.   ret
  2028. endp
  2029.  
  2030. ;input:
  2031. ; edx = position begin 'symbol' struct
  2032. ; edi = pointer to tedit struct
  2033. ; end_pos = position end 'symbol' struct
  2034. align 4
  2035. proc FindHelpId, end_pos:dword
  2036. ; ecx = word_n
  2037. ; ebx = l_pos
  2038.   mov ted_help_id,-1
  2039.  
  2040.   push ebx ecx
  2041.     xor ebx,ebx
  2042.     mov bl,byte[edx]
  2043.     shl bx,2 ;ebx*=4
  2044.     add ebx,FkPos
  2045.     mov ecx,dword[ebx]
  2046.     cmp ecx,0
  2047.     jl .if_0e ;if( (word_n=FkPos[(unsigned char)tf[0]])>-1 ){
  2048.       push esi eax
  2049.       mov ebx,ecx ;l_pos=word_n;
  2050.       ColToIndexOffset ecx,esi
  2051.       push cx
  2052.       mov cl,byte[esi]
  2053.       @@:
  2054.         cmp ebx,ted_key_words_count ;while(l_pos<ted_key_words_count)
  2055.         jge @f
  2056.         ;ColToIndexOffset ecx,esi
  2057.         ColToIndexOffset ebx,eax
  2058.         cmp cl,byte[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
  2059.         jne @f
  2060.           inc ebx ;l_pos++;
  2061.           jmp @b
  2062.       @@:
  2063.       pop cx
  2064.       call IteratNext ;pos=1;
  2065.       mov esi,1
  2066.       @@:
  2067.         push dx
  2068.         push word[edx]
  2069.         pop dx
  2070.           .wh_0b:
  2071.             cmp ebx,ecx ;while(l_pos>word_n
  2072.             jle .wh_0e
  2073.             dec ebx
  2074.             ColToIndexOffset ebx,eax
  2075.             inc ebx
  2076.             cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
  2077.             je .wh_0e
  2078.               dec ebx ;l_pos--;
  2079.             jmp .wh_0b
  2080.           .wh_0e:
  2081.  
  2082.           .wh_1b:
  2083.             cmp ebx,ecx ;while(l_pos>word_n
  2084.             jle .wh_1e
  2085.             ColToIndexOffset ecx,eax
  2086.             cmp byte[eax+esi],dl
  2087.             je .wh_1e
  2088.               inc ecx ;word_n++;
  2089.             jmp .wh_1b
  2090.           .wh_1e:
  2091.         pop dx
  2092.  
  2093.         cmp ecx,ebx ;if(word_n==l_pos) break;
  2094.         je @f
  2095.         call IteratNext ;pos++;
  2096.         cmp edx,dword[end_pos] ;for(...;i<strlen;...)
  2097.         je @f ;jge
  2098.         inc esi
  2099.         jmp @b
  2100.       @@:
  2101.       pop eax esi
  2102.  
  2103.       mov ted_help_id,ecx
  2104.       ;return word_n;
  2105.  
  2106.     .if_0e:
  2107.   pop ecx ebx
  2108.   ret
  2109. endp
  2110.  
  2111. ;-----------------------------------------------------------------------------
  2112. ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè
  2113. ;input:
  2114. ; ecx = size data
  2115. ;otput:
  2116. ; eax = pointer to memory
  2117. align 4
  2118. mem_Alloc:
  2119.   push ebx
  2120.   mov eax,68
  2121.   mov ebx,12
  2122.   int 0x40
  2123.   pop ebx
  2124.   ret
  2125. ;-----------------------------------------------------------------------------
  2126. ;ôóíêöèÿ äëÿ îñâîáîæäåíèÿ ïàìÿòè
  2127. ;input:
  2128. ; ecx = pointer to memory
  2129. align 4
  2130. mem_Free:
  2131.   push eax ebx
  2132.   cmp ecx,0
  2133.   jz @f
  2134.     mov eax,68
  2135.     mov ebx,13
  2136.     int 0x40
  2137.   @@:
  2138.   pop ebx eax
  2139.   ret
  2140.