Subversion Repositories Kolibri OS

Rev

Rev 6086 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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