Subversion Repositories Kolibri OS

Rev

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

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