Subversion Repositories Kolibri OS

Rev

Rev 3903 | Blame | Last modification | View Log | Download | RSS feed

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