Subversion Repositories Kolibri OS

Rev

Rev 7497 | Rev 7576 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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