Subversion Repositories Kolibri OS

Rev

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

  1. ; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
  2. ; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
  3. ; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 09.06.2010 IgorA
  4. ; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
  5.  
  6. ;input:
  7. ; edi = pointer to tedit struct
  8. ; reg = index
  9. ;output:
  10. ; reg = pointer to 'tex' struct
  11. macro ConvertIndexToPointer reg {
  12.   imul reg,sizeof.symbol
  13.   add reg,ted_tex
  14. }
  15.  
  16. ;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
  17. macro ColToIndexOffset ind_reg,out_reg {
  18.         mov out_reg,ind_reg
  19.         imul out_reg,sizeof.TexColViv
  20.         add out_reg,ted_key_words_data
  21. }
  22.  
  23. macro use_text_edit
  24. {
  25. TED_PANEL_NULL   equ 0 ;­¥â ®âªàë⮩ ¯ ­¥«¨
  26. TED_PANEL_FIND   equ 1 ;¯ ­¥«ì ¯®¨áª 
  27. TED_PANEL_SYNTAX equ 2 ;¯ ­¥«ì ¢ë¡®à  ä ©«®¢ ¯®¤á¢¥âª¨
  28. TED_PANEL_WIDTH  equ 150 ;è¨à¨­  ¯ ­¥«¨
  29.  
  30. MAX_COLOR_WORD_LEN equ 40
  31. ;------------------------------------------------------------------------------
  32. struct TexSelect
  33.   x0 dd ?
  34.   y0 dd ?
  35.   x1 dd ?
  36.   y1 dd ?
  37. ends
  38.  
  39. struct TexColViv
  40.   Text rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨
  41.   f1 dd 0 ; á¯à ¢ª  ¯® á«®¢ã
  42.   wwo db ? ; whole words only
  43.   endc db ? ; ᨬ¢®« ª®­æ  ¢ë¤¥«¥­¨ï (wwo&4)
  44.   color db ? ; ­®¬¥à 梥â 
  45. ends
  46.  
  47. struct symbol
  48.   c db ?    ;  +0 ᨬ¢®«
  49.   col db ?  ;  +1 梥â
  50.   perv dd ? ;  +2
  51.   next dd ? ;  +6 㪠§ â¥«¨
  52.   tc dd ?   ; +10 ¢à¥¬. ᮧ¤ ­¨ï
  53.   td dd ?   ; +14 ¢à¥¬. 㤠«¥­¨ï
  54. ends
  55. ;------------------------------------------------------------------------------
  56.  
  57. ted_symbol_tab db 26 ;ascii ª®¤ áâ५ª¨ ¢¯à ¢®, ¨á¯®«ì§ã¥âáï ¤«ï à¨á®¢ ­¨ï â ¡ã«ï樨 ¢ ०¨¬¥ ¯®ª §  ­¥¢¨¤¨¬ëå ᨬ¢®«®¢
  58.  
  59. if lang eq ru
  60.  
  61. txtFindCapt db '®¨áª',0
  62. txtFindNext db ' ©â¨ ¤ «¥¥',0
  63. txtFormatCapt db '”®à¬ â',0
  64. txtFormatApply db 'à¨¬¥­¨âì',0
  65. txtRow db '‘âப ',0
  66. txtCol db '‡­ ª',0
  67. txtOtm db 'Žâ¬¥­ë',0
  68. txtBuf db 'ãä¥à:',0
  69.  
  70. else
  71.  
  72. txtFindCapt db 'Search',0
  73. txtFindNext db 'Find next',0
  74. txtFormatCapt db 'Format',0
  75. txtFormatApply db 'Apply',0
  76. txtRow db 'Rows',0
  77. txtCol db 'Cols',0
  78. txtOtm db 'Undo',0
  79. txtBuf db 'Buffer:',0
  80.  
  81. end if
  82.  
  83. ;EvChar - â ¡«¨æ  ¤«ï 䨫ìâ஢ ­¨ï ¤®¡ ¢«ï¥¬ëå ᨬ¢®«®¢, çâ®-¡ë ­¥ ¯®¯ «¨ «¨è­¨¥ §­ ª¨
  84. align 4
  85. EvChar db 0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
  86.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  87.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  88.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  89.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  90.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  91.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  92.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
  93.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  94.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  95.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  96.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  97.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  98.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  99.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  100.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  101. ;EvUpper - â ¡«¨æ  ¤«ï ¯à¥®¡à §®¢ ­¨ï ᨬ¢®«®¢ ª ¢¥àå­¥¬ã ॣ¨áâàã
  102. EvUpper db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  103.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  104.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  105.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  106.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  107.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  108.     db 0,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79
  109.     db 80,81,82,83,84,85,86,87,88,89,90,0,0,0,0,0
  110.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  111.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  112.     db 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143
  113.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  114.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  115.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  116.     db 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159
  117.     db 0,240,0,242,0,244,0,246,0,0,0,0,0,0,0,0
  118. ;EvLover - â ¡«¨æ  ¤«ï ¯à¥®¡à §®¢ ­¨ï ᨬ¢®«®¢ ª ­¨¦­¥¬ã ॣ¨áâàã
  119. EvLover db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  120.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  121.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  122.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  123.     db 0,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111
  124.     db 112,113,114,115,116,117,118,119,120,121,122,0,0,0,0,0
  125.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  126.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  127.     db 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  128.     db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  129.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  130.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  131.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  132.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  133.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  134.     db 241,0,243,0,245,0,247,0,0,0,0,0,0,0,0,0
  135. conv_table dd 0
  136.  
  137.  
  138. KM_SHIFT equ 0x00010000
  139. KM_CTRL equ 0x00020000
  140. KM_ALT equ 0x00040000
  141. KM_NUMLOCK equ 0x00080000
  142.  
  143. ; KEY CODES
  144. KEY_F1 equ 0x0000003B
  145. KEY_F2 equ 0x0000003C
  146. KEY_F3 equ 0x0000003D
  147.  
  148.  
  149.  
  150. align 4
  151. proc ted_init, edit:dword
  152.         push eax ecx edi
  153.         mov edi,dword[edit]
  154.  
  155.         mov ecx,sizeof.symbol
  156.         imul ecx,ted_max_chars
  157.         invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
  158.         mov ted_tex,eax
  159.         mov ted_tex_1,eax
  160.         add ted_tex_1,sizeof.symbol
  161.         add eax,ecx
  162.         mov ted_tex_end,eax
  163.  
  164.         stdcall ted_clear, edi,1
  165.  
  166. ;-------------------------------------------------
  167.         mov ecx,1024 ;1024 - ¤«ï ¬ áᨢ  ted_arr_key_pos
  168.         add ecx,ted_syntax_file_size
  169.         invoke mem.alloc,ecx
  170.         mov ted_arr_key_pos,eax
  171.         add eax,1024
  172.         mov ted_syntax_file,eax
  173.  
  174.         stdcall ted_init_scroll_bars,edi,3
  175.         pop edi ecx eax
  176.         ret
  177. endp
  178.  
  179. MIN_W_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï ¢¥àâ. áªà®««¨­£ 
  180. MIN_H_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï £®à¨§. áªà®««¨­£ 
  181. ;input:
  182. ; opt = 1 - ¬¥­ïâì 梥â áªà®««¨­£®¢, 2 - ¨§¬¥­¨«¨áì à §¬¥àë ®ª­ ,
  183. ;  4 - ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â 
  184. align 4
  185. proc ted_init_scroll_bars, edit:dword, opt:dword
  186.         pushad
  187.         mov edi,dword[edit]
  188.         mov esi,ted_scr_w
  189.         mov ebx,ted_scr_h
  190.         bt dword[opt],0
  191.         jae @f
  192.                 mov ecx,ted_color_wnd_work
  193.                 mov dword[esi+sb_offs_bckg_col],ecx
  194.                 mov dword[ebx+sb_offs_bckg_col],ecx
  195.                 mov ecx,ted_color_wnd_capt
  196.                 mov dword[esi+sb_offs_frnt_col],ecx
  197.                 mov dword[ebx+sb_offs_frnt_col],ecx
  198.                 mov ecx,ted_color_wnd_bord
  199.                 mov dword[esi+sb_offs_line_col],ecx
  200.                 mov dword[ebx+sb_offs_line_col],ecx
  201.         @@:
  202.         bt dword[opt],2 ; ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â  ?
  203.         jae .doc_resize
  204.                 call ted_get_num_lines
  205.                 cmp eax,100
  206.                 jge @f
  207.                         mov eax,100
  208.                 @@:
  209.                 mov dword[esi+sb_offs_max_area],eax
  210.         .doc_resize:
  211.         bt dword[opt],1 ; ¨§¬¥­¨«¨áì à §¬¥àë ®ª­  ?
  212.         jae .no_size
  213.                         mov edx,ted_wnd_l
  214.                         add edx,ted_rec_l
  215.                         mov word[ebx+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠£®à¨§. áªà®««¨­£ 
  216.                 mov eax,ted_wnd_h ;calculate lines in page
  217.                         mov edx,ted_wnd_t
  218.                         add edx,eax
  219.                         mov word[ebx+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠£®à¨§. áªà®««¨­£ 
  220.                 sub eax,ted_rec_t
  221.                 xor edx,edx
  222.                 mov ecx,ted_rec_h
  223.                 div ecx
  224.                 cmp eax,MIN_W_SCRL_ARE
  225.                 jg @f
  226.                         mov eax,MIN_W_SCRL_ARE
  227.                 @@:
  228.                 mov dword[esi+sb_offs_cur_area],eax
  229.  
  230.                 mov eax,ted_wnd_w ;calculate cols in page
  231.                         mov edx,ted_wnd_l ;«¥¢ë© ®âáâ㯠®ª­ 
  232.                         add edx,eax ;¤®¡ ¢«ï¥¬ è¨à¨­ã ®ª­ 
  233.                         mov word[esi+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
  234.                         mov edx,ted_wnd_t
  235.                         mov word[esi+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
  236.                         mov edx,ted_wnd_h
  237.                         mov word[esi+sb_offs_size_y],dx ;¢ëáâ ¢«ï¥¬ ¢ëá®âã ¢¥àâ. áªà®««¨­£ 
  238.                 sub eax,ted_rec_l
  239.                         mov word[ebx+sb_offs_size_x],ax ;¢ëáâ ¢«ï¥¬ è¨à¨­ã £®à¨§. áªà®««¨­£ 
  240.                 xor edx,edx
  241.                 mov ecx,ted_rec_w
  242.                 div ecx
  243.                 cmp eax,MIN_H_SCRL_ARE
  244.                 jg @f
  245.                         mov eax,MIN_H_SCRL_ARE
  246.                 @@:
  247.                 dec eax
  248.                 mov dword[ebx+sb_offs_cur_area],eax ;ãáâ ­ ¢«¨¢ ¥¬ ç¨á«® ᨬ¢®«®¢, ª®â®àë¥ ¢« §ïâ ¢ íªà ­ ¤«ï £®à¨§. áªà®««¨­£ 
  249.         .no_size:
  250.         popad
  251.         ret
  252. endp
  253.  
  254. align 4
  255. proc ted_delete, edit:dword
  256.         push edi
  257.         mov edi,dword[edit]
  258.         invoke mem.free,ted_tex
  259.         invoke mem.free,ted_arr_key_pos ;ted_syntax_file
  260.         pop edi
  261.         ret
  262. endp
  263.  
  264.  
  265. ;input:
  266. ; eax = key kodes
  267. align 4
  268. proc ted_key, edit:dword, table:dword, control:dword
  269.         pushad
  270.         mov edi,dword[edit]
  271.         mov esi,ted_el_focus
  272.         cmp dword[esi],edi
  273.         jne .end_key_fun ;í«¥¬¥­â ­¥ ¢ 䮪ãᥠ¢ë室¨¬ ¨§ ä㭪樨
  274.         mov esi,dword[control]
  275.  
  276.         cmp ah,KEY_F1 ;[F1]
  277.         jne @f
  278.                 stdcall ted_show_help_f1,edi
  279.                 jmp .end_key_fun
  280.         @@:
  281.         cmp ah,KEY_F3 ;[F3]
  282.         jne @f
  283.                 stdcall ted_but_find_next,edi
  284.                 jmp .end_key_fun
  285.         @@:
  286.  
  287.         test esi,KM_CTRL ;Ctrl+...
  288.         jz .key_Ctrl
  289.                 cmp ah,24 ;Ctrl+O
  290.                 jne @f
  291.                         cmp ted_fun_on_key_ctrl_o,0
  292.                         je @f
  293.                                 call ted_fun_on_key_ctrl_o
  294.                 @@:
  295.                 cmp ah,31 ;Ctrl+S
  296.                 jne @f
  297.                         cmp ted_fun_on_key_ctrl_s,0
  298.                         je @f
  299.                                 call ted_fun_on_key_ctrl_s
  300.                 @@:
  301.                 cmp ah,33 ;Ctrl+F
  302.                 jne @f
  303.                 cmp ted_panel_id,TED_PANEL_FIND
  304.                 je @f
  305.                         cmp ted_fun_on_key_ctrl_f,0
  306.                         je @f
  307.                                 call ted_fun_on_key_ctrl_f
  308.                 @@:
  309.                 cmp ah,44 ;Ctrl+Z
  310.                 jne @f
  311.                         stdcall ted_but_undo,edi
  312.                 @@:
  313.                 cmp ah,46 ;Ctrl+C
  314.                 jne @f
  315.                         stdcall ted_but_copy,edi
  316.                 @@:
  317.                 cmp ah,47 ;Ctrl+V
  318.                 jne @f
  319.                         stdcall ted_but_paste,edi
  320.                 @@:
  321.                 cmp ah,49 ;Ctrl+N
  322.                 jne @f
  323.                         cmp ted_fun_on_key_ctrl_n,0
  324.                         je @f
  325.                                 call ted_fun_on_key_ctrl_n
  326.                 @@:
  327.                 cmp ah,199 ;Ctrl+Home
  328.                 jne @f
  329.                         call ted_key_ctrl_home
  330.                 @@:
  331.                 jmp .end_key_fun
  332.         .key_Ctrl:
  333.  
  334.         test esi,KM_SHIFT ;Shift+...
  335.         jz .key_Shift
  336.                 cmp ah,72 ;Shift+Up
  337.                 jne @f
  338.                         call ted_sel_key_up
  339.                 @@:
  340.                 cmp ah,75 ;Shift+Left
  341.                 jne @f
  342.                         call ted_sel_key_left
  343.                 @@:
  344.                 cmp ah,77 ;Shift+Right
  345.                 jne @f
  346.                         call ted_sel_key_right
  347.                 @@:
  348.                 cmp ah,80 ;Shift+Down
  349.                 jne @f
  350.                         call ted_sel_key_down
  351.                 @@:
  352.                 ;mov ted_drag_k,1 ;­ ç¨­ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  353.                 jmp .key_MoveCur
  354.         .key_Shift:
  355. ;-------------------------------------------------
  356.         cmp ah,72 ;178 ;Up
  357.         jne @f
  358.                 call ted_draw_cursor_sumb
  359.                 call ted_cur_move_up
  360.                 cmp dl,8
  361.                 jne .no_red_0
  362.                         call ted_scroll_set_redraw
  363.                         stdcall ted_draw,edi
  364.                         jmp @f
  365.                 .no_red_0:
  366.                 call ted_draw_main_cursor
  367.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  368.         @@:
  369.         cmp ah,80 ;177 ;Down
  370.         jne @f
  371.                 call ted_draw_cursor_sumb
  372.                 call ted_cur_move_down
  373.                 cmp dl,8
  374.                 jne .no_red_1
  375.                         call ted_scroll_set_redraw
  376.                         stdcall ted_draw,edi
  377.                         jmp @f
  378.                 .no_red_1:
  379.                 call ted_draw_main_cursor
  380.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  381.         @@:
  382.   cmp ah,75 ;176 ;Left
  383.   jne @f
  384.     call ted_draw_cursor_sumb
  385.     call ted_cur_move_left
  386.     cmp dl,8
  387.     jne .no_red_2
  388.       call ted_scroll_set_redraw
  389.       stdcall ted_draw,edi
  390.       jmp @f
  391.     .no_red_2:
  392.     call ted_draw_main_cursor
  393.     mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  394.   @@:
  395.   cmp ah,77 ;179 ;Right
  396.   jne @f
  397.     call ted_draw_cursor_sumb
  398.     call ted_cur_move_right
  399.     cmp dl,8
  400.     jne .no_red_3
  401.       call ted_scroll_set_redraw
  402.       stdcall ted_draw,edi
  403.       jmp @f
  404.     .no_red_3:
  405.     call ted_draw_main_cursor
  406.     mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  407.   @@:
  408.   cmp ah,71 ;180 ;Home
  409.   jne @f
  410.     call ted_draw_cursor_sumb
  411.     call ted_cur_move_x_first_char
  412.     cmp dl,8
  413.     jne .no_red_4
  414.       call ted_scroll_set_redraw
  415.       stdcall ted_draw,edi
  416.       jmp @f
  417.     .no_red_4:
  418.     call ted_draw_main_cursor
  419.     mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  420.   @@:
  421.   cmp ah,79 ;181 ;End
  422.   jne @f
  423.     call ted_draw_cursor_sumb
  424.     call ted_cur_move_x_last_char
  425.     cmp dl,8
  426.     jne .no_red_5
  427.       call ted_scroll_set_redraw
  428.       stdcall ted_draw,edi
  429.       jmp @f
  430.     .no_red_5:
  431.     call ted_draw_main_cursor
  432.     mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  433.   @@:
  434.   cmp ah,73 ;184 ;PageUp
  435.   jne @f
  436.     call ted_cur_move_page_up
  437.     cmp dl,0
  438.     je @f
  439.     call ted_scroll_set_redraw
  440.     stdcall ted_draw,edi
  441.   @@:
  442.   cmp ah,81 ;183 ;PageDown
  443.   jne @f
  444.     call ted_cur_move_page_down
  445.     cmp dl,0
  446.     je @f
  447.     call ted_scroll_set_redraw
  448.     stdcall ted_draw,edi
  449.     mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  450.   @@:
  451. ;-------------------------------------------------
  452. ;       cmp esi,0
  453. ;       jne .end_key_fun
  454.         .key_MoveCur:
  455.  
  456.         cmp ah,69 ;[Pause Break]
  457.         je .end_key_fun
  458.         cmp ah,120 ;[Fn]
  459.         je .end_key_fun
  460.         cmp ah,0x80 ;if key up
  461.         ja .end_key_fun
  462.  
  463.         cmp dword[table],0
  464.         je @f
  465.                 stdcall KeyConvertToASCII, dword[table]
  466.         @@:
  467.  
  468.         ;mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  469.  
  470.         lea edx,[EvChar] ;¡¥à¥¬  ¤à¥á â ¡«¨æë á ¤®¯ãá⨬묨 ᨬ¢®« ¬¨
  471.         add dl,ah
  472.         jae @f
  473.                 add edx,0x100 ;¥á«¨ ¡ë«® ¯¥à¥¯®«­¥­¨¥ ¯à¨ ¤®¡ ¢«¥­¨¨ ª®¤  ᨬ¢®« 
  474.         @@:
  475.         cmp byte [edx],1
  476.         jne @f
  477.                 mov ted_key_new,ah
  478.                 call ted_set_undo
  479.                 mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  480.                 stdcall ted_sel_text_del,edx
  481.                 cmp al,1
  482.                 jne .del
  483.                         mov edx,ted_opt_ed_move_cursor
  484.                 .del:
  485.                 cmp ted_cur_ins,1
  486.                 je .no_ins_mod
  487.                         stdcall ted_text_del,edi,ted_opt_ed_change_time
  488.                         mov edx,ted_opt_ed_move_cursor
  489.                 .no_ins_mod:
  490.                 mov ecx,edi
  491.                 add ecx,ted_offs_key_new
  492.                 stdcall ted_text_add,edi,ecx,1,edx ;¤®¡ ¢«ï¥¬ ᨬ¢®« ¢¢¥¤¥­­ë© á ª« ¢¨ âãàë
  493.                 cmp ted_key_new,13
  494.                 jne .dr_m_win
  495.                         stdcall ted_draw,edi
  496.                         jmp .dr_cur_l
  497.                 .dr_m_win:
  498.                         stdcall ted_draw_cur_line,edi
  499.                 .dr_cur_l:
  500.                 cmp ted_fun_draw_panel_buttons,0
  501.                 je @f
  502.                         call ted_fun_draw_panel_buttons
  503.         @@:
  504.  
  505.         cmp ah,8 ;[<-]
  506.         jne @f
  507.                 call ted_set_undo
  508.                 stdcall ted_sel_text_del,ted_opt_ed_change_time
  509.                 cmp al,1
  510.                 je .del_one_b
  511.                         stdcall ted_text_del,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  512.                 .del_one_b:
  513.                 stdcall ted_draw,edi
  514.                 cmp ted_fun_draw_panel_buttons,0
  515.                 je .end_key_fun
  516.                         call ted_fun_draw_panel_buttons
  517.                 jmp .end_key_fun
  518.         @@:
  519.  
  520.         cmp ah,182 ;Delete
  521.         jne @f
  522.                 call ted_set_undo
  523.                 stdcall ted_sel_text_del,ted_opt_ed_change_time
  524.                 cmp al,1
  525.                 je .del_one_d
  526.                         stdcall ted_text_del,edi,ted_opt_ed_change_time
  527.                 .del_one_d:
  528.                 stdcall ted_draw,edi
  529.                 cmp ted_fun_draw_panel_buttons,0
  530.                 je .end_key_fun
  531.                         call ted_fun_draw_panel_buttons
  532.                 jmp .end_key_fun
  533.         @@:
  534.  
  535.         cmp ah,185 ;Ins
  536.         jne @f
  537.                 call ted_draw_cursor_sumb
  538.                 xor ted_cur_ins,1
  539.                 call ted_draw_main_cursor
  540.         @@:
  541.  
  542.         .end_key_fun:
  543.         popad
  544.         ret
  545. endp
  546.  
  547. ;output:
  548. ; al = 1 - can save
  549. align 4
  550. proc ted_can_save, edit:dword
  551.         push ecx edi
  552.         mov edi,dword[edit]
  553.  
  554.         mov ecx,ted_tim_ch
  555.         sub ecx,ted_tim_undo
  556.         mov al,1
  557.         cmp ted_tim_ls,ecx
  558.         jne @f
  559.                 dec al
  560.         @@:
  561.         pop edi ecx
  562.         ret
  563. endp
  564.  
  565. ;input:
  566. ; edi = pointer to tedit struct
  567. ;output:
  568. ; al = 1 - selected
  569. align 4
  570. proc ted_is_select
  571.   push ebx
  572.   xor al,al
  573.   cmp ted_drag_m,1
  574.   je @f
  575.     mov al,1
  576.     mov ebx,ted_sel_x0
  577.     cmp ebx,ted_sel_x1
  578.     jne @f
  579.     mov ebx,ted_sel_y0
  580.     cmp ebx,ted_sel_y1
  581.     jne @f
  582.     xor al,al
  583.   @@:
  584.   pop ebx
  585.   ret
  586. endp
  587.  
  588. ;input:
  589. ; edi = pointer to tedit struct
  590. align 4
  591. proc ted_sel_normalize
  592.         push ecx esi
  593.         push edi
  594.                 mov esi,edi
  595.                 add esi,ted_offs_sel
  596.                 add edi,ted_offs_seln
  597.                 mov ecx,sizeof.TexSelect
  598.                 rep movsb
  599.         pop edi
  600.  
  601.         jmp @f
  602.                 .swp_f:
  603.                 mov ecx,ted_seln_x0
  604.                 m2m ted_seln_x0,ted_seln_x1
  605.                 mov ted_seln_x1,ecx
  606.  
  607.                 mov ecx,ted_seln_y0
  608.                 cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
  609.                 jle .end_f
  610.                 m2m ted_seln_y0,ted_seln_y1
  611.                 mov ted_seln_y1,ecx
  612.  
  613.                 jmp .end_f
  614.         @@:
  615.  
  616.         mov ecx,ted_seln_y0
  617.         cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
  618.         jg .swp_f
  619.  
  620.         cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
  621.         jne .end_f
  622.                 mov ecx,ted_seln_x0
  623.                 cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
  624.                 jg .swp_f
  625.  
  626.         .end_f:
  627.         pop esi ecx
  628.         ret
  629. endp
  630.  
  631. ;input:
  632. ; edi = pointer to tedit struct
  633. ;description:
  634. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ­ ç «¥ ¢ë¤¥«¥­¨ï
  635. align 4
  636. proc ted_sel_start
  637.         push eax ecx
  638.                 mov eax,ted_scr_h
  639.                 mov ecx,ted_cur_x
  640.                 add ecx,dword[eax+sb_offs_position]
  641.                 mov ted_sel_x0,ecx
  642.                 mov ted_sel_x1,ecx
  643.  
  644.                 mov eax,ted_scr_w
  645.                 mov ecx,ted_cur_y
  646.                 add ecx,dword[eax+sb_offs_position]
  647.                 mov ted_sel_y0,ecx
  648.                 mov ted_sel_y1,ecx
  649.         pop ecx eax
  650.         ret
  651. endp
  652.  
  653. ;input:
  654. ; edi = pointer to tedit struct
  655. ;description:
  656. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¯¥à¥¬¥é¥­¨¨ ¢ë¤¥«¥­¨ï
  657. align 4
  658. proc ted_sel_move
  659.         push eax ecx
  660.                 mov ecx,ted_cur_x
  661.                 mov eax,ted_scr_h
  662.                 add ecx,dword[eax+sb_offs_position]
  663.                 mov ted_sel_x1,ecx
  664.  
  665.                 mov eax,ted_scr_w
  666.                 mov ecx,ted_cur_y
  667.                 add ecx,dword[eax+sb_offs_position]
  668.                 mov ted_sel_y1,ecx
  669.         pop ecx eax
  670.         cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
  671.         je @f
  672.                 call ted_fun_draw_panel_buttons
  673.         @@:
  674.         ret
  675. endp
  676.  
  677. ;input:
  678. ; cl_al_mem = 1 - clear all memory
  679. align 4
  680. proc ted_clear, edit:dword, cl_al_mem:dword
  681.         push ecx edi
  682.         mov edi,dword[edit]
  683.  
  684.         mov ted_cur_x,0
  685.         mov ted_cur_y,0
  686.         mov ted_tim_ch,0
  687.         mov ted_tim_ls,0
  688.         mov ted_tim_co,0
  689.         mov ted_tim_undo,0
  690.         mov ted_help_id,-1
  691.         mov ecx,sizeof.symbol
  692.         shl ecx,1
  693.         add ecx,ted_tex
  694.         mov ted_ptr_free_symb,ecx
  695.  
  696.         mov ecx,ted_scr_w
  697.         mov dword[ecx+sb_offs_position],0
  698.         mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® áâப ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
  699.         mov dword[ecx+sb_offs_redraw],1
  700.         mov ecx,ted_scr_h
  701.         mov dword[ecx+sb_offs_position],0
  702.         mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® ᨬ¢®«®¢ ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
  703.  
  704.         mov ted_sel_x0,0
  705.         mov ted_sel_y0,0
  706.         mov ted_sel_x1,0
  707.         mov ted_sel_y1,0
  708.  
  709.         cmp dword[cl_al_mem],0
  710.         je .exit
  711.  
  712.         push edx
  713.         mov ecx,sizeof.symbol
  714.         imul ecx,ted_max_chars
  715.         mov edx,ted_tex
  716.         @@:
  717.                 mov byte [edx],0
  718.                 inc edx
  719.         loop @b
  720.         mov edx,ted_tex
  721.         mov dword [edx+6],1
  722.         pop edx
  723.  
  724.         .exit:
  725.         pop edi ecx
  726.         ret
  727. endp
  728.  
  729.  
  730. align 4
  731. proc ted_init_syntax_file, edit:dword, file:dword, f_name:dword
  732.         pushad
  733.         mov edi,dword[edit]
  734.  
  735.         mov eax,70
  736.         mov ebx,dword[file]
  737.         mov dword[ebx], 0
  738.         mov dword[ebx+4], 0
  739.         mov dword[ebx+8], 0
  740.         mov ecx,ted_syntax_file_size
  741.         mov dword[ebx+12], ecx
  742.         m2m dword[ebx+16], ted_syntax_file
  743.         mov  byte[ebx+20], 0
  744.         m2m dword[ebx+21], dword[f_name]
  745.         int 0x40
  746.  
  747.         mov ecx,0x100
  748.         mov edx,ted_arr_key_pos
  749.         @@:
  750.                 mov dword[edx],-1
  751.                 add edx,4
  752.         loop @b
  753.  
  754.         ;init: ted_colors_text_count, ted_key_words_count, ...
  755.         mov ted_colors_text_count,1
  756.         mov ted_key_words_count,0
  757.         mov ted_help_text_f1,0
  758.         mov ted_help_id,-1 ;¨¤¥­â¨ä¨ª â®à á«®¢  ¤«ï á¯à ¢ª¨
  759.  
  760.         cmp eax,6
  761.         je @f
  762.         cmp eax,0
  763.         je @f
  764.                 cmp ax,10
  765.                 jl .zifra_0_9
  766.                         mov al,'?'
  767.                         sub ax,48
  768.                 .zifra_0_9:
  769.                 add ax,48
  770.                 cmp ted_fun_init_synt_err,0
  771.                 je .no_colors
  772.                         call ted_fun_init_synt_err
  773.                         jmp .no_colors
  774.         @@:
  775.  
  776.         mov eax,edi ;á®å࠭塞 §­ ç¥­¨¥ edi
  777.         mov esi,ted_syntax_file
  778.         add edi,ted_offs_count_colors
  779.         mov ecx,9*4
  780.         rep movsb
  781.         mov edi,eax ;¢®áâ ­ ¢«¨¢ ¥¬ §­ ç¥­¨¥ edi
  782.  
  783.         mov eax,ted_syntax_file
  784.         add eax,32
  785.         mov ted_text_colors,eax
  786.  
  787.         mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
  788.         add eax,8
  789.         shl eax,2
  790.         add eax,ted_syntax_file
  791.         mov ted_key_words_data,eax
  792.  
  793.         mov ecx,ted_key_words_count ;init: ted_arr_key_pos (first key positions)
  794.         xor eax,eax
  795.         @@:
  796.                 ColToIndexOffset eax,edx
  797.                 xor ebx,ebx
  798.                 mov bl,byte[edx]
  799.                 shl bx,2
  800.                 mov esi,ted_arr_key_pos
  801.                 add esi,ebx
  802.                 cmp dword[esi],-1
  803.                 jne .no_ch_key
  804.                         mov dword[esi],eax
  805.                 .no_ch_key:
  806.                 inc eax
  807.         loop @b
  808.  
  809.         ;init: ted_help_text_f1
  810.         mov ecx,ted_key_words_count
  811.         imul ecx,sizeof.TexColViv
  812.         add ecx,ted_key_words_data
  813.         mov ted_help_text_f1,ecx
  814.  
  815.         stdcall ted_init_scroll_bars,edi,1 ;¬¥­ï¥¬ æ¢¥â  áªà®««¨­£®¢
  816.         .no_colors:
  817.         popad
  818.         ret
  819. endp
  820.  
  821. ;input:
  822. ; ebx = file size
  823. ; edi = pointer to tedit struct
  824. ;description:
  825. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥âáï ¯à¨ ®âªàë⨨ ä ©« 
  826. align 4
  827. proc ted_on_open_file
  828.         push eax ;destination
  829.         push ecx ;for cycle
  830.         push edx ;source
  831.         push esi
  832.  
  833.         stdcall ted_clear,edi,0 ;ç¨á⨬ ­¥ ¢áî ¯ ¬ïâì, ¯®â®¬ã çâ® ­¨¦¥ ¡ã¤¥¬ ¥¥ § ¯®«­ïâì ­®¢ë¬¨ ¤ ­ë¬¨
  834.         mov eax,ebx
  835.         mov ecx,ebx
  836.         add eax,2
  837.         ConvertIndexToPointer eax
  838.         mov edx,ted_tex
  839.         add edx,ebx
  840.         push ebx
  841.         @@:
  842.                 mov ebx,[edx]
  843.                 mov byte [eax],bl
  844.                 mov dword [eax+2],ecx
  845.                 inc dword [eax+2]
  846.                 mov dword [eax+6],ecx
  847.                 add dword [eax+6],3
  848.                 ;mov byte[eax+1],0 ;col=0
  849.                 mov dword [eax+10],-1 ;tc=-1
  850.                 mov dword [eax+14],0 ;td=0
  851.  
  852.                 cmp ecx,0
  853.                 je @f
  854.                 dec ecx
  855.                 dec edx
  856.                 sub eax,sizeof.symbol
  857.                 jmp @b
  858.         @@:
  859.         pop ebx
  860.         add eax,2
  861.         mov dword [eax],0 ; first sumbol 'perv=0'
  862.  
  863.         mov edx,ted_tex
  864.         ; begining sumbol 'perv=0' 'next=2'
  865.         mov dword [edx+2],0
  866.         mov dword [edx+6],2
  867.  
  868.         add edx,sizeof.symbol
  869.         mov dword [edx+6],0 ; last sumbol 'next=0'
  870.         mov dword [edx+2],ebx ; last sumbol 'perv=last'
  871.         inc dword [edx+2]
  872.  
  873.         mov edx,ebx
  874.         inc edx ;2 = rezerv sumbols
  875.         imul edx,sizeof.symbol
  876.         add edx,ted_tex
  877.         mov dword [edx+6],1 ; last sumbol 'next=1'
  878.  
  879.         @@: ;clear memory, need if before was open big file
  880.                 add edx,sizeof.symbol
  881.                 cmp edx,ted_tex_end
  882.                 jge @f
  883.                         mov dword[edx+10],0
  884.                         mov dword[edx+14],0
  885.                 jmp @b
  886.         @@:
  887.  
  888.         call ted_get_num_lines
  889.         cmp eax,100
  890.         jge @f
  891.                 mov eax,100
  892.         @@:
  893.         mov esi,ted_scr_w
  894.         mov dword[esi+sb_offs_max_area],eax
  895.         pop esi edx ecx eax
  896.  
  897.         call ted_text_colored
  898.         stdcall ted_draw,edi
  899.         cmp ted_fun_draw_panel_buttons,0
  900.         je @f
  901.                 call ted_fun_draw_panel_buttons
  902.         @@:
  903.         ret
  904. endp
  905.  
  906. ;input:
  907. ; edx = pointer to symbol struct
  908. ; edi = pointer to tedit struct
  909. ;output:
  910. ; edx = pointer to 'perv' visible symbol struct
  911. align 4
  912. ted_iterat_perv:
  913.   cmp ted_tim_undo,0
  914.   je .else
  915.   push ebx
  916.   @@:
  917.     call ted_get_text_perv_pos
  918.     cmp edx,ted_tex
  919.     je @f
  920.     call ted_symbol_not_vis
  921.     cmp bl,1
  922.     je @b
  923.     cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  924.     je @b
  925.   @@:
  926.   pop ebx
  927.   ret
  928.   .else:
  929.     call ted_get_text_perv_pos
  930.     cmp edx,ted_tex
  931.     je .endif
  932.     cmp dword [edx+14],0
  933.     jne .else
  934.     cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  935.     je .else
  936.   .endif:
  937.   ret
  938.  
  939.  
  940. ;input:
  941. ; edx = pointer to symbol struct
  942. ; edi = pointer to tedit struct
  943. ;output:
  944. ; edx = pointer to 'next' visible symbol struct
  945. align 4
  946. ted_iterat_next:
  947.   cmp ted_tim_undo,0
  948.   je .else
  949.   push ebx
  950.   @@:
  951.     call ted_get_text_next_pos
  952.     cmp edx,ted_tex_1
  953.     jle @f
  954.     call ted_symbol_not_vis
  955.     cmp bl,1
  956.     je @b
  957.     cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  958.     je @b
  959.   @@:
  960.   pop ebx
  961.   ret
  962.   .else:
  963.     call ted_get_text_next_pos
  964.     cmp edx,ted_tex_1
  965.     jle .endif
  966.     cmp dword [edx+14],0
  967.     jne .else
  968.     cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  969.     je .else
  970.   .endif:
  971.   ret
  972.  
  973. ;input:
  974. ; bl = symbol end of select
  975. ; edx = pointer to symbol struct
  976. ; edi = pointer to tedit struct
  977. ;description:
  978. ; ­ ©â¨ á«¥¤ãîéãî ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
  979. align 4
  980. ted_iterat_next_pos_char:
  981.         @@:
  982.                 cmp bl,byte[edx]
  983.                 je @f
  984.                 cmp edx,ted_tex_1
  985.                 jle @f
  986.                         call ted_iterat_next
  987.                         jmp @b
  988.         @@:
  989.         call ted_iterat_next
  990.         ret
  991.  
  992. ;input:
  993. ; edx = pointer to symbol struct
  994. ; edi = pointer to tedit struct
  995. align 4
  996. ted_iterat_perv_color_tag:
  997.   @@:
  998.     cmp byte[edx+1],0
  999.     jne @f
  1000.     call ted_iterat_perv
  1001.     cmp edx,ted_tex_1
  1002.     jle @f
  1003.     jmp @b
  1004.   @@:
  1005.   ret
  1006.  
  1007. ;input:
  1008. ; edx = pointer to symbol struct
  1009. ; edi = pointer to tedit struct
  1010. align 4
  1011. ted_iterat_next_color_tag:
  1012.   @@:
  1013.     call ted_iterat_next
  1014.     cmp byte[edx+1],0
  1015.     jne @f
  1016.     cmp edx,ted_tex_1
  1017.     jle @f
  1018.     jmp @b
  1019.   @@:
  1020.   ;call ted_iterat_next
  1021.   ret
  1022.  
  1023. ;input:
  1024. ; edx = pointer to symbol struct
  1025. ; edi = pointer to tedit struct
  1026. ;output:
  1027. ; bl = 1 if sumbol not visible
  1028. ; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
  1029. align 4
  1030. ted_symbol_not_vis:
  1031.   push eax
  1032.  
  1033.   xor bl,bl
  1034.  
  1035.   cmp dword [edx+14],0
  1036.   je @f
  1037.   mov eax,[edx+14] ;eax=tex[i].td
  1038.   add eax,ted_tim_undo
  1039.   cmp eax,ted_tim_ch
  1040.   jg @f
  1041.     mov bl,1
  1042.     pop eax
  1043.     ret
  1044.   @@:
  1045.  
  1046.   mov eax,ted_tim_ch
  1047.   sub eax,ted_tim_undo
  1048.   cmp [edx+10],eax
  1049.   jle @f
  1050.     or bl,1
  1051.   @@:
  1052.  
  1053.   pop eax
  1054.   ret
  1055.  
  1056. ;input:
  1057. ; text:dword - pointer to text string
  1058. ; add_opt:dword - options
  1059. align 4
  1060. proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
  1061.         locals
  1062.                 new_spc dd ? ;count new spaces
  1063.                 new_lin dd ? ;count new lines
  1064.         endl
  1065. ;¨á¯®«ì§®¢ ­¨¥ ॣ¨áâ஢ ¢­ãâਠä㭪樨:
  1066. ;eax - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨ ⥪áâ 
  1067. ;ebx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤, ¤«¨­­  ¢áâ ¢«ï¥¬®£® ⥪áâ 
  1068. ;ecx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤
  1069. ;edx - 㪠§ â¥«ì ­  áâàãªâãàã ᨬ¢®« 
  1070.         pushad
  1071.         cmp dword[t_len],1 ;¯à®¢¥à塞 ¤«¨­­ã ¤®¡¢«ï¥¬®£® ⥪áâ 
  1072.         jl .no_add ;ª®£¤  ¤«¨­­  <1 ¯à룠¥¬ ­  ª®­¥æ ä㭪樨, ¢® ¨§¡¥¦ ­¨¥ £«îª®¢
  1073.  
  1074.         mov edi,dword[edit]
  1075.         mov esi,dword[text]
  1076.  
  1077.         call ted_get_pos_by_cursor
  1078.         call ted_get_text_perv_pos
  1079.         call ted_get_text_arr_index ;eax=po_t
  1080.  
  1081.         mov dword[new_spc],0
  1082.         cmp ted_gp_opt,2
  1083.         je @f
  1084.                 push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
  1085.                         mov eax,ted_scr_h
  1086.                         mov eax,dword[eax+sb_offs_position]
  1087.                         add eax,ted_cur_x ;eax - ­®¬¥à ᨬ¢®« 
  1088.                         mov dword[new_spc],eax
  1089.  
  1090.                         mov eax,ted_scr_w
  1091.                         mov eax,dword[eax+sb_offs_position]
  1092.                         add eax,ted_cur_y ;eax - ­®¬¥à áâப¨
  1093.                         call ted_strlen ;ebx = line len
  1094.                         sub dword[new_spc],ebx ;®â ¯®§¨æ¨¨ ªãàá®à  ®â­¨¬ ¥¬ ¤«¨­­ã áâப¨, 㧭 ¥¬ ª®««¨ç¥á⢮ ¤®¡ ¢«ï¥¬ëå ¯à®¡¥«®¢
  1095.                 pop eax
  1096.         @@:
  1097.  
  1098.         mov ebx,dword[t_len]
  1099.  
  1100.         mov dword[new_lin],0
  1101.         cmp ted_gp_opt,0
  1102.         jne @f
  1103.                 push eax
  1104.                         mov eax,ted_scr_w
  1105.                         mov eax,dword[eax+sb_offs_position]
  1106.                         add eax,ted_cur_y
  1107.                         inc eax
  1108.                         mov dword[new_lin],eax
  1109.  
  1110.                         call ted_get_num_lines
  1111.                         sub dword[new_lin],eax
  1112.                 pop eax
  1113.         @@:
  1114.  
  1115.         mov edx,ted_ptr_free_symb
  1116.         .beg_cycle: ;for(i=...;i<ted_max_chars;i++)
  1117.                 cmp dword [edx+10],0 ;if(!tex[i].tc && !tex[i].td)
  1118.                 jne .u1f
  1119.                 cmp dword [edx+14],0
  1120.                 jne .u1f
  1121.                         test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
  1122.                         jz .no_tim
  1123.                                 inc ted_tim_ch
  1124.                         .no_tim:
  1125.                         test dword[add_opt],ted_opt_ed_move_cursor
  1126.                         jz .no_cur_mov
  1127.                         cmp dword[new_lin],0 ;¥á«¨ ¥áâì ¤®¡ ¢®ç­ë¥ áâப¨, â® ªãàá®à ¥é¥ ­¥ ¤¢¨£ ¥¬
  1128.                         jg .no_cur_mov
  1129.                         cmp dword[new_spc],0 ;¥á«¨ ­¥â ¤®¡ ¢®ç­ëå ¯à®¡¥«®¢, â® ªãàá®à ⮦¥ ­¥ ¤¢¨£ ¥¬
  1130.                         jg .no_cur_mov
  1131.                                 inc ted_cur_x ;move cursor
  1132.                                 ;call ted_go_to_pos
  1133.                                 cmp byte [esi],13
  1134.                                 jne .no_cur_mov
  1135.                                         mov ted_cur_x,0
  1136.                                         inc ted_cur_y
  1137.                         .no_cur_mov:
  1138.  
  1139.                         mov ecx,ted_opt_ed_change_time
  1140.                         not ecx
  1141.                         and dword[add_opt],ecx ;n_tim=false;
  1142.  
  1143.                         mov cl,byte [esi] ;tex[i].c=ta[ns];
  1144.                         mov byte [edx],cl
  1145.                         m2m dword [edx+10],ted_tim_ch ;tex[i].tc=ted_tim_ch;
  1146.                         mov [edx+2],eax ;tex[i].perv=po_t;
  1147.  
  1148.                         mov ecx,eax
  1149.                         imul ecx,sizeof.symbol
  1150.                         add ecx,ted_tex ; *** ecx = tex[po_t] ***
  1151.                         add ecx,6   ; *** ecx = tex[po_t].next ***
  1152.                         m2m dword [edx+6],dword [ecx] ;tex[i].next=tex[po_t].next;
  1153.  
  1154.                         call ted_get_text_arr_index ;*** eax = i ***
  1155.                         mov [ecx],eax ;tex[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
  1156.                         mov ecx,[edx+6] ; *** ecx = tex[i].next ***
  1157.                         imul ecx,sizeof.symbol
  1158.                         add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
  1159.                         mov [ecx+2],eax ;tex[tex[i].next].perv=i;
  1160.  
  1161.                         cmp dword[new_lin],0 ;add lines or text
  1162.                         jle .spc_add
  1163.                                 dec dword[new_lin]
  1164.                                 mov byte [edx],13
  1165.                                 jmp .u1f
  1166.                         .spc_add:
  1167.                         cmp dword[new_spc],0 ;add spaces or text
  1168.                         jle .tex_add
  1169.                                 dec dword[new_spc]
  1170.                                 mov byte [edx],' '
  1171.                                 jmp .u1f
  1172.                         .tex_add:
  1173.                         inc esi
  1174.                         dec ebx
  1175.                 .u1f:
  1176.                 add edx,sizeof.symbol
  1177.                 cmp edx,ted_tex_end
  1178.                 jge @f ;out of memory
  1179.                 cmp ebx,0
  1180.                 jne .beg_cycle
  1181.                 mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
  1182.                 jmp .add_all
  1183.         @@:
  1184.         cmp ted_increase_size,0
  1185.         je .add_all
  1186.                 call ted_memory_increase
  1187.                 cmp ebx,0
  1188.                 jne .beg_cycle
  1189.         .add_all: ;¢á¥ ᨬ¢®«ë ¤®¡ ¢«¥­ë
  1190.  
  1191.         call ted_text_colored
  1192.         .no_add:
  1193.         popad
  1194.         ret
  1195. endp
  1196.  
  1197. ;input:
  1198. ;  edx = pointer to sumbol, when insert
  1199. ;  edi = pointer to tedit struct
  1200. ;output:
  1201. ;  edx = new pointer to sumbol, when insert
  1202. align 4
  1203. proc ted_memory_increase
  1204.         cmp ted_increase_size,0
  1205.         je @f
  1206.                 push eax ebx ecx
  1207.                 mov ecx,ted_increase_size
  1208.                 add ecx,ted_max_chars
  1209.                 mov ted_max_chars,ecx
  1210.                 imul ecx,sizeof.symbol
  1211.                 invoke mem.realloc, ted_tex,ecx
  1212.                 mov ebx,ted_tex
  1213.                 mov ted_tex,eax
  1214.                 mov ted_tex_1,eax
  1215.                 add ted_tex_1,sizeof.symbol
  1216.                         sub edx,ebx
  1217.                         add edx,eax
  1218.                         mov ted_ptr_free_symb,edx
  1219.                 add eax,ecx
  1220.                 mov ted_tex_end,eax
  1221.                 pop ecx ebx eax
  1222.         @@:
  1223.         ret
  1224. endp
  1225.  
  1226. ;input:
  1227. ;  ecx = position to free insert cell
  1228. ;  edx = pointer to sumbol, when insert
  1229. ;  esi = pointer to added symbol
  1230. ;  edi = pointer to tedit struct
  1231. ;output:
  1232. ;  ecx = position to inserted cell
  1233. align 4
  1234. ted_char_add:
  1235.  
  1236.   .loop_b:
  1237.     cmp ecx,ted_tex_end
  1238.     jge .end_f
  1239.     cmp dword[ecx+10],0
  1240.     jne @f
  1241.       cmp dword[ecx+14],0
  1242.       je .loop_e
  1243.     @@:
  1244.     add ecx,sizeof.symbol
  1245.     jmp .loop_b
  1246.   .loop_e:
  1247.  
  1248.   push eax ebx
  1249.   mov eax,ted_tim_ch
  1250.   mov dword[ecx+10],eax
  1251.   mov al,byte[esi]
  1252.   mov byte[ecx],al
  1253.  
  1254.   call ted_get_text_arr_index ; *** eax=pos ***
  1255.   mov [ecx+2],eax ;tex[i].perv=pos;
  1256.   m2m dword[ecx+6],dword[edx+6] ;tex[i].next=tex[pos].next;
  1257.  
  1258.   push edx
  1259.     mov edx,ecx
  1260.     call ted_get_text_arr_index ; *** eax=i ***
  1261.   pop edx
  1262.  
  1263.   mov [edx+6],eax ;tex[pos].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
  1264.   mov ebx,[ecx+6]
  1265.   ConvertIndexToPointer ebx
  1266.   mov [ebx+2],eax ;tex[tex[i].next].perv=i; // ...
  1267.   pop ebx eax
  1268.  
  1269.   .end_f:
  1270.   call ted_text_colored
  1271.   ret
  1272.  
  1273.  
  1274. ;input:
  1275. ; conv_table = pointert to convert table
  1276. ; edi = pointer to tedit struct
  1277. ;output:
  1278. ; esi = count converted symbols
  1279. ;description:
  1280. ; ”ã­ªæ¨ï ¨á¯®«ì§ã¥âáï ¤«ï ᬥ­ë ॣ¨áâà  ¢ë¡à ­­ëå ᨬ¢®«®¢
  1281. align 4
  1282. proc ted_convert_sel_text
  1283.   locals
  1284.     conv_cou dd ?
  1285.   endl
  1286.   mov dword[conv_cou],0
  1287.   pushad
  1288.  
  1289.   call ted_is_select
  1290.   cmp al,0
  1291.   je .end_f
  1292.     call ted_set_undo
  1293.     call ted_sel_normalize
  1294.  
  1295.     mov esi,ted_seln_x0
  1296.     mov ecx,ted_seln_y0
  1297.     call ted_get_pos_by_coords
  1298.     mov eax,edx
  1299.     mov esi,ted_seln_x1
  1300.     mov ecx,ted_seln_y1
  1301.     call ted_get_pos_by_coords
  1302.     ;call ted_get_text_perv_pos
  1303.     mov ebx,edx
  1304.  
  1305.     cmp eax,ebx
  1306.     je .end_f
  1307.  
  1308.     inc ted_tim_ch
  1309.     mov edx,eax ;i=p0;
  1310.     mov ecx,ted_ptr_free_symb
  1311.     @@:
  1312.       mov esi,[edx]
  1313.       and esi,0xff
  1314.       add esi,[conv_table] ;EvUpper
  1315.       cmp byte [esi],0
  1316.       je .no_change
  1317.         m2m dword [edx+14],ted_tim_ch
  1318.         call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos);
  1319.         call ted_get_text_next_pos ;go to added symbol
  1320.         inc dword[conv_cou]
  1321.       .no_change:
  1322.  
  1323.       call ted_iterat_next
  1324.       cmp edx,ted_tex
  1325.       je @f
  1326.       cmp edx,ebx
  1327.       je @f
  1328.  
  1329.       jmp @b
  1330.     @@:
  1331.     cmp dword[conv_cou],0
  1332.     jne @f
  1333.       dec ted_tim_ch
  1334.     @@:
  1335.   .end_f:
  1336.   popad
  1337.   mov esi,dword[conv_cou]
  1338.   ret
  1339. endp
  1340.  
  1341. ;output:
  1342. ; bl = 0 - no delete
  1343. ; bl = 1 - delete
  1344. align 4
  1345. proc ted_text_del, edit:dword, del_opt:dword
  1346.   push cx edx edi
  1347.   mov edi,dword[edit]
  1348.   mov ebx,dword[del_opt]
  1349.  
  1350.   xor cl,cl
  1351.   test ebx,ted_opt_ed_move_cursor
  1352.   jz @f
  1353.     call ted_cur_move_left
  1354.     cmp dl,0
  1355.     je .no_del
  1356.   @@:
  1357.   call ted_get_pos_by_cursor
  1358.   cmp ted_gp_opt,1
  1359.   je .no_del
  1360.     test ebx,ted_opt_ed_change_time
  1361.     jz @f
  1362.       inc ted_tim_ch
  1363.     @@:
  1364.     m2m dword [edx+14], ted_tim_ch
  1365.     mov cl,1
  1366.   .no_del:
  1367.   mov bl,cl
  1368.   pop edi edx cx
  1369.   ret
  1370. endp
  1371.  
  1372. ;input:
  1373. ; edi = pointer to tedit struct
  1374. ;output:
  1375. ; al = 1 if delete
  1376. ;description:
  1377. ; ”ã­ªæ¨ï 㤠«ï¥â ¢ë¤¥«¥­­ë© ⥪áâ
  1378. align 4
  1379. proc ted_sel_text_del, del_opt:dword
  1380.         push ebx ecx edx esi
  1381.  
  1382.         call ted_is_select
  1383.         cmp al,0
  1384.         je .end_f
  1385.  
  1386.                 call ted_sel_normalize
  1387.  
  1388.                 mov esi,ted_seln_x1
  1389.                 mov ecx,ted_seln_y1
  1390.                 call ted_get_pos_by_coords
  1391.                 mov ebx,edx
  1392.  
  1393.                 mov esi,ted_seln_x0
  1394.                 mov ecx,ted_seln_y0
  1395.                 call ted_get_pos_by_coords
  1396.  
  1397.                 test dword[del_opt],ted_opt_ed_change_time
  1398.                 jz @f
  1399.                         inc ted_tim_ch
  1400.                 @@:
  1401.                 cmp edx,ted_tex
  1402.                 je @f
  1403.                 cmp edx,ebx ;if(i==te)break;
  1404.                 je @f
  1405.                         m2m dword[edx+14],ted_tim_ch
  1406.                         mov esi,ted_opt_ed_change_time
  1407.                         not esi
  1408.                         and dword[del_opt],esi ;n_tim=false;
  1409.                         call ted_iterat_next
  1410.                         jmp @b
  1411.                 @@:
  1412.                 test dword[del_opt],ted_opt_ed_change_time
  1413.                 jz @f
  1414.                         dec ted_tim_ch
  1415.                         xor al,al
  1416.                 @@:
  1417.                 test dword[del_opt],ted_opt_ed_change_time
  1418.                 jnz @f
  1419.                         mov ecx,ted_seln_x0
  1420.                         mov edx,ted_seln_y0
  1421.                         call ted_go_to_pos
  1422.                         mov ted_sel_x0,0
  1423.                         mov ted_sel_y0,0
  1424.                         mov ted_sel_x1,0
  1425.                         mov ted_sel_y1,0
  1426.                 @@:
  1427.         .end_f:
  1428.         pop esi edx ecx ebx
  1429.         ret
  1430. endp
  1431.  
  1432.  
  1433. ;input:
  1434. ; eax = pointer to begin select
  1435. ; ebx = pointer to end select
  1436. ; edi = pointer to tedit struct
  1437. align 4
  1438. ted_revers:
  1439.   cmp eax,ebx
  1440.   jne @f
  1441.     ret
  1442.   @@:
  1443.  
  1444.   push ecx edx
  1445.  
  1446.   mov edx,ted_tex_1
  1447.   cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
  1448.   jne @f
  1449.     call ted_get_text_perv_pos
  1450.     mov ebx,edx
  1451.   @@:
  1452.  
  1453.   push esi
  1454.     mov edx,[eax+2] ; *** edx = tex[p0].perv ***
  1455.     ConvertIndexToPointer edx
  1456.     add edx,6
  1457.     mov ecx,[edx] ;tmp = tex[tex[p0].perv].next;
  1458.  
  1459.     mov esi,[ebx+6] ; *** esi = tex[p1].next ***
  1460.     ConvertIndexToPointer esi
  1461.     add esi,2
  1462.     m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv;
  1463.  
  1464.     mov [esi],ecx ;tex[tex[p1].next].perv = tmp;
  1465.   pop esi
  1466.  
  1467.   mov ecx,[eax+2] ;tmp = tex[p0].perv;
  1468.   m2m dword[eax+2],dword[ebx+6] ;tex[p0].perv = tex[p1].next;
  1469.   mov [ebx+6],ecx ;tex[p1].next = tmp;
  1470.  
  1471.   mov edx,eax ;i=p0;
  1472.   @@:
  1473.     mov ecx,[edx+6] ;tmp = tex[i].next;
  1474.     m2m dword[edx+6],dword[edx+2] ;tex[i].next = tex[i].perv;
  1475.     mov [edx+2],ecx ;tex[i].perv = tmp;
  1476.     cmp edx,ebx ;if(i==p1)break;
  1477.     je @f
  1478. ; ---
  1479. ;cmp edx,ted_tex
  1480. ;je @f
  1481. ; ---
  1482.     mov edx,ecx ;i = tmp;
  1483.     ConvertIndexToPointer edx
  1484.     jmp @b
  1485.   @@:
  1486.   pop edx ecx
  1487.   call ted_text_colored
  1488.   ret
  1489.  
  1490.  
  1491. ;input:
  1492. ; edi = pointer to tedit struct
  1493. ;output:
  1494. ; dl = 0 not move
  1495. ; dl = 2 if move up
  1496. ; dl = 8 if scroll move up
  1497. align 4
  1498. ted_cur_move_up:
  1499.   cmp ted_cur_y,0
  1500.   je @f
  1501.     dec ted_cur_y
  1502.     mov dl,2
  1503.     ret
  1504.   @@:
  1505.   push eax
  1506.   mov eax,ted_scr_w
  1507.   cmp dword[eax+sb_offs_position],0
  1508.   je @f
  1509.     dec dword[eax+sb_offs_position]
  1510.     mov dl,8
  1511.     jmp .ret_f
  1512.   @@:
  1513.   mov dl,0
  1514.   .ret_f:
  1515.   pop eax
  1516.   ret
  1517.  
  1518. ;input:
  1519. ; edi = pointer to tedit struct
  1520. ;output:
  1521. ; dl = 0 not move
  1522. ; dl = 2 if move down
  1523. ; dl = 8 if scroll move down
  1524. align 4
  1525. ted_cur_move_down:
  1526.   push eax ebx
  1527.   mov ebx,ted_scr_w
  1528.   mov dl,0
  1529.   mov eax,dword[ebx+sb_offs_cur_area]
  1530.   dec eax
  1531.   cmp ted_cur_y,eax
  1532.   jge @f
  1533.     inc ted_cur_y
  1534.     mov dl,2
  1535.     jmp .ret_f
  1536.   @@:
  1537.   mov eax,ted_cur_y
  1538.   add eax,dword[ebx+sb_offs_position]
  1539.   inc eax
  1540.   cmp dword[ebx+sb_offs_max_area],eax
  1541.   jle @f
  1542.     inc dword[ebx+sb_offs_position]
  1543.     mov dl,8
  1544.   @@:
  1545.   .ret_f:
  1546.   pop ebx eax
  1547.   ret
  1548.  
  1549.  
  1550. ;input:
  1551. ; edi = pointer to tedit struct
  1552. ;output:
  1553. ; dl = 0 not move
  1554. ; dl = 1 if move up
  1555. align 4
  1556. ted_cur_move_page_up:
  1557.   push eax ebx
  1558.   mov ebx,ted_scr_w
  1559.   mov eax,dword[ebx+sb_offs_cur_area]
  1560.   xor dl,dl
  1561.   cmp eax,dword[ebx+sb_offs_position]
  1562.   jg @f
  1563.     sub dword[ebx+sb_offs_position],eax
  1564.     mov dl,1
  1565.   @@:
  1566.   cmp dword[ebx+sb_offs_position],0
  1567.   je @f
  1568.   cmp dl,1
  1569.   je @f
  1570.     mov dword[ebx+sb_offs_position],0
  1571.     mov dl,1
  1572.   @@:
  1573.   pop ebx eax
  1574.   ret
  1575.  
  1576. ;input:
  1577. ; edi = pointer to tedit struct
  1578. align 4
  1579. ted_cur_move_page_down:
  1580.         push eax ebx ecx
  1581.         mov ecx,ted_scr_w
  1582.  
  1583.         xor dl,dl
  1584.         mov eax,dword[ecx+sb_offs_max_area]
  1585.         sub eax,dword[ecx+sb_offs_cur_area]
  1586.         cmp dword[ecx+sb_offs_position],eax
  1587.         jge @f
  1588.                 mov ebx,dword[ecx+sb_offs_cur_area]
  1589.                 add dword[ecx+sb_offs_position],ebx
  1590.                 mov dl,1
  1591.                 mov dword[ecx+sb_offs_redraw],1
  1592.                 cmp dword[ecx+sb_offs_position],eax
  1593.                 jle @f
  1594.                         mov dword[ecx+sb_offs_position],eax
  1595.         @@:
  1596.         pop ecx ebx eax
  1597.         ret
  1598.  
  1599. ;input:
  1600. ; edi = pointer to tedit struct
  1601. ;output:
  1602. ; dl = 0 not move
  1603. ; dl = 1 if move left
  1604. ; dl = 3 if move left and up
  1605. ; dl = 8 if scroll move up
  1606. align 4
  1607. ted_cur_move_left:
  1608.         cmp ted_cur_x,0
  1609.         je @f
  1610.                 dec ted_cur_x
  1611.                 mov dl,1
  1612.                 ret
  1613.         @@:
  1614.         push eax
  1615.         mov eax,ted_scr_h
  1616.         cmp dword[eax+sb_offs_position],0
  1617.         je @f
  1618.                 dec dword[eax+sb_offs_position]
  1619.                 mov dl,8
  1620.                 jmp .ret_f
  1621.         @@:
  1622.         cmp ted_cur_y,0
  1623.         jne @f
  1624.                 mov eax,ted_scr_w
  1625.                 mov dl,0
  1626.                 cmp dword[eax+sb_offs_position],0
  1627.                 je .ret_f
  1628.                         dec dword[eax+sb_offs_position]
  1629.                         call ted_scroll_set_redraw
  1630.                         call ted_cur_move_x_last_char
  1631.                         mov dl,8
  1632.                         jmp .ret_f
  1633.         @@:
  1634.         cmp ted_cur_y,0
  1635.         je @f
  1636.                 dec ted_cur_y
  1637.                 call ted_cur_move_x_last_char
  1638.                 cmp dl,8
  1639.                 je .ret_f
  1640.                 mov dl,3
  1641.                 jmp .ret_f
  1642.         @@:
  1643.         mov dl,0
  1644.         .ret_f:
  1645.         pop eax
  1646.         ret
  1647.  
  1648. ;input:
  1649. ; edi = pointer to tedit struct
  1650. align 4
  1651. ted_cur_move_right:
  1652.         push eax ebx
  1653.         mov eax,ted_scr_h
  1654.         xor dl,dl
  1655.         mov ebx,dword[eax+sb_offs_cur_area]
  1656.         cmp ted_cur_x,ebx
  1657.         jge @f
  1658.                 inc ted_cur_x
  1659.                 mov dl,1
  1660.                 jmp .ret_f
  1661.         @@:
  1662.                 inc dword[eax+sb_offs_position]
  1663.                 mov dl,8
  1664.         .ret_f:
  1665.         pop ebx eax
  1666.         ret
  1667.  
  1668. ;input:
  1669. ; edi = pointer to tedit struct
  1670. align 4
  1671. ted_cur_move_x_last_char:
  1672. ;[hScr.position]
  1673. ;[hScr.cur_area]
  1674. ;dl-???
  1675.   push eax ebx ecx
  1676.   mov eax,ted_cur_y
  1677.   mov ecx,ted_scr_w
  1678.   add eax,dword[ecx+sb_offs_position]
  1679.   call ted_strlen
  1680.   xor dl,dl
  1681.  
  1682.   mov ecx,ted_scr_h
  1683.   cmp ebx,dword[ecx+sb_offs_position]
  1684.   jge @f
  1685.     mov dl,8
  1686.     mov dword[ecx+sb_offs_position],ebx
  1687.   @@:
  1688.   sub ebx,dword[ecx+sb_offs_position]
  1689.  
  1690.   cmp ebx,dword[ecx+sb_offs_cur_area]
  1691.   jle @f ; b---[---]---e
  1692.     add dword[ecx+sb_offs_position],ebx
  1693.     mov ebx,dword[ecx+sb_offs_cur_area]
  1694.     sub dword[ecx+sb_offs_position],ebx
  1695.     mov dl,8
  1696.   @@:
  1697.   mov ted_cur_x,ebx
  1698.   pop ecx ebx eax
  1699.   ret
  1700.  
  1701. ;input:
  1702. ; edi = pointer to tedit struct
  1703. ;output:
  1704. ; dl = 0 not move
  1705. ; dl = 1 move cursor
  1706. ; dl = 8 move cursor and scroll
  1707. align 4
  1708. ted_cur_move_x_first_char:
  1709.         xor dl,dl
  1710.         cmp ted_cur_x,0
  1711.         je @f
  1712.                 mov ted_cur_x,0
  1713.                 mov dl,1
  1714.         @@:
  1715.         push eax
  1716.         mov eax,ted_scr_h
  1717.         cmp dword[eax+sb_offs_position],0
  1718.         je @f
  1719.                 mov dword[eax+sb_offs_position],0
  1720.                 mov dl,8
  1721.         @@:
  1722.         pop eax
  1723.         ret
  1724.  
  1725. ;input:
  1726. ; edx = pointer to symbol struct
  1727. ; edi = pointer to tedit struct
  1728. ;output:
  1729. ; eax = array index
  1730. align 4
  1731. ted_get_text_arr_index:
  1732.         push ecx edx
  1733.                 mov eax,edx
  1734.                 sub eax,ted_tex
  1735.                 xor edx,edx
  1736.                 mov ecx,sizeof.symbol
  1737.                 div ecx
  1738.         pop edx ecx
  1739.         ret
  1740.  
  1741. ;input:
  1742. ; edx = pointer to symbol struct
  1743. ; edi = pointer to tedit struct
  1744. ;output:
  1745. ; edx = pointer to 'perv' struct
  1746. align 4
  1747. ted_get_text_perv_pos:
  1748.         mov edx,dword[edx+2]
  1749.         imul edx,sizeof.symbol
  1750.         add edx,ted_tex
  1751.         ret
  1752.  
  1753. ;input:
  1754. ; edx = pointer to symbol struct
  1755. ;output:
  1756. ; edx = pointer to 'next' symbol struct
  1757. align 4
  1758. ted_get_text_next_pos:
  1759.         mov edx,dword[edx+6]
  1760.         imul edx,sizeof.symbol
  1761.         add edx,ted_tex
  1762.         ret
  1763.  
  1764. ;input:
  1765. ; edi = pointer to tedit struct
  1766. ;output:
  1767. ; edx = symbol under cursor
  1768. ; ted_gp_opt = 1,2
  1769. ; edx = tex[1].perv if error
  1770. ; ted_gp_opt = 0
  1771. align 4
  1772. ted_get_pos_by_cursor:
  1773.         push eax ecx esi
  1774.                 mov esi,ted_cur_x
  1775.                 mov eax,ted_scr_h
  1776.                 add esi,dword[eax+sb_offs_position]
  1777.                 mov ecx,ted_cur_y
  1778.                 mov eax,ted_scr_w
  1779.                 add ecx,dword[eax+sb_offs_position]
  1780.                 call ted_get_pos_by_coords
  1781.         pop esi ecx eax
  1782.         ret
  1783.  
  1784. ;input:
  1785. ; esi = XPos
  1786. ; ecx = YPos
  1787. ; edi = pointer to tedit struct
  1788. ;output:
  1789. ; edx = symbol under cursor
  1790. ; ted_gp_opt = 1 if found text line
  1791. ; ted_gp_opt = 2 if found text line and column
  1792. ; edx = tex[1] if error
  1793. ; ted_gp_opt = 0 if text no found
  1794. align 4
  1795. ted_get_pos_by_coords:
  1796.   push eax ;Row
  1797.   push ebx ;Col
  1798.  
  1799.   xor eax,eax
  1800.   xor ebx,ebx
  1801.   mov ted_gp_opt,0
  1802.   mov edx,ted_tex
  1803.   @@:
  1804.     call ted_iterat_next
  1805.     cmp edx,ted_tex_1
  1806.     jle @f
  1807.     cmp ebx,esi
  1808.     jne .u1_0 ;Col <> ted_cur_x
  1809.       mov ted_gp_opt,1
  1810.       cmp eax,ecx
  1811.       jge @f ; Row >= ted_cur_y
  1812.     .u1_0:
  1813.     mov ted_gp_opt,0
  1814.     inc ebx
  1815.     cmp byte [edx],13
  1816.     jne @b
  1817.     cmp eax,ecx
  1818.     jge @f ; Row >= ted_cur_y
  1819.     inc eax
  1820.     xor ebx,ebx
  1821.     jmp @b
  1822.   @@:
  1823.   cmp eax,ecx
  1824.   jne @f ; Row = ted_cur_y
  1825.     inc ted_gp_opt
  1826.   @@:
  1827.   cmp ted_gp_opt,0
  1828.   jne @f
  1829.     mov edx,ted_tex_1
  1830.     ;call ted_get_text_perv_pos
  1831.   @@:
  1832.   pop ebx eax
  1833.   ret
  1834.  
  1835.  
  1836. ;input:
  1837. ; eax = Row
  1838. ; edi = pointer to tedit struct
  1839. ;output:
  1840. ; ebx = str len
  1841. align 4
  1842. ted_strlen:
  1843.   push edx ecx
  1844.   ;ecx = Row, from cycle
  1845.  
  1846.   xor ebx,ebx
  1847.   xor ecx,ecx
  1848.   mov edx,ted_tex
  1849.   @@:
  1850.     call ted_iterat_next
  1851.     cmp edx,ted_tex_1
  1852.     jle @f
  1853.     inc ebx
  1854.     cmp byte [edx],13
  1855.     jne @b
  1856.     dec ebx ;lenght minus 1 sumbol to paragraph
  1857.     cmp eax,ecx
  1858.     je @f
  1859.     xor ebx,ebx
  1860.     inc ecx
  1861.     jmp @b
  1862.   @@:
  1863.  
  1864.   cmp eax,ecx
  1865.   je @f
  1866.     xor ebx,ebx
  1867.   @@:
  1868.  
  1869.   pop ecx edx
  1870.   ret
  1871.  
  1872.  
  1873. ;input:
  1874. ; edx = symbol position
  1875. ; edi = pointer to tedit struct
  1876. ;output:
  1877. ; eax = number of line
  1878. ; ebx = symbol position in line
  1879. align 4
  1880. ted_get_text_coords:
  1881.   push edx
  1882.   xor eax,eax
  1883.   xor ebx,ebx
  1884.   @@:
  1885.     call ted_iterat_perv
  1886.  
  1887.     cmp eax,0
  1888.     jne .no_col_mov
  1889.     inc ebx
  1890.     .no_col_mov:
  1891.  
  1892.     cmp edx,ted_tex_1
  1893.     jle @f
  1894.     cmp byte [edx],13
  1895.     jne @b
  1896.     inc eax
  1897.     jmp @b
  1898.   @@:
  1899.   dec ebx
  1900.   pop edx
  1901.   ret
  1902.  
  1903. ;input:
  1904. ; edi = pointer to tedit struct
  1905. ;output:
  1906. ; eax = num lines
  1907. align 4
  1908. ted_get_num_lines:
  1909.   push edx
  1910.   mov eax,1
  1911.   mov edx,ted_tex
  1912.   @@:
  1913.     call ted_iterat_next
  1914.     cmp edx,ted_tex_1
  1915.     jle @f
  1916.     cmp byte [edx],13
  1917.     jne @b
  1918.     inc eax
  1919.     jmp @b
  1920.   @@:
  1921. ;...
  1922. ;dec eax
  1923.   pop edx
  1924.   ret
  1925.  
  1926.  
  1927. ;input:
  1928. ; edi = pointer to tedit struct
  1929. ;description:
  1930. ; ®â¬¥­ï¥â ®â¬¥­¥­­ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥­¥­¨¥¬ ¤®ªã¬¥­â 
  1931. align 4
  1932. proc ted_set_undo
  1933.   mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  1934.   cmp ted_tim_undo,1
  1935.   jl .no_work
  1936.  
  1937.   push eax ebx edx
  1938.   mov edx,ted_tex
  1939.   call ted_get_text_next_pos ;long i=tex[0].next;
  1940.   mov eax,ted_tim_undo
  1941.   sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
  1942.   mov eax,ted_tim_ch
  1943.   cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
  1944.   jle @f
  1945.     mov ted_tim_ls,0
  1946.   @@:
  1947.     cmp edx,ted_tex
  1948.     je @f
  1949.  
  1950.     ;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  1951.     cmp [edx+10],eax
  1952.     jle .no_u1
  1953.       mov dword [edx+10],0
  1954.       mov dword [edx+14],0
  1955.  
  1956.       mov ebx,[edx+2]
  1957.       imul ebx,sizeof.symbol
  1958.       add ebx,ted_tex;.next
  1959.       m2m dword [ebx+6],dword [edx+6] ;tex[tex[i].perv].next=tex[i].next;
  1960.  
  1961.       mov ebx,[edx+6]
  1962.       imul ebx,sizeof.symbol
  1963.       add ebx,ted_tex;.perv
  1964.       m2m dword [ebx+2],dword [edx+2] ;tex[tex[i].next].perv=tex[i].perv;
  1965.  
  1966. cmp ted_ptr_free_symb,edx
  1967. jle .no_u1
  1968.   mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
  1969.     .no_u1:
  1970.  
  1971.     ;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  1972.     cmp [edx+14],eax
  1973.     jle .no_u2
  1974.       mov dword [edx+14],0
  1975.     .no_u2:
  1976.  
  1977.     call ted_get_text_next_pos
  1978.     jmp @b
  1979.   @@:
  1980.   mov ted_tim_undo,0
  1981.   mov eax,ted_tim_co
  1982.   cmp ted_tim_ch,eax
  1983.   jge @f
  1984.     mov ted_tim_co,0
  1985.   @@:
  1986.   pop edx ebx eax
  1987.   .no_work:
  1988.   ret
  1989. endp
  1990.  
  1991. ;input:
  1992. ; ecx = Col
  1993. ; edx = Row
  1994. ; edi = pointer to tedit struct
  1995. align 4
  1996. ted_go_to_pos:
  1997.         push eax
  1998.         mov eax,ted_scr_w
  1999.         mov ted_cur_x,ecx
  2000.         sub edx,dword[eax+sb_offs_position]
  2001.  
  2002.         cmp edx,dword[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
  2003.         jl @f
  2004.                 push ebx
  2005.                 mov ebx,edx
  2006.                 sub ebx,dword[eax+sb_offs_cur_area]
  2007.                 inc ebx
  2008.                 add dword[eax+sb_offs_position],ebx
  2009.                 sub edx,ebx
  2010.                 pop ebx
  2011.                 ; ??? redrav
  2012.         @@:
  2013.         mov ted_cur_y,edx
  2014.         pop eax
  2015.         ret
  2016.  
  2017. ;input:
  2018. ; edi = pointer to tedit struct
  2019. align 4
  2020. ted_text_colored:
  2021.   push eax edx
  2022.   mov eax,ted_tim_ch
  2023.   sub eax,ted_tim_undo
  2024.   mov ted_tim_co,eax
  2025.   mov edx,ted_tex
  2026.   @@:
  2027.     call ted_iterat_next
  2028.     cmp edx,ted_tex_1
  2029.     jle @f
  2030.     mov byte[edx+1],0
  2031.     jmp @b
  2032.   @@:
  2033.  
  2034.   cmp ted_key_words_count,1
  2035.   jl .no_colors
  2036.   mov edx,ted_tex
  2037.   @@:
  2038.     call ted_text_find_sel_color
  2039.     cmp edx,ted_tex_1
  2040.     jle .no_colors
  2041.     jmp @b
  2042.   .no_colors:
  2043.   pop edx eax
  2044.   ret
  2045.  
  2046.  
  2047. ;input:
  2048. ; edx = pointer to start symbol
  2049. ; edi = pointer to tedit struct
  2050. ;output:
  2051. ; edx = pointer to next symbol
  2052. ;description:
  2053. ; ”ã­ªæ¨ï ¤«ï ¯®¨áª  ¨ ¢ë¤¥«¥­¨ï ¯®¤á¢¥ç¥­ëå á«®¢
  2054. align 4
  2055. proc ted_text_find_sel_color
  2056. locals
  2057.   begPos dd ? ;­ ç «ì­ ï ¯®§¨æ¨ï
  2058.   endPos dd ? ;ª®­¥ç­ ï ¯®§¨æ¨ï
  2059.   find db ? ;­ ©¤¥­® / ­¥ ­ ©¤¥­®
  2060.   f_color db ? ;¨­¤¥ªá æ¢¥â  ­ ©¤¥­®£® á«®¢ 
  2061. endl
  2062.   push eax ebx ecx esi
  2063. ;eax = word_n ⥪ã騩 ­®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢  ¢ ᯨ᪥
  2064. ;ebx = ¤«ï à §­ëå 楫¥©
  2065. ;ecx = l_pos ¯®á«¥¤­¨© ­®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢  ¢ ᯨ᪥
  2066. ;esi = ¤«ï à §­ëå 楫¥©, ­®¬¥à ¯à®¢¥à塞®£® ᨬ¢®«  ¢ á«®¢¥
  2067.   mov dword[begPos],1
  2068.   mov dword[endPos],1
  2069.   mov byte[find],0
  2070.   mov byte[f_color],1
  2071.   @@:
  2072.     call ted_iterat_next
  2073.     cmp edx,ted_tex_1
  2074.     jle @f
  2075.  
  2076.     xor eax,eax
  2077.     mov al,byte[edx]
  2078.     shl ax,2 ;eax*=4
  2079.     add eax,ted_arr_key_pos
  2080.     mov eax,dword[eax]
  2081.     cmp eax,0
  2082.     jl @b ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
  2083.  
  2084.     mov ecx,eax
  2085.     ;while(l_pos<ted_key_words_count && Col[l_pos].Text[0]==Col[word_n].Text[0])
  2086.     .wh_1b:
  2087.       cmp ecx,ted_key_words_count
  2088.       jge .wh_1e
  2089.       ColToIndexOffset ecx,esi
  2090.       mov bl,byte[esi]
  2091.       ColToIndexOffset eax,esi
  2092.       cmp bl,byte[esi]
  2093.       jne .wh_1e
  2094.         inc ecx
  2095.       jmp .wh_1b
  2096.     .wh_1e:
  2097.  
  2098.     mov dword[begPos],edx ;bP=i;
  2099.     mov esi,1
  2100.  
  2101.     .wh_2b: ;while(1){
  2102.       call ted_iterat_next
  2103.  
  2104.       ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
  2105.       .wh_3b:
  2106.         cmp ecx,eax
  2107.         jle .wh_3e
  2108.         dec ecx
  2109.         ColToIndexOffset ecx,ebx
  2110.         inc ecx
  2111.         ;cmp byte[ebx+esi],byte[edx]
  2112.         mov bl,byte[ebx+esi]
  2113.         cmp bl,byte[edx]
  2114.         je .wh_3e
  2115.           dec ecx
  2116.         jmp .wh_3b
  2117.       .wh_3e:
  2118.  
  2119.       ColToIndexOffset eax,ebx
  2120.       cmp byte[ebx+esi],0
  2121.       jne .if_0 ;if(Col[word_n].Text[pos]==0){
  2122.         mov dword[endPos],edx ;eP=i;
  2123.         ColToIndexOffset eax,ebx
  2124.         mov bl,byte[ebx+MAX_COLOR_WORD_LEN+6]
  2125.         mov byte[f_color],bl ;f_color=Col[word_n].color;
  2126.  
  2127. mov byte[find],1
  2128.           ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
  2129.           mov bl,byte[ebx+MAX_COLOR_WORD_LEN+4]
  2130.           cmp bl,0 ;if(Col[word_n].wwo)
  2131.           je .if_2n
  2132.             push edx
  2133.             mov edx,dword[begPos]
  2134.      call ted_iterat_perv
  2135.  
  2136.             btr bx,0 ;1-1
  2137.             jae .if_3e ;if(Col[word_n].wwo&1)
  2138.               ;u1= !(isalnum(cont_s)||cont_s=='_')
  2139.               call isalnum
  2140.               jae .if_3e
  2141.                 mov byte[find],0
  2142.             .if_3e:
  2143.  
  2144.             btr bx,3 ;4-1
  2145.             jae .if_4e ;if(Col[word_n].wwo&8)
  2146.               ;u1= !isalpha(cont_s);
  2147.               call isalpha
  2148.               jae .if_4e
  2149.                 mov byte[find],0
  2150.             .if_4e:
  2151.  
  2152.             mov edx,dword[endPos]
  2153. ;     call ted_iterat_next
  2154.  
  2155.             btr bx,1 ;2-1
  2156.             jae .if_5e ;if(Col[word_n].wwo&2)
  2157.               ;u1= !(isalnum(cont_s)||cont_s=='_')
  2158.               call isalnum
  2159.               jae .if_5e
  2160.                 mov byte[find],0
  2161.             .if_5e:
  2162.  
  2163.             btr bx,4 ;5-1
  2164.             jae .if_6e ;if(Col[word_n].wwo&16)
  2165.               ;u1= !isalpha(cont_s);
  2166.               call isalpha
  2167.               jae .if_6e
  2168.                 mov byte[find],0
  2169.             .if_6e:
  2170.  
  2171.             btr bx,2 ;3-1
  2172.             jae .if_7e ;if(Col[word_n].wwo&4)
  2173.             ColToIndexOffset eax,ebx
  2174.             mov bl,byte[ebx+MAX_COLOR_WORD_LEN+5]
  2175.             call ted_iterat_next_pos_char
  2176.        cmp edx,ted_tex_1
  2177.        jle .if_7e
  2178.        mov dword[endPos],edx
  2179.             .if_7e:
  2180.  
  2181.             pop edx
  2182.           .if_2n:
  2183. ;                 if(i!=1){ // ­¥ ª®­¥æ ¤®ªã¬¥­â 
  2184. ;                   cont_s=tex[eP].c;
  2185. ;                   if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // ­¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
  2186. ;                   if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ­¥ ç¨á«. ᨬ¢®«
  2187. ;                   if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
  2188.  
  2189.         cmp eax,ecx
  2190.         je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç­® ¯®á«¥¤­¥¥
  2191.       .if_0:
  2192.  
  2193.       cmp edx,ted_tex_1
  2194.       jle .wh_2e ;if(i==1) break;
  2195.  
  2196.       ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
  2197.       .wh_4b:
  2198.         cmp ecx,eax
  2199.         jle .wh_4e
  2200.         ColToIndexOffset eax,ebx
  2201.         ;cmp byte[ebx+esi],byte[edx]
  2202.         mov bl,byte[ebx+esi]
  2203.         cmp bl,byte[edx]
  2204.         je .wh_4e
  2205.           inc eax
  2206.         jmp .wh_4b
  2207.       .wh_4e:
  2208.  
  2209.       cmp eax,ecx
  2210.       je .wh_2e;if(word_n==l_pos) break;
  2211.       inc esi ;pos++;
  2212.       jmp .wh_2b
  2213.     .wh_2e:
  2214.  
  2215.     cmp byte[find],1 ;if(fnd)break;
  2216.     je @f
  2217.     mov edx,dword[begPos];i=bP;
  2218.     jmp @b
  2219.   @@:
  2220.  
  2221.   cmp byte[find],1
  2222.   jne .if_1e ;if(fnd){ // ¢ë¤¥«¥­¨¥ ­ ©¤¥­®£® ⥪áâ 
  2223. ;    if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
  2224.     mov eax,dword[begPos]
  2225.     mov bl,byte[f_color]
  2226.     mov byte[eax+1],bl ;tex[bP].col=f_color;
  2227.     mov eax,dword[endPos]
  2228.     mov byte[eax+1],0xff ;tex[eP].col=255;
  2229. ;    return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®­æ  ¢å®¦¤¥­¨ï
  2230.     mov edx,dword[endPos]
  2231.     call ted_get_text_perv_pos
  2232.     jmp @f
  2233.   .if_1e:
  2234.     mov edx,ted_tex
  2235.   @@:
  2236.  
  2237.   pop esi ecx ebx eax
  2238.   ret
  2239. endp
  2240.  
  2241. ;input:
  2242. ; edx = pointer to char (byte)
  2243. ;output:
  2244. ; cf=1 if symbol is...
  2245. align 4
  2246. 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
  2247. 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
  2248.  
  2249. align 4
  2250. isalnum:
  2251.   push eax ebx
  2252.   mov al,byte[edx] ;al=offset
  2253.   shr al,3
  2254.   and eax,11111b
  2255.   lea ebx,[tab_all_num]
  2256.   add ebx,eax
  2257.   mov ah,byte[ebx]
  2258.   mov al,byte[edx] ;al=bit
  2259.   and ax,111b
  2260.   mov bx,word[ebx]
  2261.   btr bx,ax
  2262.   pop ebx eax
  2263.   ret
  2264. align 4
  2265. isalpha:
  2266.   push eax ebx
  2267.   mov al,byte[edx] ;al=offset
  2268.   shr al,3
  2269.   and eax,11111b
  2270.   lea ebx,[tab_alpha]
  2271.   add ebx,eax
  2272.   mov ah,byte[ebx]
  2273.   mov al,byte[edx] ;al=bit
  2274.   and ax,111b
  2275.   mov bx,word[ebx]
  2276.   btr bx,ax
  2277.   pop ebx eax
  2278.   ret
  2279.  
  2280. align 4
  2281. proc ted_show_help_f1, edit:dword
  2282.   push eax edx edi
  2283.   mov edi,dword[edit]
  2284.  
  2285.   call ted_get_pos_by_cursor
  2286.   push edx
  2287.     call ted_iterat_next_color_tag
  2288.     mov eax,edx
  2289.   pop edx
  2290.   call ted_iterat_perv_color_tag
  2291.  
  2292.   cmp eax,ted_tex
  2293.   jle @f
  2294.   cmp edx,ted_tex_1
  2295.   jle @f
  2296.     stdcall ted_find_help_id,eax
  2297.   @@:
  2298.   ;call ted_draw_main_cursor
  2299.   call ted_draw_help_f1
  2300.   pop edi edx eax
  2301.   ret
  2302. endp
  2303.  
  2304. ;input:
  2305. ; edx = position begin 'symbol' struct
  2306. ; edi = pointer to tedit struct
  2307. ; end_pos = position end 'symbol' struct
  2308. align 4
  2309. proc ted_find_help_id, end_pos:dword
  2310. ; ecx = word_n
  2311. ; ebx = l_pos
  2312.   mov ted_help_id,-1
  2313.  
  2314.   push ebx ecx
  2315.     xor ebx,ebx
  2316.     mov bl,byte[edx]
  2317.     shl bx,2 ;ebx*=4
  2318.     add ebx,ted_arr_key_pos
  2319.     mov ecx,dword[ebx]
  2320.     cmp ecx,0
  2321.     jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
  2322.       push esi eax
  2323.       mov ebx,ecx ;l_pos=word_n;
  2324.       ColToIndexOffset ecx,esi
  2325.       push cx
  2326.       mov cl,byte[esi]
  2327.       @@:
  2328.         cmp ebx,ted_key_words_count ;while(l_pos<ted_key_words_count)
  2329.         jge @f
  2330.         ;ColToIndexOffset ecx,esi
  2331.         ColToIndexOffset ebx,eax
  2332.         cmp cl,byte[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
  2333.         jne @f
  2334.           inc ebx ;l_pos++;
  2335.           jmp @b
  2336.       @@:
  2337.       pop cx
  2338.       call ted_iterat_next ;pos=1;
  2339.       mov esi,1
  2340.       @@:
  2341.         push dx
  2342.         push word[edx]
  2343.         pop dx
  2344.           .wh_0b:
  2345.             cmp ebx,ecx ;while(l_pos>word_n
  2346.             jle .wh_0e
  2347.             dec ebx
  2348.             ColToIndexOffset ebx,eax
  2349.             inc ebx
  2350.             cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
  2351.             je .wh_0e
  2352.               dec ebx ;l_pos--;
  2353.             jmp .wh_0b
  2354.           .wh_0e:
  2355.  
  2356.           .wh_1b:
  2357.             cmp ebx,ecx ;while(l_pos>word_n
  2358.             jle .wh_1e
  2359.             ColToIndexOffset ecx,eax
  2360.             cmp byte[eax+esi],dl
  2361.             je .wh_1e
  2362.               inc ecx ;word_n++;
  2363.             jmp .wh_1b
  2364.           .wh_1e:
  2365.         pop dx
  2366.  
  2367.         cmp ecx,ebx ;if(word_n==l_pos) break;
  2368.         je @f
  2369.         call ted_iterat_next ;pos++;
  2370.         cmp edx,dword[end_pos] ;for(...;i<strlen;...)
  2371.         je @f ;jge
  2372.         inc esi
  2373.         jmp @b
  2374.       @@:
  2375.       pop eax esi
  2376.  
  2377.       mov ted_help_id,ecx
  2378.       ;return word_n;
  2379.  
  2380.     .if_0e:
  2381.   pop ecx ebx
  2382.   ret
  2383. endp
  2384.  
  2385. ;output:
  2386. ; eax = ª®¤ ®è¨¡ª¨
  2387. ; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
  2388. align 4
  2389. proc ted_open_file, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
  2390.         push edi
  2391.         mov edi,dword[edit]
  2392.  
  2393.         mov eax,70
  2394.         mov ebx,dword[file]
  2395.         mov dword[ebx], 0
  2396.         mov dword[ebx+4], 0
  2397.         mov dword[ebx+8], 0
  2398.         m2m dword[ebx+12], ted_max_chars ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©« 
  2399.         m2m dword[ebx+16], ted_tex
  2400.         mov  byte[ebx+20], 0
  2401.         push dword[f_name]
  2402.         pop dword[ebx+21]
  2403.         int 0x40
  2404.  
  2405.         cmp eax,0
  2406.         je @f
  2407.         cmp eax,6
  2408.         je @f
  2409.                 jmp .ret_f
  2410.         @@:
  2411.         cmp ebx,-1
  2412.         je .ret_f
  2413.                 ;if open file
  2414.                 call ted_on_open_file
  2415.         .ret_f:
  2416.         pop edi
  2417.         ret
  2418. endp
  2419.  
  2420. align 4
  2421. proc ted_but_select_word, edit:dword
  2422.         pushad
  2423.         mov edi,dword[edit]
  2424.  
  2425.         call ted_get_pos_by_cursor
  2426.         push edx
  2427.                 call ted_iterat_perv_color_tag
  2428.                 cmp edx,ted_tex_1
  2429.                 jle @f
  2430.                         call ted_get_text_coords
  2431.                         mov ted_sel_x0,ebx
  2432.                         mov ted_sel_y0,eax
  2433.                 @@:
  2434.         pop edx
  2435.         call ted_iterat_next_color_tag
  2436.         cmp edx,ted_tex_1
  2437.         jle @f
  2438.                 call ted_get_text_coords
  2439.                 mov ted_sel_x1,ebx
  2440.                 mov ted_sel_y1,eax
  2441.         @@:
  2442.  
  2443.         cmp ted_fun_draw_panel_buttons,0
  2444.         je @f
  2445.                 call ted_fun_draw_panel_buttons
  2446.         @@:
  2447.         stdcall ted_draw,edi
  2448.         popad
  2449.         ret
  2450. endp
  2451.  
  2452. align 4
  2453. proc ted_but_cut, edit:dword
  2454.         push edi
  2455.         mov edi,dword[edit]
  2456.  
  2457.         stdcall ted_but_copy,edi
  2458.         call ted_set_undo
  2459.         stdcall ted_sel_text_del,ted_opt_ed_change_time
  2460.  
  2461.         cmp al,1
  2462.         jne @f
  2463.                 stdcall ted_draw,edi
  2464.                 cmp ted_fun_draw_panel_buttons,0
  2465.                 je @f
  2466.                         call ted_fun_draw_panel_buttons
  2467.         @@:
  2468.         pop edi
  2469.         ret
  2470. endp
  2471.  
  2472. ;output:
  2473. ; al = 1 if copy text
  2474. align 4
  2475. proc ted_but_copy, edit:dword
  2476.         pushad
  2477.         mov edi,dword[edit]
  2478.  
  2479.         call ted_is_select
  2480.         cmp al,0
  2481.         je .end_f ;if not selected text
  2482.         call ted_sel_normalize
  2483.  
  2484.         mov esi,ted_seln_x1
  2485.         mov ecx,ted_seln_y1
  2486.         call ted_get_pos_by_coords
  2487.         mov ebx,edx
  2488.         mov esi,ted_seln_x0
  2489.         mov ecx,ted_seln_y0
  2490.         call ted_get_pos_by_coords
  2491.         mov esi,ebx
  2492.  
  2493.         xor ecx,ecx
  2494.         mov ebx,ted_buffer
  2495.         ;mov edx,ted_tex
  2496.         @@:
  2497.                 cmp edx,ted_tex_1 ;end of file
  2498.                 jle @f
  2499.                 cmp edx,esi ;end of select
  2500.                 je @f
  2501.                 inc ecx
  2502.                 cmp ecx,ted_buffer_size ;owerflow bufer
  2503.                 je @f
  2504.  
  2505.                 mov al,byte[edx]
  2506.                 mov byte[ebx],al
  2507.                 inc ebx
  2508.  
  2509.                 call ted_iterat_next
  2510.                 jmp @b
  2511.         @@:
  2512.         add ecx,ted_buffer
  2513.         mov byte[ebx],0
  2514.  
  2515.         cmp ecx,0
  2516.         je .end_f
  2517.                 call ted_draw_buffer
  2518.                 cmp ted_fun_draw_panel_buttons,0
  2519.                 je .end_f
  2520.                         call ted_fun_draw_panel_buttons
  2521.         .end_f:
  2522.         popad
  2523.         ret
  2524. endp
  2525.  
  2526.  
  2527. align 4
  2528. proc ted_but_paste, edit:dword
  2529.         push eax ebx esi edi
  2530.         mov edi,dword[edit]
  2531.  
  2532.         mov esi,ted_buffer
  2533.         call tl_strlen
  2534.         cmp eax,1
  2535.         jl @f
  2536.                 mov esi,eax
  2537.                 call ted_set_undo
  2538.                 mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  2539.                 stdcall ted_sel_text_del,ebx
  2540.                 cmp al,1
  2541.                 jne .del
  2542.                         mov ebx,ted_opt_ed_move_cursor
  2543.                 .del:
  2544.                 stdcall ted_text_add,edi,ted_buffer,esi,ebx
  2545.                 stdcall ted_draw,edi
  2546.                 cmp ted_fun_draw_panel_buttons,0
  2547.                 je @f
  2548.                         call ted_fun_draw_panel_buttons
  2549.         @@:
  2550.         pop edi esi ebx eax
  2551.         ret
  2552. endp
  2553.  
  2554. align 4
  2555. proc ted_but_sumb_upper, edit:dword
  2556.   push edi esi
  2557.   mov edi,dword[edit]
  2558.  
  2559.   mov [conv_table],EvUpper
  2560.   call ted_convert_sel_text
  2561.   cmp esi,0
  2562.   je @f
  2563.     stdcall ted_draw,edi
  2564.   @@:
  2565.   pop esi edi
  2566.   ret
  2567. endp
  2568.  
  2569. align 4
  2570. proc ted_but_sumb_lover, edit:dword
  2571.   push edi esi
  2572.   mov edi,dword[edit]
  2573.  
  2574.   mov [conv_table],EvLover
  2575.   call ted_convert_sel_text
  2576.   cmp esi,0
  2577.   je @f
  2578.     stdcall ted_draw,edi
  2579.   @@:
  2580.   pop esi edi
  2581.   ret
  2582. endp
  2583.  
  2584. align 4
  2585. proc ted_but_reverse, edit:dword
  2586.   push eax ebx edi
  2587.   mov edi,dword[edit]
  2588.  
  2589.   call ted_is_select
  2590.   cmp al,0
  2591.   je @f
  2592.     call ted_sel_normalize
  2593.     push esi ecx edx
  2594.       mov esi,ted_seln_x0
  2595.       mov ecx,ted_seln_y0
  2596.       call ted_get_pos_by_coords
  2597.       mov eax,edx
  2598.       mov esi,ted_seln_x1
  2599.       cmp esi,0
  2600.       je .beg_str
  2601.         dec esi
  2602.       .beg_str:
  2603.       mov ecx,ted_seln_y1
  2604.       call ted_get_pos_by_coords
  2605.       ;call ted_get_text_perv_pos
  2606.       mov ebx,edx
  2607.     pop edx ecx esi
  2608.     ;cmp eax,...
  2609.     ;je @f
  2610.     call ted_revers
  2611.   @@:
  2612.   stdcall ted_draw,edi
  2613.   pop edi ebx eax
  2614.   ret
  2615. endp
  2616.  
  2617. align 4
  2618. proc ted_but_undo, edit:dword
  2619.         push eax edi
  2620.         mov edi,dword[edit]
  2621.  
  2622.         mov eax,ted_tim_undo
  2623.         cmp ted_tim_ch,eax
  2624.         jbe @f
  2625.                 inc ted_tim_undo
  2626.                 ;call ted_text_colored
  2627.                 stdcall ted_draw,edi
  2628.                 cmp ted_fun_draw_panel_buttons,0
  2629.                 je @f
  2630.                         call ted_fun_draw_panel_buttons
  2631.         @@:
  2632.         pop edi eax
  2633.         ret
  2634. endp
  2635.  
  2636. align 4
  2637. proc ted_but_redo, edit:dword
  2638.         push edi
  2639.         mov edi,dword[edit]
  2640.  
  2641.         cmp ted_tim_undo,1
  2642.         jb @f
  2643.                 dec ted_tim_undo
  2644.                 ;call ted_text_colored
  2645.                 stdcall ted_draw,edi
  2646.                 cmp ted_fun_draw_panel_buttons,0
  2647.                 je @f
  2648.                         call ted_fun_draw_panel_buttons
  2649.         @@:
  2650.         pop edi
  2651.         ret
  2652. endp
  2653.  
  2654. align 4
  2655. proc ted_but_find_next, edit:dword
  2656.         pushad
  2657.         mov edi,dword[edit]
  2658.  
  2659.         call ted_get_pos_by_cursor
  2660.         mov eax,ted_buffer_find
  2661.         mov bl,byte[eax]
  2662.         @@:
  2663.                 call ted_get_find_rezult
  2664.                 cmp bh,1
  2665.                 je @f ; find
  2666.                         call ted_iterat_next
  2667.                         cmp edx,ted_tex_1
  2668.                         jle @f
  2669.                         jmp @b
  2670.         @@:
  2671.         cmp bh,0
  2672.         je @f
  2673.                 call ted_get_text_coords
  2674.                 inc ebx ;move cursor right
  2675.                 mov ted_sel_x1,ebx
  2676.                 mov ted_sel_y1,eax
  2677.                 mov edx,eax
  2678.                 mov ecx,ebx
  2679.                 call ted_go_to_pos
  2680.                 mov edx,esi ;esi ¡ë«® ãáâ ­®¢«¥® ¢ ted_get_find_rezult
  2681.                 call ted_get_text_coords
  2682.                 mov ted_sel_x0,ebx
  2683.                 mov ted_sel_y0,eax
  2684.                 stdcall ted_draw,edi
  2685.                 jmp .end_find
  2686.         @@:
  2687.                 ;¯®¯ ¤ ¥¬ á ¥á«¨ ⥪áâ ­¥ ­ ©¤¥­
  2688.                 cmp ted_fun_find_err,0
  2689.                 je .end_find
  2690.                         call ted_fun_find_err ;¯®«ì§®¢ â¥«ì᪠ï äã­ªæ¨ï
  2691.         .end_find:
  2692.         popad
  2693.         ret
  2694. endp
  2695.  
  2696. ;input:
  2697. ; edi = pointer to tedit struct
  2698. align 4
  2699. ted_key_ctrl_home:
  2700.         mov ted_cur_x,0
  2701.         mov ted_cur_y,0
  2702.         push eax
  2703.                 mov eax,ted_scr_w
  2704.                 mov dword[eax+sb_offs_position],0
  2705.                 mov eax,ted_scr_h
  2706.                 mov dword[eax+sb_offs_position],0
  2707.         pop eax
  2708.         stdcall ted_draw,edi
  2709.         cmp ted_fun_draw_panel_buttons,0
  2710.         je @f
  2711.                 call ted_fun_draw_panel_buttons
  2712.         @@:
  2713.         ret
  2714.  
  2715. ;input:
  2716. ; edi = pointer to tedit struct
  2717. align 4
  2718. proc ted_sel_key_up
  2719.   cmp ted_drag_k,1
  2720.   je @f
  2721.     call ted_sel_start
  2722.     mov ted_drag_k,1
  2723.   @@:
  2724.   push dx
  2725.     call ted_cur_move_up
  2726.     cmp dl,8
  2727.     jne @f
  2728.       call ted_scroll_set_redraw
  2729.     @@:
  2730.   pop dx
  2731.   call ted_sel_move
  2732.   stdcall ted_draw,edi
  2733.   ret
  2734. endp
  2735.  
  2736. ;input:
  2737. ; edi = pointer to tedit struct
  2738. align 4
  2739. proc ted_sel_key_down
  2740.   cmp ted_drag_k,1
  2741.   je @f
  2742.     call ted_sel_start
  2743.     mov ted_drag_k,1
  2744.   @@:
  2745.   push dx
  2746.     call ted_cur_move_down
  2747.     cmp dl,8
  2748.     jne @f
  2749.       call ted_scroll_set_redraw
  2750.     @@:
  2751.   pop dx
  2752.   call ted_sel_move
  2753.   stdcall ted_draw,edi
  2754.   ret
  2755. endp
  2756.  
  2757. ;input:
  2758. ; edi = pointer to tedit struct
  2759. align 4
  2760. proc ted_sel_key_left
  2761.   cmp ted_drag_k,1
  2762.   je @f
  2763.     call ted_sel_start
  2764.   @@:
  2765.   push dx
  2766.     call ted_cur_move_left
  2767.     call ted_sel_move
  2768.     cmp ted_drag_k,1
  2769.     je @f
  2770.       mov ted_drag_k,1
  2771.       mov dl,8
  2772.     @@:
  2773.     cmp dl,8
  2774.     jne @f
  2775.       call ted_scroll_set_redraw
  2776.       stdcall ted_draw,edi
  2777.       jmp .end_f
  2778.     @@:
  2779.       stdcall ted_draw_cur_line,edi
  2780.     .end_f:
  2781.   pop dx
  2782.   ret
  2783. endp
  2784.  
  2785. ;input:
  2786. ; edi = pointer to tedit struct
  2787. align 4
  2788. proc ted_sel_key_right
  2789.   cmp ted_drag_k,1
  2790.   je @f
  2791.     call ted_sel_start
  2792.   @@:
  2793.   push dx
  2794.     call ted_cur_move_right
  2795.     call ted_sel_move
  2796.     cmp ted_drag_k,1
  2797.     je @f
  2798.       mov ted_drag_k,1
  2799.       mov dl,8
  2800.     @@:
  2801.     cmp dl,8
  2802.     jne @f
  2803.       call ted_scroll_set_redraw
  2804.       stdcall ted_draw,edi
  2805.       jmp .end_f
  2806.     @@:
  2807.       stdcall ted_draw_cur_line,edi
  2808.     .end_f:
  2809.   pop dx
  2810.   ret
  2811. endp
  2812.  
  2813. ;input:
  2814. ; edi = pointer to tedit struct
  2815. ;description:
  2816. ; this function need to optimize output
  2817. align 4
  2818. proc ted_draw_cursor_sumb
  2819.   pushad
  2820.  
  2821.   mov eax,13 ;rect
  2822.   mov ebx,ted_wnd_l
  2823.   add ebx,ted_rec_l
  2824.   mov edx,ted_cur_x
  2825.   imul edx,ted_rec_w
  2826.   add ebx,edx
  2827.   shl ebx,16
  2828.   add ebx,ted_rec_w
  2829.  
  2830.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  2831.   add ecx,ted_rec_t
  2832.   mov edx,ted_cur_y
  2833.   imul edx,ted_rec_h
  2834.   add ecx,edx
  2835.   shl ecx,16
  2836.   add ecx,ted_rec_h
  2837.  
  2838.   mov edx,ted_color_wnd_work
  2839.   push ecx
  2840.     call ted_sel_normalize
  2841.  
  2842.     mov esi,ted_scr_w
  2843.         mov ecx,dword[esi+sb_offs_position]
  2844.     sub ted_seln_y0,ecx
  2845.     sub ted_seln_y1,ecx
  2846.  
  2847.     mov ecx,ted_cur_y
  2848.     cmp ecx,ted_seln_y0
  2849.     jl .no_cur_sel
  2850.     cmp ecx,ted_seln_y1
  2851.     jg .no_cur_sel
  2852.     mov edx,ted_color_select ;¬¥­ï¥¬ 梥â ä®­  ­  梥⠢뤥«¥­¨ï
  2853.    
  2854.     mov esi,ted_scr_h
  2855.         cmp ecx,ted_seln_y0
  2856.     jne @f
  2857.       mov ecx,ted_cur_x
  2858.       add ecx,dword[esi+sb_offs_position]
  2859.       cmp ecx,ted_seln_x0
  2860.       jge @f
  2861.       mov edx,ted_color_wnd_work
  2862.     @@:
  2863.  
  2864.     mov ecx,ted_cur_y
  2865.     cmp ecx,ted_seln_y1
  2866.     jne .no_cur_sel
  2867.       mov ecx,ted_cur_x
  2868.       add ecx,dword[esi+sb_offs_position]
  2869.       cmp ecx,ted_seln_x1
  2870.       jl .no_cur_sel
  2871.       mov edx,ted_color_wnd_work
  2872.  
  2873.     .no_cur_sel:
  2874.   pop ecx
  2875.   int 0x40 ;à¨á®¢ ­¨¥ ¯àאַ㣮«ì­¨ª 
  2876.  
  2877.   call ted_get_pos_by_cursor ;¡¥à¥¬ ¯®§¨æ¨î ᨬ¢®« 
  2878.   cmp ted_gp_opt,2
  2879.   jne @f
  2880.     mov eax,4
  2881.     mov esi,1
  2882.     ror ecx,16
  2883.     mov bx,cx
  2884.     add ebx,0x10001
  2885.     call ted_get_symb_color
  2886.     call ted_convert_invis_symb
  2887.     int 0x40 ;à¨á®¢ ­¨¥ ᨬ¢®« 
  2888.   @@:
  2889.  
  2890.   popad
  2891.   ret
  2892. endp
  2893.  
  2894. ;input:
  2895. ; edx -> pointer to text
  2896. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  2897. ;output:
  2898. ; ecx = color
  2899. ; if ted_mode_color=0 then ecx=ted_color_wnd_text
  2900. align 4
  2901. ted_get_symb_color:
  2902.   mov ecx,ted_color_wnd_text ;§ ¤ ¥¬ 梥â ⥪áâ  ¯® 㬮«ç ­¨î
  2903.  
  2904.   push eax edx
  2905.   cmp ted_mode_color,0
  2906.   je .exit
  2907.     jmp .on_first
  2908.     @@:
  2909.       call ted_iterat_perv
  2910.       cmp edx,ted_tex_1
  2911.       jle .exit
  2912.     .on_first:
  2913.       xor eax,eax
  2914.       mov al,byte[edx+1]
  2915.       cmp al,0 ;¥á«¨ al=0 ⮠梥⠭¥ ¬¥­ï¥âáï
  2916.     je @b
  2917.  
  2918.     cmp eax,ted_colors_text_count
  2919.     jge .exit
  2920.  
  2921.     shl ax,2 ;㬭®¦ ¥¬ ¨­¤¥ªá æ¢¥â  ­  4 ¡ ©â 
  2922.     mov ecx,ted_text_colors ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 1-£® 梥â 
  2923.     add ecx,eax
  2924.     mov ecx,dword[ecx] ;ãáâ ­ ¢«¨¢ ¥¬ ⥪ã騩 梥â ⥪áâ  ¯® ᬥ饭¨î
  2925.   .exit:
  2926.   pop edx eax
  2927.   ret
  2928.  
  2929. ;input:
  2930. ; edx = pointer to text
  2931. ; edi = pointer to tedit struct
  2932. ;description:
  2933. ; ”ã­ªæ¨ï ¯à¥®¡à §ã¥â ­¥¢¨¤¨¬ë¥ ᨬ¢®«ë ¢ ¯¥ç â ¥¬ë¥ ­  íªà ­¥
  2934. align 4
  2935. ted_convert_invis_symb:
  2936.         cmp ted_mode_invis,1
  2937.         jne .end_f
  2938.                 cmp byte[edx],9
  2939.                 jne @f
  2940.                         lea edx,[ted_symbol_tab]
  2941.                 @@:
  2942.                 cmp byte[edx],13
  2943.                 jne @f
  2944.                         mov edx,edi
  2945.                         add edx,ted_offs_symbol_new_line
  2946.                 @@:
  2947.         .end_f:
  2948.         ret
  2949.  
  2950. ;input:
  2951. ; edi = pointer to tedit struct
  2952. align 4
  2953. ted_scroll_set_redraw:
  2954.         push eax
  2955.         mov eax,ted_scr_w
  2956.         mov dword[eax+sb_offs_redraw],1
  2957.         mov eax,ted_scr_h
  2958.         mov dword[eax+sb_offs_redraw],1
  2959.         pop eax
  2960.         ret
  2961.  
  2962. align 4
  2963. proc ted_draw, edit:dword
  2964.         locals
  2965.                 line_num dd ?
  2966.         endl
  2967.         pushad
  2968.         mov edi,dword[edit]
  2969.  
  2970.         mov eax,4 ;draw text
  2971.         mov ecx,ted_text_colors
  2972.         mov ecx,dword[ecx]
  2973.  
  2974.         mov ebx,ted_wnd_l
  2975.         add ebx,ted_rec_l
  2976.         shl ebx,16
  2977.         add ebx,ted_wnd_t
  2978.         add ebx,ted_rec_t
  2979.         add ebx,0x10001 ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  2980.  
  2981.         call ted_sel_normalize ;need before draw select
  2982.         mov esi,ted_scr_w
  2983.         mov esi,dword[esi+sb_offs_position]
  2984.         mov dword[line_num],esi
  2985.  
  2986.         stdcall ted_clear_line_before_draw, edi,ebx,1,esi
  2987.         call ted_get_first_visible_pos
  2988.         cmp edx,0
  2989.         je .no_draw_text
  2990.         mov esi,1 ;¤«¨­­  ¢ë¢®¤¨¬®£® ⥪áâ  ¯® 1-¬ã ᨬ¢®«ã
  2991.         @@:
  2992.                 call ted_iterat_next
  2993.                 cmp edx,ted_tex_1
  2994.                 jle .no_draw_text
  2995.  
  2996.                 ; *** 梥⮢ ï à §¬¥âª 
  2997.                 cmp ted_mode_color,0
  2998.                 je .no_col_change
  2999.                 cmp byte[edx+1],0
  3000.                 je .no_col_change
  3001.                         call ted_get_symb_color
  3002.                 .no_col_change:
  3003.  
  3004.                 cmp byte [edx],13
  3005.                 jne .no_13
  3006.                         cmp ted_mode_invis,1
  3007.                         jne .no_invis
  3008.                                 push edx
  3009.                                 mov edx,edi
  3010.                                 add edx,ted_offs_symbol_new_line
  3011.                                 int 0x40
  3012.                                 pop edx
  3013.                         .no_invis:
  3014.                         add ebx,ted_rec_h
  3015.                         ;optimized output \/
  3016.                         mov eax,ted_wnd_h
  3017.                         add eax,ted_wnd_t
  3018.                         cmp bx,ax
  3019.                         jg .no_draw_text
  3020.                         mov eax,4
  3021.                         ;optimized output /\        
  3022.                         and ebx,0xffff
  3023.                         ror ebx,16
  3024.                         add ebx,ted_wnd_l
  3025.                         add ebx,ted_rec_l
  3026.                         inc ebx
  3027.                         ror ebx,16
  3028.                         inc dword[line_num] ;increment line number
  3029.                         stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
  3030.                         call ted_opt_draw_line_left
  3031.                         jmp @b
  3032.                 .no_13:
  3033.  
  3034.                 int 0x40
  3035.                 ror ebx,16
  3036.                 add ebx,ted_rec_w
  3037.                 mov esi,ted_wnd_l
  3038.                 add esi,ted_wnd_w
  3039.                 cmp bx,si
  3040.                 jl .no_opt
  3041.                         call ted_opt_draw_line_right
  3042.                 .no_opt:
  3043.                 mov si,1
  3044.                 ror ebx,16
  3045.                 jmp @b
  3046.         .no_draw_text:
  3047.  
  3048.         stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
  3049.         call ted_draw_line_numbers
  3050.         call ted_draw_main_cursor
  3051.  
  3052. ;---------------------------------------------
  3053. ; set all_redraw flag for draw all ScrollBar
  3054. ; In some cases it is necessity to draw only the area
  3055. ; of moving of a "runner", for acceleration of output -
  3056. ; in this case the flag needs to be reset to 0 (zero).
  3057.         mov eax,ted_scr_h
  3058.         mov esi,ted_scr_w
  3059.         mov dword[eax+sb_offs_all_redraw],1
  3060.         mov dword[esi+sb_offs_all_redraw],1
  3061.  
  3062. ; à¨á®¢ ­¨¥ ¯®«®á ¯à®ªàã⪨
  3063.         stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
  3064.         stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
  3065. ; reset all_redraw flag
  3066.         mov dword[eax+sb_offs_all_redraw],0
  3067.         mov dword[esi+sb_offs_all_redraw],0
  3068. ;---------------------------------------------
  3069.  
  3070.   ;left-bottom square
  3071.   mov ebx,ted_wnd_l
  3072.   shl ebx,16
  3073.   add ebx,ted_rec_l
  3074.   mov ecx,ted_wnd_t
  3075.   add ecx,ted_wnd_h
  3076.   shl ecx,16
  3077.   mov cx,word[eax+sb_offs_size_y]
  3078.   inc cx
  3079.   mov edx,ted_color_wnd_capt ;[sc.work]
  3080.   mov eax,13
  3081.   int 0x40
  3082.  
  3083.         ;right-bottom square
  3084.         mov ebx,ted_wnd_l
  3085.         add ebx,ted_wnd_w
  3086.         shl ebx,16
  3087.         mov bx,word[esi+sb_offs_size_x]
  3088.         inc bx
  3089.         int 0x40
  3090.  
  3091.         cmp ted_fun_draw_panel_find,0
  3092.         je @f
  3093.                 call ted_fun_draw_panel_find
  3094.         @@:
  3095.         cmp ted_fun_draw_panel_syntax,0
  3096.         je @f
  3097.                 call ted_fun_draw_panel_syntax
  3098.         @@:
  3099.         popad
  3100.         ret
  3101. endp
  3102.  
  3103. ;input:
  3104. ; edi = pointer to tedit struct
  3105. align 4
  3106. proc ted_draw_main_cursor
  3107.   pushad
  3108.  
  3109.   mov eax,13 ;draw cursor
  3110.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  3111.   add ecx,ted_rec_t
  3112.   mov edx,ted_cur_y
  3113.   imul edx,ted_rec_h
  3114.   add ecx,edx
  3115.  
  3116.   cmp ted_cur_ins,1 ;¯à®¢¥àª  ०¨¬  à ¡®âë ªãàá®à  (®¡ëç­ë© ¨«¨ ¢áâ ¢ª )
  3117.   jne @f
  3118.     mov edx,ted_rec_h
  3119.     inc edx   ;1->1, 3->2, 5->3, ...
  3120.     shr edx,1 ;edx = ¢ëá®â  áâப¨ ¤¥«¥­­ ï ­  2 (ª®£¤  ªãàá®à ­¥ ¯®«­ë©)
  3121.     add ecx,edx
  3122.   @@:
  3123.   shl ecx,16
  3124.   add ecx,ted_rec_h
  3125.   cmp ted_cur_ins,1
  3126.   jne @f
  3127.     shr cx,1 ;¤¥«¨¬ ¢ëá®âã ªãàá®à  ­  2
  3128.   @@:
  3129.  
  3130.   mov ebx,ted_wnd_l ;calc rect -> x0,x1
  3131.   add ebx,ted_rec_l
  3132.   mov edx,ted_cur_x
  3133.   imul edx,ted_rec_w
  3134.   add ebx,edx
  3135.   shl ebx,16
  3136.   add ebx,ted_rec_w
  3137.  
  3138.   mov edx,ted_color_cursor
  3139.   int 0x40 ;¢ë¢®¤ ªãàá®à 
  3140.  
  3141.   call ted_get_pos_by_cursor
  3142.   cmp ted_gp_opt,2
  3143.   jne @f
  3144.     mov eax,4 ;draw text
  3145.     mov esi,1
  3146.     ror ecx,16
  3147.     mov bx,cx
  3148.     add ebx,0x10001
  3149.     cmp ted_cur_ins,1
  3150.     jne .no_up_tetx
  3151.       mov ecx,ted_rec_h
  3152.       inc cx ; 1->1, 3->2, 5->3, ...
  3153.       shr cx,1
  3154.       sub bx,cx
  3155.     .no_up_tetx:
  3156.     mov ecx,ted_color_cur_text
  3157.     call ted_convert_invis_symb
  3158.     int 0x40
  3159.   @@:
  3160.  
  3161.   mov eax,4
  3162.   mov ebx,ted_wnd_l
  3163.   add ebx,ted_rec_l
  3164.   shl ebx,16
  3165.   add ebx,ted_wnd_t
  3166.   add ebx,3
  3167.   mov ecx,ted_color_wnd_bord
  3168.   or  ecx,0x80000000
  3169.   lea edx,[txtRow]
  3170.   int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‘âப '
  3171.  
  3172.   add ebx,0x500000
  3173.   lea edx,[txtCol]
  3174.   int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‡­ ª'
  3175.  
  3176.   cmp ted_tim_undo,0
  3177.   je @f
  3178.     add ebx,0x500000
  3179.     lea edx,[txtOtm]
  3180.     int 0x40
  3181.     sub ebx,0x500000
  3182.   @@:
  3183.  
  3184.   call ted_draw_buffer
  3185.   call ted_draw_help_f1
  3186.  
  3187.   mov eax,47 ;draw cursor coords
  3188.   mov esi,ted_color_wnd_bord
  3189.   or  esi,0x40000000
  3190.  
  3191.   mov edx,ebx
  3192.   ror edx,16
  3193.   sub edx,35
  3194.   ror edx,16
  3195.   ;add edx,3
  3196.   mov ebx,0x40000 ;Row=...
  3197.   mov ecx,ted_scr_w
  3198.   mov ecx,dword[ecx+sb_offs_position]
  3199.   add ecx,ted_cur_y
  3200.   inc ecx
  3201.  
  3202. push edi
  3203.   mov edi,ted_color_wnd_work
  3204.   int 0x40 ;¢ë¢®¤ ç¨á«  ⥪ã饩 áâப¨
  3205. pop edi
  3206.  
  3207.   ;mov ebx,0x40000 ;Col=...
  3208.   mov ecx,ted_scr_h
  3209.   mov ecx,dword[ecx+sb_offs_position]
  3210.   add ecx,ted_cur_x
  3211.   inc ecx
  3212.   add edx,0x500000
  3213. push edi
  3214.   mov edi,ted_color_wnd_work
  3215.   int 0x40 ;¢ë¢®¤ ç¨á«  §­ ª®¢
  3216. pop edi
  3217.  
  3218.   cmp ted_tim_undo,0
  3219.   je @f
  3220.     mov ecx,ted_tim_undo
  3221.     add edx,0x500000
  3222.         mov edi,ted_color_wnd_work ;¯®à⨬ ॣ¨áâà edi, ­® ¢ ª®­æ¥ ä㭪樨 í⮠㦥 ­¥ ¢ ¦­®
  3223.     int 0x40 ;¢ë¢®¤ ç¨á«  ®â¬¥­¥­­ëå ¤¥©á⢨©
  3224.   @@:
  3225.  
  3226.   popad
  3227.   ret
  3228. endp
  3229.  
  3230. ;input:
  3231. ; edi = pointer to tedit struct
  3232. proc ted_draw_buffer
  3233.         pushad
  3234.  
  3235.         mov eax,ted_buffer
  3236.         cmp byte[eax],0 ;ᬮâਬ 1-© ᨬ¢®« ¨§ ¡ãä¥à 
  3237.         je @f
  3238.                 mov ebx,ted_rec_l
  3239.                 add bx,300
  3240.                 cmp ebx,ted_wnd_w ;áà ¢­¨¢ ¥¬ ª®®à¤¨­ âã ¤«ï ¢ë¢®¤ ⥪áâ 
  3241.                 jge @f ;¯®¤¯¨áì ­¥ ¢« §¨â ¢ ®ª­®
  3242.  
  3243.                 add ebx,ted_wnd_l
  3244.                 shl ebx,16
  3245.                 add ebx,ted_wnd_t
  3246.                 add ebx,3
  3247.                 mov ecx,ted_color_wnd_bord
  3248.                 or ecx,0x40000000
  3249.  
  3250.                 mov edx,ted_buffer
  3251.                 mov esi,edx
  3252.                 mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
  3253.                 call tl_strlen
  3254.                 ;cmp eax,0 ;¡ãä¥à ¯ãáâ
  3255.                 ;je @f
  3256.                 cmp eax,20
  3257.                 jle .crop_buf
  3258.                         mov eax,20 ;®¡à¥§ª  ¯®¤¯¨á¨ ¤® 20 ᨬ¢®«®¢
  3259.                 .crop_buf:
  3260.                 mov esi,eax
  3261.                 mov eax,4
  3262.                 int 0x40 ;¢ë¢®¤ ᮤ¥à¦¨¬®£® ¡ãä¥à 
  3263.  
  3264.                 sub ebx,50 shl 16
  3265.                 lea edx,[txtBuf]
  3266.                 mov esi,edx
  3267.                 call tl_strlen
  3268.                 mov esi,eax
  3269.                 mov eax,4
  3270.                 xor ecx,0x40000000 ;㡨ࠥ¬ 梥â ä®­ 
  3271.                 int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ ¤«ï ¡ãä¥à 
  3272.         @@:
  3273.         popad
  3274.         ret
  3275. endp
  3276.  
  3277. ;input:
  3278. ; edi = pointer to tedit struct
  3279. align 4
  3280. proc ted_draw_help_f1
  3281.         pushad
  3282.         cmp ted_rec_t,13 ;¬¨­¨¬ «ì­ ï ¢ëá®â  ¤«ï à¨á®¢ ­¨ï á¯à ¢ª¨
  3283.         jle @f
  3284.                 mov eax,13 ;clear place before draw help
  3285.                 mov ebx,ted_wnd_l
  3286.                 add ebx,ted_rec_l
  3287.                 shl ebx,16
  3288.                 add ebx,ted_wnd_w
  3289.                 sub ebx,ted_rec_l
  3290.                 mov ecx,ted_wnd_t
  3291.                 add ecx,13
  3292.                 shl ecx,16
  3293.                 add ecx,ted_rec_h
  3294.                 mov edx,ted_color_wnd_capt
  3295.                 int 0x40
  3296.  
  3297.         cmp ted_help_id,-1
  3298.         je @f
  3299.                 mov eax,ted_help_id
  3300.                 ColToIndexOffset eax,edx
  3301.  
  3302.                 ;SetCoordinates
  3303.                 mov ebx,ted_wnd_l
  3304.                 add ebx,ted_rec_l
  3305.                 shl ebx,16
  3306.                 add ebx,ted_wnd_t
  3307.                 add ebx,13 ;=3+10
  3308.  
  3309.                 ;SetTextColor
  3310.                 xor eax,eax
  3311.                 mov al,byte[edx+MAX_COLOR_WORD_LEN+6]
  3312.                 shl ax,2
  3313.                 mov ecx,ted_text_colors
  3314.                 add ecx,eax
  3315.                 mov ecx,dword[ecx]
  3316.                 or      ecx,0xc0000000 ;SetTextStyles
  3317.                 mov esi,edi
  3318.                         mov edi,ted_color_wnd_work
  3319.                         mov eax,4
  3320.                         int 0x40
  3321.                 mov edi,esi
  3322.  
  3323.                 ;*** draw help string ***
  3324.                 mov ecx,ted_color_wnd_bord
  3325.                 or ecx,0x80000000
  3326.                 mov edx,dword[edx+MAX_COLOR_WORD_LEN]
  3327.                 cmp edx,0
  3328.                 je @f
  3329.                         add edx,ted_help_text_f1
  3330.                         add ebx,0x500000
  3331.                         int 0x40
  3332.         @@:
  3333.         popad
  3334.         ret
  3335. endp
  3336.  
  3337. ;input:
  3338. ; edi = pointer to tedit struct
  3339. align 4
  3340. proc ted_draw_line_numbers
  3341.   pushad
  3342.  
  3343.   ;top panel with caption
  3344.   mov ebx,ted_wnd_l
  3345. ;  add ebx,ted_rec_l
  3346.   shl ebx,16
  3347.   add ebx,ted_wnd_w
  3348. ;  sub ebx,ted_rec_l
  3349.   mov edx,ted_color_wnd_work
  3350.   mov ecx,ted_wnd_t
  3351.   shl ecx,16
  3352.   add ecx,ted_rec_t
  3353.   mov eax,13
  3354.   mov edx,ted_color_wnd_capt
  3355.   int 0x40
  3356.  
  3357.   ;line numbers
  3358.   mov ebx,0x40000 ;format
  3359.   mov ecx,ted_scr_w
  3360.   mov ecx,dword[ecx+sb_offs_position]
  3361.   inc ecx
  3362.   mov edx,3
  3363.   add edx,ted_wnd_l
  3364.   rol edx,16
  3365.   add edx,ted_wnd_t
  3366.   add edx,ted_rec_t
  3367.   @@:
  3368.  
  3369. push ebx ecx edx
  3370.   ;left panel with numbers
  3371.   mov ebx,ted_wnd_l
  3372.   shl ebx,16
  3373.   add ebx,ted_rec_l
  3374.   mov ecx,ted_rec_h
  3375.   rol ecx,16
  3376.   mov cx,dx
  3377.   rol ecx,16
  3378.   mov eax,13
  3379.   mov edx,ted_color_wnd_capt
  3380.   int 0x40 ;à¨á㥬 ¯àאַ㣮«ì­¨ª ¯®¤ ­®¬¥à®¬ áâப¨
  3381. pop edx ecx ebx
  3382.  
  3383.     mov eax,47
  3384.     mov esi,ted_color_wnd_bord
  3385.     int 0x40 ;à¨á㥬 ­®¬¥à áâப¨
  3386.     inc ecx
  3387.     add edx,ted_rec_h
  3388.     sub edx,ted_wnd_t
  3389.         mov esi,edx
  3390.         and esi,0xffff
  3391.     cmp esi,ted_wnd_h
  3392.     jge @f
  3393.     add edx,ted_wnd_t
  3394.     jmp @b
  3395.   @@:
  3396.  
  3397.   popad
  3398.   ret
  3399. endp
  3400.  
  3401. ;output:
  3402. ; ah = symbol
  3403. align 4
  3404. proc KeyConvertToASCII, table:dword
  3405.         push ebx
  3406.         mov ebx,dword[table] ;convert scan to ascii
  3407.         ror ax,8
  3408.         xor ah,ah
  3409.         add bx,ax ;? ebx,eax
  3410.         mov ah,byte[ebx]
  3411.         pop ebx
  3412.         ret
  3413. endp
  3414.  
  3415. align 4
  3416. proc ted_draw_cur_line, edit:dword
  3417.   pushad
  3418.     mov edi,dword[edit]
  3419.  
  3420.     mov ebx,ted_wnd_l
  3421.     add ebx,ted_rec_l
  3422.     shl ebx,16
  3423.     mov eax,ted_cur_y
  3424.     imul eax,ted_rec_h
  3425.         mov bx,ax
  3426.     add ebx,ted_wnd_t
  3427.     add ebx,ted_rec_t ;ebx - ª®®à¤¨­ âë ¤«ï ¯àאַ㣮«ì­¨ª  ®ç¨á⪨ «¨­¨¨
  3428.         add ebx,0x10001   ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3429.  
  3430.     call ted_sel_normalize ;need before draw select
  3431.         mov ecx,ted_cur_y
  3432.         mov eax,ted_scr_w
  3433.     add ecx,dword[eax+sb_offs_position]
  3434.     stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
  3435.  
  3436.     mov eax,ted_scr_h
  3437.         mov esi,dword[eax+sb_offs_position]
  3438.     call ted_get_pos_by_coords
  3439.  
  3440.   cmp ted_gp_opt,2
  3441.   jne .no_draw_text
  3442. ;  mov eax,4 ;draw text
  3443.   call ted_get_symb_color
  3444.   mov esi,1 ;draw 1 symbol
  3445.   @@:
  3446.     ;call ted_iterat_next
  3447.     cmp edx,ted_tex_1
  3448.     jle .no_draw_text
  3449.  
  3450.     ; *** 梥⮢ ï à §¬¥âª 
  3451.     cmp ted_mode_color,0
  3452.     je .no_col_change
  3453.     cmp byte[edx+1],0
  3454.     je .no_col_change
  3455.       call ted_get_symb_color
  3456.     .no_col_change:
  3457.  
  3458.     mov eax,4 ;draw text
  3459.     cmp byte [edx],13
  3460.     jne .no_13
  3461.       cmp ted_mode_invis,1
  3462.       jne .no_draw_text
  3463.  push edx
  3464.  mov edx,edi
  3465.  add edx,ted_offs_symbol_new_line
  3466.  int 0x40
  3467.  pop edx
  3468.       jmp .no_draw_text
  3469.     .no_13:
  3470.  
  3471.     int 0x40
  3472.     ror ebx,16
  3473.     add ebx,ted_rec_w
  3474.     mov eax,ted_wnd_w
  3475.     add eax,ted_wnd_l ;ax = ®âáâ㯠¯® ®á¨ x
  3476.     cmp bx,ax
  3477.     jge .no_draw_text ;Opt
  3478.     ror ebx,16
  3479.     call ted_iterat_next
  3480.     jmp @b
  3481.   .no_draw_text:
  3482.  
  3483.   call ted_draw_main_cursor
  3484.   popad
  3485.   ret
  3486. endp
  3487.  
  3488. ;input:
  3489. ; eax - text need find
  3490. ; bl - first symbol to find
  3491. ; edx - first symbol pointer
  3492. ; edi - pointer to tedit struct
  3493. ;output:
  3494. ; bh - rezult
  3495. ; edx - last text position (if find sucess)
  3496. ; esi - first symbol pointer
  3497. ;description:
  3498. ; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ eax
  3499. ; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
  3500. ; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
  3501. ; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
  3502. align 4
  3503. ted_get_find_rezult:
  3504.   push eax
  3505.     mov bh,1
  3506.     mov esi,edx ;copy edx
  3507.     @@:
  3508.       cmp byte[edx],bl
  3509.       jne .no_text
  3510.  
  3511.       inc eax ;*** get next symbol (in find text) ***
  3512.       mov bl,byte[eax]
  3513.       cmp bl,0
  3514.       je @f ;end of find text
  3515.  
  3516.       call ted_iterat_next ;*** get next symbol (in editor text) ***
  3517.       cmp edx,ted_tex_1
  3518.       jle @f ;end of editor text
  3519.  
  3520.       jmp @b
  3521.       .no_text:
  3522.         xor bh,bh
  3523.         mov edx,esi ;restore edx
  3524.     @@:
  3525.   pop eax
  3526.   mov bl,byte[eax] ;restore bl
  3527.   ret
  3528.  
  3529. ;input:
  3530. ;  clear_o - ¥á«¨ =1 ®ç¨áâ¨âì ®¤­ã áâபã, =0 ®ç¨áâ¨âì ¢á¥ áâப¨ ®ª­  ¤® ­¨§ã
  3531. align 4
  3532. proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
  3533.         pushad
  3534.         mov edi,dword[edit]
  3535.         mov ebx,dword[coords]   ;ebx = x*2^16+y coords to left up point clear line
  3536.         mov esi,dword[numb_lin] ;esi - number text line
  3537.  
  3538.         sub ebx,0x10001 ;®â­¨¬ ¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3539.         cmp dword[clear_o],0
  3540.         jne @f
  3541.                 add ebx,ted_rec_h
  3542.                 inc esi
  3543.                 ror ebx,16
  3544.                 xor bx,bx
  3545.                 add ebx,ted_wnd_l
  3546.                 add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
  3547.                 ror ebx,16
  3548.         @@:
  3549.  
  3550.         mov eax,ted_wnd_h
  3551.         add eax,ted_wnd_t
  3552.         cmp ax,bx
  3553.         jl .no_clear
  3554.         sub ax,bx
  3555.  
  3556.         mov cx,bx
  3557.         shl ecx,16
  3558.  
  3559.         xor bx,bx
  3560.         add ebx,ted_wnd_w
  3561.         sub ebx,ted_rec_l
  3562.         xor cx,cx
  3563.         add ecx,ted_rec_h
  3564.         mov edx,ted_color_wnd_work
  3565.  
  3566.         cmp dword[clear_o],0
  3567.         je .pusto
  3568.         cmp ax,cx
  3569.         jge @f
  3570.         .pusto:
  3571.                 mov cx,ax
  3572.         @@:
  3573.  
  3574.         call ted_is_select
  3575.         cmp al,0
  3576.         je @f
  3577.         cmp ted_seln_y0,esi
  3578.         jg @f
  3579.         cmp ted_seln_y1,esi
  3580.         jl @f
  3581.                 mov edx,ted_color_select ;draw selected line
  3582.         @@:
  3583.  
  3584.         mov eax,13 ;rect
  3585.         int 0x40
  3586.  
  3587.         call ted_is_select
  3588.         cmp al,0
  3589.         je .no_clear
  3590.  
  3591.         mov al,13 ;rect
  3592.         xor cx,cx
  3593.         add ecx,ted_rec_h
  3594.         cmp ted_seln_y0,esi
  3595.         jne @f
  3596.                 push bx esi
  3597.                 mov edx,ted_seln_x0 ; ¢¥àå­ïï ¯®«®á  (§ â¨à ¥â á«¥¢ )
  3598.                 mov esi,ted_scr_h
  3599.                 cmp edx,dword[esi+sb_offs_position]
  3600.                 jle .in_wnd
  3601.                         sub edx,dword[esi+sb_offs_position]
  3602.                         imul edx,ted_rec_w
  3603.                         mov bx,dx
  3604.                         jmp .no_wnd
  3605.                 .in_wnd:
  3606.                 mov bx,0
  3607.                 .no_wnd:
  3608.                 mov edx,ted_color_wnd_work
  3609.                 int 0x40
  3610.                 pop esi bx
  3611.         @@:
  3612.         cmp ted_seln_y1,esi
  3613.         jne @f
  3614.                 push esi
  3615.                 mov edx,ted_seln_x1 ; ­¨¦­ïï ¯®«®á  (§ â¨à ¥â á¯à ¢ )
  3616.                 mov esi,ted_scr_h
  3617.                 cmp edx,dword[esi+sb_offs_position]
  3618.                 jle .in_wnd2
  3619.                         sub edx,dword[esi+sb_offs_position]
  3620.                         imul edx,ted_rec_w
  3621.                         sub bx,dx
  3622.                         shl edx,16
  3623.                         add ebx,edx
  3624.                 .in_wnd2:
  3625.  
  3626.                 mov edx,ted_color_wnd_work
  3627.                 int 0x40
  3628.                 pop esi
  3629.         @@:
  3630.  
  3631.         .no_clear:
  3632.         popad
  3633.         ret
  3634. endp
  3635.  
  3636. ;input:
  3637. ; edi = pointer to tedit struct
  3638. ;output:
  3639. ; ecx = ­®¢ë© 梥â ᨬ¢®« 
  3640. ; edx = pointer to symbol
  3641. ; edx = 0 if text not in screen
  3642. align 4
  3643. ted_get_first_visible_pos:
  3644.         push eax ecx
  3645.         mov eax,ted_scr_w
  3646.         mov edx,ted_tex
  3647.         xor ecx,ecx
  3648.         @@:
  3649.                 cmp ecx,dword[eax+sb_offs_position]
  3650.                 je @f
  3651.                 call ted_iterat_next
  3652.                 cmp edx,ted_tex_1
  3653.                 jle @f
  3654.                 cmp byte [edx],13
  3655.                 jne @b
  3656.                 inc ecx
  3657.                 jmp @b
  3658.         @@:
  3659.  
  3660.         cmp ecx,dword[eax+sb_offs_position]
  3661.         je @f
  3662.                 xor edx,edx
  3663.         @@:
  3664.         cmp ecx,dword[eax+sb_offs_max_area]
  3665.         jle @f
  3666.                 mov dword[eax+sb_offs_max_area],ecx
  3667.         @@:
  3668.         pop ecx eax
  3669.         call ted_opt_draw_line_left
  3670.         ret
  3671.  
  3672. ;input:
  3673. ; edx = pointer to symbol
  3674. ; edi = pointer to tedit struct
  3675. ;output:
  3676. ; ecx = 梥â ᨬ¢®« 
  3677. ; edx = 㪠§ â¥«ì ­  ¯¥à¢ë© «¥¢ë© ᨬ¢®«
  3678. ;description:
  3679. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  3680. align 4
  3681. proc ted_opt_draw_line_left
  3682.   push ebx
  3683.  
  3684.   mov ebx,ted_scr_h
  3685.   mov ebx,dword[ebx+sb_offs_position]
  3686.   cmp ebx,0
  3687.   je .ret_f
  3688.   push eax
  3689.   mov eax,edx
  3690.  
  3691.   cmp edx,ted_tex
  3692.   jne @f
  3693.     call ted_iterat_next
  3694.     jmp .beg_cycle
  3695.   @@:
  3696.  
  3697.   cmp ebx,0
  3698.   je @f
  3699.  
  3700.   cmp byte[edx],13
  3701.   jne @f
  3702.     call ted_iterat_next
  3703.     .beg_cycle:
  3704.   @@:
  3705.     cmp edx,ted_tex_1
  3706.     jle @f
  3707.     cmp byte[edx],13
  3708.     je @f
  3709.     cmp ebx,0
  3710.     je @f
  3711. ;--------------------------------------
  3712. xor eax,eax ;eax ¡ã¤¥â ¬¥­ïâìáï
  3713. mov al,byte[edx+1]
  3714. cmp al,0
  3715. je .no_color
  3716. cmp eax,ted_colors_text_count
  3717. jge .no_color
  3718.   xor ecx,ecx
  3719.   mov cl,byte[edx+1]
  3720.   shl cx,2
  3721.   add ecx,ted_text_colors
  3722.   mov ecx,dword[ecx]
  3723. .no_color:
  3724. ;--------------------------------------
  3725.     mov eax,edx
  3726.     call ted_iterat_next
  3727.     dec ebx
  3728.     jmp @b
  3729.   @@:
  3730.     mov edx,eax
  3731.   pop eax
  3732.   .ret_f:
  3733.   call ted_get_symb_color
  3734.   pop ebx
  3735.   ret
  3736. endp
  3737.  
  3738. ;input:
  3739. ; edx = pointer to symbol
  3740. ; edi = pointer to tedit struct
  3741. ;output:
  3742. ; ecx = symbol color
  3743. ; edx = pointer to 13 symbol
  3744. ;description:
  3745. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  3746. align 4
  3747. proc ted_opt_draw_line_right
  3748.         push eax
  3749.         mov eax,edx
  3750.         @@:
  3751.                 cmp edx,ted_tex_1
  3752.                 jle @f
  3753.                 cmp byte[edx],13
  3754.                 je @f
  3755.                 mov eax,edx
  3756.                 call ted_iterat_next
  3757.                 jmp @b
  3758.         @@:
  3759.         mov edx,eax ;perv sumbol
  3760.         call ted_get_symb_color
  3761.  
  3762.         pop eax
  3763.         ret
  3764. endp
  3765.  
  3766. align 4
  3767. proc ted_mouse, edit:dword
  3768.         pushad
  3769.         mov edi,dword[edit]
  3770.  
  3771.         ;®¡à ¡ â뢠¥¬ áªà®««¨­£¨
  3772.         mov edx,ted_scr_h
  3773.         mov ecx,ted_scr_w
  3774.  
  3775.         cmp word[edx+sb_offs_delta2],0
  3776.         jne .horizontal
  3777.  
  3778.         mov eax,dword[ecx+sb_offs_max_area]
  3779.         cmp eax,dword[ecx+sb_offs_cur_area]
  3780.         jbe .horizontal
  3781.         ; mouse event for Vertical ScrollBar
  3782.         stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
  3783.         cmp dword[ecx+sb_offs_redraw],0
  3784.         je @f
  3785.                 mov dword[ecx+sb_offs_redraw],0
  3786.                 stdcall ted_draw,edi
  3787.                 jmp .no_in_wnd
  3788.         @@:
  3789.         cmp word[ecx+sb_offs_delta2],0
  3790.         jne .no_in_wnd
  3791.         .horizontal:
  3792.         mov eax,dword[edx+sb_offs_max_area]
  3793.         cmp eax,dword[edx+sb_offs_cur_area]
  3794.         jbe .other
  3795.         ; mouse event for Horizontal ScrollBar
  3796.         stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
  3797.         cmp dword[edx+sb_offs_redraw],0
  3798.         je .other
  3799.                 mov dword[edx+sb_offs_redraw],0
  3800.                 stdcall ted_draw,edi
  3801.                 jmp .no_in_wnd
  3802.         .other:
  3803.         cmp word[ecx+sb_offs_delta2],0
  3804.         jne .no_in_wnd
  3805.         cmp word[edx+sb_offs_delta2],0
  3806.         jne .no_in_wnd
  3807.  
  3808.         ;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
  3809.         mcall 37,2 ;get mouse buttons
  3810.         cmp al,1
  3811.         jne @f
  3812.                 mcall 37,1 ;get mouse coords
  3813.                 mov ebx,ted_wnd_t
  3814.                 add ebx,ted_rec_t
  3815.                 cmp ax,bx
  3816.                 jl @f ;y_mouse<y_wnd
  3817.  
  3818.                 sub ebx,ted_rec_t
  3819.                 add ebx,ted_wnd_h
  3820.                 cmp bx,ax
  3821.                 jl @f ;y_mouse>y_wnd
  3822.  
  3823.                 mov ebx,ted_wnd_l
  3824.                 add ebx,ted_rec_l
  3825.                 mov ecx,eax
  3826.                 shr ecx,16
  3827.                 cmp cx,bx
  3828.                 jl @f ;x_mouse<x_wnd
  3829.  
  3830.                 sub ebx,ted_rec_l
  3831.                 add ebx,ted_wnd_w
  3832.                 cmp bx,cx
  3833.                 jl @f ;x_mouse>x_wnd
  3834.  
  3835.                 call ted_draw_cursor_sumb
  3836.                 call ted_wnd_main_click
  3837.                 jmp .no_in_wnd
  3838.         @@:
  3839.         mov edx,ted_el_focus
  3840.         cmp dword[edx],edi
  3841.         jne @f
  3842.                 call ted_wnd_main_mouse_scroll ;ᬮâਬ ­  ¯à®ªàãâªã ª®«¥á  ¬ëè¨
  3843.         @@:
  3844.         cmp ted_drag_m,0
  3845.         je .no_in_wnd
  3846.                 mov ted_drag_m,0
  3847.                 stdcall ted_draw,edi
  3848.                 cmp ted_fun_draw_panel_buttons,0
  3849.                 je .no_in_wnd
  3850.                         call ted_fun_draw_panel_buttons
  3851.         .no_in_wnd:
  3852.         popad
  3853.         ret
  3854. endp
  3855.  
  3856. ;input:
  3857. ; eax -> (x,y)
  3858. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  3859. ;description:
  3860. ; äã­ªæ¨ï ¢ë§ë¢¥âáï ¯à¨ ­ ¦ â¨¨ ª­®¯ª®© ¬ëè¨ ¨ ¯®¯ ¤¥­¨¨ ªãàá®à®¬ ¢ ®ª­® । ªâ®à 
  3861. align 4
  3862. ted_wnd_main_click:
  3863.         push ebx ecx edx
  3864.         mov ebx,ted_el_focus
  3865.         mov dword[ebx],edi ;áâ ¢¨¬ 䮪ãá
  3866.  
  3867.   push eax
  3868.     shr eax,16
  3869.     and eax,0xffff
  3870.     sub eax,ted_wnd_l
  3871.     sub eax,ted_rec_l
  3872.  
  3873.     xor edx,edx
  3874.     mov ecx,ted_rec_w
  3875.     div cx
  3876.     ;inc eax
  3877.         mov ebx,ted_scr_h
  3878.     cmp eax,dword[ebx+sb_offs_cur_area]
  3879.     jle @f
  3880.       mov eax,dword[ebx+sb_offs_cur_area]
  3881.     @@:
  3882.     ;dec eax
  3883.     mov ted_cur_x,eax
  3884.   pop eax
  3885.  
  3886.   push eax
  3887.     and eax,0xffff
  3888.     sub eax,ted_wnd_t
  3889.     sub eax,ted_rec_t
  3890.  
  3891.     xor edx,edx
  3892.     mov ecx,ted_rec_h
  3893.     div cx
  3894.     inc eax
  3895.         mov ebx,ted_scr_w
  3896.     cmp eax,dword[ebx+sb_offs_cur_area]
  3897.     jle @f
  3898.       mov eax,dword[ebx+sb_offs_cur_area]
  3899.     @@:
  3900.     dec eax
  3901.     mov ted_cur_y,eax
  3902.   pop eax
  3903.  
  3904.         cmp ted_drag_m,0
  3905.         je @f
  3906.                 call ted_sel_move
  3907.                 jmp .sel_move
  3908.         @@:
  3909.                 mov ted_drag_m,1
  3910.                 call ted_sel_start
  3911.         .sel_move:
  3912.         pop edx ecx ebx
  3913.         ret
  3914.  
  3915. ;input:
  3916. ; edi = pointer to tedit struct
  3917. align 4
  3918. ted_wnd_main_mouse_scroll:
  3919.         push eax ebx ecx
  3920.         mcall 37,7 ;¯à®ªàã⪠ ª®«¥á  ¬ëè¨
  3921.         cmp ax,0
  3922.         je .no_scroll
  3923.                 mov ecx,ted_scr_w
  3924.                 mov ebx,dword[ecx+sb_offs_position] ;copy old scroll position
  3925.                 and eax,0xffff
  3926.                 btr ax,15
  3927.                 jae @f
  3928.                         or eax,0xffff8000
  3929.                 @@:
  3930.                 add dword[ecx+sb_offs_position],eax
  3931.  
  3932.                 mov eax,[ecx+sb_offs_position]
  3933.                 cmp eax,[ecx+sb_offs_max_area]
  3934.                 jb @f
  3935.                         mov dword[ecx+sb_offs_position],ebx ;if scroll position out of range
  3936.                         jmp .no_scroll
  3937.                 @@:
  3938.                 stdcall ted_draw,edi
  3939.         .no_scroll:
  3940.         pop ecx ebx eax
  3941.         ret
  3942.  
  3943. align 4
  3944. proc ted_but_save_file, edit:dword, file:dword, f_name:dword
  3945.   pushad
  3946.   mov edi,dword[edit]
  3947.  
  3948.   stdcall ted_can_save,edi
  3949.   cmp al,0
  3950.   je .no_save
  3951.  
  3952.   mov ecx,ted_max_chars
  3953.   invoke mem.alloc,ecx
  3954.   push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3955.  
  3956.   mov edx,ted_tex
  3957.   xor ecx,ecx
  3958.   @@:
  3959.     call ted_iterat_next
  3960.     cmp edx,ted_tex_1
  3961.     jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
  3962.     mov bl,[edx]
  3963.     mov byte[eax],bl
  3964.     inc eax
  3965.     inc ecx
  3966.     jmp @b
  3967.   @@:
  3968.  
  3969.   cmp ecx,0
  3970.   je @f
  3971.     mov ebx,dword[file]
  3972.     pop eax ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3973.     mov dword[ebx+16],eax
  3974.     push eax ;®¡à â­® § ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3975.     mov eax,70
  3976.     mov dword[ebx], 2
  3977.     mov dword[ebx+4], 0
  3978.     mov dword[ebx+8], 0
  3979.     mov dword[ebx+12], ecx
  3980.     mov  byte[ebx+20], 0
  3981.     push dword[f_name]
  3982.     pop dword[ebx+21]
  3983.     int 0x40
  3984.  
  3985.     mov ted_err_save,al
  3986.  
  3987.     cmp eax,0
  3988.     je .no_msg
  3989. ;    cmp eax,6
  3990. ;    je @f
  3991.       cmp ax,10
  3992.       jl .zifra_0_9
  3993.         mov al,'?'
  3994.         sub ax,48
  3995.       .zifra_0_9:
  3996.       add ax,48
  3997. cmp ted_fun_save_err,0
  3998. je @f
  3999. call ted_fun_save_err
  4000.       jmp @f
  4001.     .no_msg:
  4002.     m2m ted_tim_ls,ted_tim_ch
  4003.   @@:
  4004.  
  4005.   pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4006.   invoke mem.free,ecx
  4007.   .no_save:
  4008.   popad
  4009.   ret
  4010. endp
  4011. }