Subversion Repositories Kolibri OS

Rev

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

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