Subversion Repositories Kolibri OS

Rev

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

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