Subversion Repositories Kolibri OS

Rev

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

  1. ; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
  2. ; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
  3. ; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 19.02.2016 IgorA
  4. ; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
  5.  
  6. ;input:
  7. ; edi = pointer to tedit struct
  8. ; reg = index
  9. ;output:
  10. ; reg = pointer to 'tex' struct
  11. macro ConvertIndexToPointer reg {
  12.         imul reg,sizeof.symbol
  13.         add reg,ted_tex
  14. }
  15.  
  16. ;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
  17. macro ColToIndexOffset ind_reg,out_reg {
  18.         mov out_reg,ind_reg
  19.         imul out_reg,sizeof.TexColViv
  20.         add out_reg,ted_key_words_data
  21. }
  22.  
  23. macro use_text_edit
  24. {
  25. TED_PANEL_NULL   equ 0 ;­¥â ®âªàë⮩ ¯ ­¥«¨
  26. TED_PANEL_FIND   equ 1 ;¯ ­¥«ì ¯®¨áª 
  27. TED_PANEL_SYNTAX equ 2 ;¯ ­¥«ì ¢ë¡®à  ä ©«®¢ ¯®¤á¢¥âª¨
  28. TED_PANEL_WIDTH  equ 150 ;è¨à¨­  ¯ ­¥«¨
  29.  
  30. TED_LINES_IN_NEW_FILE equ 30 ;ç¨á«® áâப ¢ ­®¢®¬ ä ©«¥
  31. MAX_COLOR_WORD_LEN equ 40
  32. ;------------------------------------------------------------------------------
  33. struct TexSelect
  34.         x0 dd ?
  35.         y0 dd ?
  36.         x1 dd ?
  37.         y1 dd ?
  38. ends
  39.  
  40. struct TexColViv
  41.         Text  rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨
  42.         f1    dd 0 ; á¯à ¢ª  ¯® á«®¢ã
  43.         flags db ? ; f1+4 ä« £¨ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ¢ë¤¥«¥­¨¨
  44.         endc  db ? ; f1+5 ᨬ¢®« ª®­æ  ¢ë¤¥«¥­¨ï (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
  45.         escc  db ? ; f1+6 íªà ­¨àãî騩 ᨬ¢®« (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
  46.         color db ? ; f1+7 ­®¬¥à 梥â 
  47. ends
  48.  
  49. struct symbol
  50.         c db ?    ;  +0 ᨬ¢®«
  51.         col db ?  ;  +1 梥â
  52.         perv dd ? ;  +2
  53.         next dd ? ;  +6 㪠§ â¥«¨
  54.         tc dd ?   ; +10 ¢à¥¬. ᮧ¤ ­¨ï
  55.         td dd ?   ; +14 ¢à¥¬. 㤠«¥­¨ï
  56. ends
  57. ;------------------------------------------------------------------------------
  58.  
  59. ted_symbol_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.         .loop_b:
  1258.                 cmp ecx,ted_tex_end
  1259.                 jge .end_f
  1260.                 cmp dword[ecx+10],0
  1261.                 jne @f
  1262.                         cmp dword[ecx+14],0
  1263.                         je .loop_e
  1264.                 @@:
  1265.                 add ecx,sizeof.symbol
  1266.                 jmp .loop_b
  1267. align 4
  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 uses ecx edx edi, edit:dword, del_opt:dword
  1401.         mov edi,dword[edit]
  1402.         mov ebx,dword[del_opt]
  1403.  
  1404.         xor cl,cl
  1405.         test ebx,ted_opt_ed_move_cursor
  1406.         jz @f
  1407.                 call ted_cur_move_left
  1408.                 cmp dl,0
  1409.                 je .no_del
  1410.         @@:
  1411.         call ted_get_pos_by_cursor
  1412.         cmp ted_gp_opt,1
  1413.         je .no_del
  1414.                 test ebx,ted_opt_ed_change_time
  1415.                 jz @f
  1416.                         inc ted_tim_ch
  1417.                 @@:
  1418.                 m2m dword[edx+14], ted_tim_ch
  1419.                 mov cl,1
  1420.         .no_del:
  1421.         mov bl,cl
  1422.         ret
  1423. endp
  1424.  
  1425. ;input:
  1426. ; edi = pointer to tedit struct
  1427. ;output:
  1428. ; al = 1 if delete
  1429. ;description:
  1430. ; ”ã­ªæ¨ï 㤠«ï¥â ¢ë¤¥«¥­­ë© ⥪áâ
  1431. align 4
  1432. proc ted_sel_text_del uses ebx ecx edx esi, del_opt:dword
  1433.         call ted_is_select
  1434.         cmp al,0
  1435.         je .end_f
  1436.                 call ted_sel_normalize
  1437.  
  1438.                 mov esi,ted_seln_x1
  1439.                 mov ecx,ted_seln_y1
  1440.                 call ted_get_pos_by_coords
  1441.                 mov ebx,edx
  1442.  
  1443.                 mov esi,ted_seln_x0
  1444.                 mov ecx,ted_seln_y0
  1445.                 call ted_get_pos_by_coords
  1446.  
  1447.                 test dword[del_opt],ted_opt_ed_change_time
  1448.                 jz @f
  1449.                         inc ted_tim_ch
  1450.                 @@:
  1451.                 cmp edx,ted_tex
  1452.                 je @f
  1453.                 cmp edx,ebx ;if(i==te)break;
  1454.                 je @f
  1455.                         m2m dword[edx+14],ted_tim_ch
  1456.                         mov esi,ted_opt_ed_change_time
  1457.                         not esi
  1458.                         and dword[del_opt],esi ;n_tim=false;
  1459.                         call ted_iterat_next
  1460.                         jmp @b
  1461. align 4
  1462.                 @@:
  1463.                 test dword[del_opt],ted_opt_ed_change_time
  1464.                 jz @f
  1465.                         dec ted_tim_ch
  1466.                         xor al,al
  1467.                 @@:
  1468.                 test dword[del_opt],ted_opt_ed_change_time
  1469.                 jnz @f
  1470.                         mov ecx,ted_seln_x0
  1471.                         mov edx,ted_seln_y0
  1472.                         call ted_go_to_pos
  1473.                         mov ted_sel_x0,0
  1474.                         mov ted_sel_y0,0
  1475.                         mov ted_sel_x1,0
  1476.                         mov ted_sel_y1,0
  1477.                 @@:
  1478.         .end_f:
  1479.         ret
  1480. endp
  1481.  
  1482.  
  1483. ;input:
  1484. ; eax = pointer to begin select
  1485. ; ebx = pointer to end select
  1486. ; edi = pointer to tedit struct
  1487. align 4
  1488. ted_revers:
  1489.         cmp eax,ebx
  1490.         jne @f
  1491.                 ret
  1492.         @@:
  1493.  
  1494.         push ecx edx
  1495.  
  1496.         mov edx,ted_tex_1
  1497.         cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
  1498.         jne @f
  1499.                 call ted_get_text_perv_pos
  1500.                 mov ebx,edx
  1501.         @@:
  1502.  
  1503.         push esi
  1504.                 mov edx,[eax+2] ; *** edx = tex[p0].perv ***
  1505.                 ConvertIndexToPointer edx
  1506.                 add edx,6
  1507.                 mov ecx,[edx] ;tmp = tex[tex[p0].perv].next;
  1508.  
  1509.                 mov esi,[ebx+6] ; *** esi = tex[p1].next ***
  1510.                 ConvertIndexToPointer esi
  1511.                 add esi,2
  1512.                 m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv;
  1513.  
  1514.                 mov [esi],ecx ;tex[tex[p1].next].perv = tmp;
  1515.         pop esi
  1516.  
  1517.         mov ecx,[eax+2] ;tmp = tex[p0].perv;
  1518.         m2m dword[eax+2],dword[ebx+6] ;tex[p0].perv = tex[p1].next;
  1519.         mov [ebx+6],ecx ;tex[p1].next = tmp;
  1520.  
  1521.         mov edx,eax ;i=p0;
  1522.         @@:
  1523.                 mov ecx,[edx+6] ;tmp = tex[i].next;
  1524.                 m2m dword[edx+6],dword[edx+2] ;tex[i].next = tex[i].perv;
  1525.                 mov [edx+2],ecx ;tex[i].perv = tmp;
  1526.                 cmp edx,ebx ;if(i==p1)break;
  1527.                 je @f
  1528. ; ---
  1529. ;cmp edx,ted_tex
  1530. ;je @f
  1531. ; ---
  1532.                 mov edx,ecx ;i = tmp;
  1533.                 ConvertIndexToPointer edx
  1534.                 jmp @b
  1535.         @@:
  1536.         pop edx ecx
  1537.         call ted_text_colored
  1538.         ret
  1539.  
  1540.  
  1541. ;input:
  1542. ; edi = pointer to tedit struct
  1543. ;output:
  1544. ; dl = 0 not move
  1545. ; dl = 2 if move up
  1546. ; dl = 8 if scroll move up
  1547. align 4
  1548. ted_cur_move_up:
  1549.   cmp ted_cur_y,0
  1550.   je @f
  1551.     dec ted_cur_y
  1552.     mov dl,2
  1553.     ret
  1554.   @@:
  1555.   push eax
  1556.   mov eax,ted_scr_w
  1557.   cmp dword[eax+sb_offs_position],0
  1558.   je @f
  1559.     dec dword[eax+sb_offs_position]
  1560.     mov dl,8
  1561.     jmp .ret_f
  1562.   @@:
  1563.   mov dl,0
  1564.   .ret_f:
  1565.   pop eax
  1566.   ret
  1567.  
  1568. ;input:
  1569. ; edi = pointer to tedit struct
  1570. ;output:
  1571. ; dl = 0 not move
  1572. ; dl = 2 if move down
  1573. ; dl = 8 if scroll move down
  1574. align 4
  1575. ted_cur_move_down:
  1576.   push eax ebx
  1577.   mov ebx,ted_scr_w
  1578.   mov dl,0
  1579.   mov eax,dword[ebx+sb_offs_cur_area]
  1580.   dec eax
  1581.   cmp ted_cur_y,eax
  1582.   jge @f
  1583.     inc ted_cur_y
  1584.     mov dl,2
  1585.     jmp .ret_f
  1586.   @@:
  1587.   mov eax,ted_cur_y
  1588.   add eax,dword[ebx+sb_offs_position]
  1589.   inc eax
  1590.   cmp dword[ebx+sb_offs_max_area],eax
  1591.   jle @f
  1592.     inc dword[ebx+sb_offs_position]
  1593.     mov dl,8
  1594.   @@:
  1595.   .ret_f:
  1596.   pop ebx eax
  1597.   ret
  1598.  
  1599.  
  1600. ;input:
  1601. ; edi = pointer to tedit struct
  1602. ;output:
  1603. ; dl = 0 not move
  1604. ; dl = 1 if move up
  1605. align 4
  1606. ted_cur_move_page_up:
  1607.   push eax ebx
  1608.   mov ebx,ted_scr_w
  1609.   mov eax,dword[ebx+sb_offs_cur_area]
  1610.   xor dl,dl
  1611.   cmp eax,dword[ebx+sb_offs_position]
  1612.   jg @f
  1613.     sub dword[ebx+sb_offs_position],eax
  1614.     mov dl,1
  1615.   @@:
  1616.   cmp dword[ebx+sb_offs_position],0
  1617.   je @f
  1618.   cmp dl,1
  1619.   je @f
  1620.     mov dword[ebx+sb_offs_position],0
  1621.     mov dl,1
  1622.   @@:
  1623.   pop ebx eax
  1624.   ret
  1625.  
  1626. ;input:
  1627. ; edi = pointer to tedit struct
  1628. align 4
  1629. ted_cur_move_page_down:
  1630.         push eax ebx ecx
  1631.         mov ecx,ted_scr_w
  1632.  
  1633.         xor dl,dl
  1634.         mov eax,dword[ecx+sb_offs_max_area]
  1635.         sub eax,dword[ecx+sb_offs_cur_area]
  1636.         cmp dword[ecx+sb_offs_position],eax
  1637.         jge @f
  1638.                 mov ebx,dword[ecx+sb_offs_cur_area]
  1639.                 add dword[ecx+sb_offs_position],ebx
  1640.                 mov dl,1
  1641.                 mov dword[ecx+sb_offs_redraw],1
  1642.                 cmp dword[ecx+sb_offs_position],eax
  1643.                 jle @f
  1644.                         mov dword[ecx+sb_offs_position],eax
  1645.         @@:
  1646.         pop ecx ebx eax
  1647.         ret
  1648.  
  1649. ;input:
  1650. ; edi = pointer to tedit struct
  1651. ;output:
  1652. ; dl = 0 not move
  1653. ; dl = 1 if move left
  1654. ; dl = 3 if move left and up
  1655. ; dl = 8 if scroll move up
  1656. align 4
  1657. ted_cur_move_left:
  1658.         cmp ted_cur_x,0
  1659.         je @f
  1660.                 dec ted_cur_x
  1661.                 mov dl,1
  1662.                 ret
  1663.         @@:
  1664.         push eax
  1665.         mov eax,ted_scr_h
  1666.         cmp dword[eax+sb_offs_position],0
  1667.         je @f
  1668.                 dec dword[eax+sb_offs_position]
  1669.                 mov dl,8
  1670.                 jmp .ret_f
  1671.         @@:
  1672.         cmp ted_cur_y,0
  1673.         jne @f
  1674.                 mov eax,ted_scr_w
  1675.                 mov dl,0
  1676.                 cmp dword[eax+sb_offs_position],0
  1677.                 je .ret_f
  1678.                         dec dword[eax+sb_offs_position]
  1679.                         call ted_scroll_set_redraw
  1680.                         call ted_cur_move_x_last_char
  1681.                         mov dl,8
  1682.                         jmp .ret_f
  1683.         @@:
  1684.         cmp ted_cur_y,0
  1685.         je @f
  1686.                 dec ted_cur_y
  1687.                 call ted_cur_move_x_last_char
  1688.                 cmp dl,8
  1689.                 je .ret_f
  1690.                 mov dl,3
  1691.                 jmp .ret_f
  1692.         @@:
  1693.         mov dl,0
  1694.         .ret_f:
  1695.         pop eax
  1696.         ret
  1697.  
  1698. ;input:
  1699. ; edi = pointer to tedit struct
  1700. align 4
  1701. ted_cur_move_right:
  1702.         push eax ebx
  1703.         mov eax,ted_scr_h
  1704.         xor dl,dl
  1705.         mov ebx,dword[eax+sb_offs_cur_area]
  1706.         cmp ted_cur_x,ebx
  1707.         jge @f
  1708.                 inc ted_cur_x
  1709.                 mov dl,1
  1710.                 jmp .ret_f
  1711.         @@:
  1712.                 inc dword[eax+sb_offs_position]
  1713.                 mov dl,8
  1714.         .ret_f:
  1715.         pop ebx eax
  1716.         ret
  1717.  
  1718. ;input:
  1719. ; edi = pointer to tedit struct
  1720. align 4
  1721. ted_cur_move_x_last_char:
  1722. ;[hScr.position]
  1723. ;[hScr.cur_area]
  1724. ;dl-???
  1725.   push eax ebx ecx
  1726.   mov eax,ted_cur_y
  1727.   mov ecx,ted_scr_w
  1728.   add eax,dword[ecx+sb_offs_position]
  1729.   call ted_strlen
  1730.   xor dl,dl
  1731.  
  1732.   mov ecx,ted_scr_h
  1733.   cmp ebx,dword[ecx+sb_offs_position]
  1734.   jge @f
  1735.     mov dl,8
  1736.     mov dword[ecx+sb_offs_position],ebx
  1737.   @@:
  1738.   sub ebx,dword[ecx+sb_offs_position]
  1739.  
  1740.   cmp ebx,dword[ecx+sb_offs_cur_area]
  1741.   jle @f ; b---[---]---e
  1742.     add dword[ecx+sb_offs_position],ebx
  1743.     mov ebx,dword[ecx+sb_offs_cur_area]
  1744.     sub dword[ecx+sb_offs_position],ebx
  1745.     mov dl,8
  1746.   @@:
  1747.   mov ted_cur_x,ebx
  1748.   pop ecx ebx eax
  1749.   ret
  1750.  
  1751. ;input:
  1752. ; edi = pointer to tedit struct
  1753. ;output:
  1754. ; dl = 0 not move
  1755. ; dl = 1 move cursor
  1756. ; dl = 8 move cursor and scroll
  1757. align 4
  1758. ted_cur_move_x_first_char:
  1759.         xor dl,dl
  1760.         cmp ted_cur_x,0
  1761.         je @f
  1762.                 mov ted_cur_x,0
  1763.                 mov dl,1
  1764.         @@:
  1765.         push eax
  1766.         mov eax,ted_scr_h
  1767.         cmp dword[eax+sb_offs_position],0
  1768.         je @f
  1769.                 mov dword[eax+sb_offs_position],0
  1770.                 mov dl,8
  1771.         @@:
  1772.         pop eax
  1773.         ret
  1774.  
  1775. ;input:
  1776. ; edx = pointer to symbol struct
  1777. ; edi = pointer to tedit struct
  1778. ;output:
  1779. ; eax = array index
  1780. align 4
  1781. ted_get_text_arr_index:
  1782.         push ecx edx
  1783.                 mov eax,edx
  1784.                 sub eax,ted_tex
  1785.                 xor edx,edx
  1786.                 mov ecx,sizeof.symbol
  1787.                 div ecx
  1788.         pop edx ecx
  1789.         ret
  1790.  
  1791. ;input:
  1792. ; edx = pointer to symbol struct
  1793. ; edi = pointer to tedit struct
  1794. ;output:
  1795. ; edx = pointer to 'perv' struct
  1796. align 4
  1797. ted_get_text_perv_pos:
  1798.         mov edx,dword[edx+2]
  1799.         imul edx,sizeof.symbol
  1800.         add edx,ted_tex
  1801.         ret
  1802.  
  1803. ;input:
  1804. ; edx = pointer to symbol struct
  1805. ;output:
  1806. ; edx = pointer to 'next' symbol struct
  1807. align 4
  1808. ted_get_text_next_pos:
  1809.         mov edx,dword[edx+6]
  1810.         imul edx,sizeof.symbol
  1811.         add edx,ted_tex
  1812.         ret
  1813.  
  1814. ;input:
  1815. ; edi = pointer to tedit struct
  1816. ;output:
  1817. ; edx = symbol under cursor
  1818. ; ted_gp_opt = 1,2
  1819. ; edx = tex[1].perv if error
  1820. ; ted_gp_opt = 0
  1821. align 4
  1822. ted_get_pos_by_cursor:
  1823.         push eax ecx esi
  1824.                 mov esi,ted_cur_x
  1825.                 mov eax,ted_scr_h
  1826.                 add esi,dword[eax+sb_offs_position]
  1827.                 mov ecx,ted_cur_y
  1828.                 mov eax,ted_scr_w
  1829.                 add ecx,dword[eax+sb_offs_position]
  1830.                 call ted_get_pos_by_coords
  1831.         pop esi ecx eax
  1832.         ret
  1833.  
  1834. ;input:
  1835. ; esi = XPos
  1836. ; ecx = YPos
  1837. ; edi = pointer to tedit struct
  1838. ;output:
  1839. ; edx = symbol under cursor
  1840. ; ted_gp_opt = 1 if found text line
  1841. ; ted_gp_opt = 2 if found text line and column
  1842. ; edx = tex[1] if error
  1843. ; ted_gp_opt = 0 if text no found
  1844. align 4
  1845. ted_get_pos_by_coords:
  1846.   push eax ;Row
  1847.   push ebx ;Col
  1848.  
  1849.   xor eax,eax
  1850.   xor ebx,ebx
  1851.   mov ted_gp_opt,0
  1852.   mov edx,ted_tex
  1853.   @@:
  1854.     call ted_iterat_next
  1855.     cmp edx,ted_tex_1
  1856.     jle @f
  1857.     cmp ebx,esi
  1858.     jne .u1_0 ;Col <> ted_cur_x
  1859.       mov ted_gp_opt,1
  1860.       cmp eax,ecx
  1861.       jge @f ; Row >= ted_cur_y
  1862.     .u1_0:
  1863.     mov ted_gp_opt,0
  1864.     inc ebx
  1865.     cmp byte [edx],13
  1866.     jne @b
  1867.     cmp eax,ecx
  1868.     jge @f ; Row >= ted_cur_y
  1869.     inc eax
  1870.     xor ebx,ebx
  1871.     jmp @b
  1872.   @@:
  1873.   cmp eax,ecx
  1874.   jne @f ; Row = ted_cur_y
  1875.     inc ted_gp_opt
  1876.   @@:
  1877.   cmp ted_gp_opt,0
  1878.   jne @f
  1879.     mov edx,ted_tex_1
  1880.     ;call ted_get_text_perv_pos
  1881.   @@:
  1882.   pop ebx eax
  1883.   ret
  1884.  
  1885.  
  1886. ;input:
  1887. ; eax = Row
  1888. ; edi = pointer to tedit struct
  1889. ;output:
  1890. ; ebx = str len
  1891. align 4
  1892. ted_strlen:
  1893.   push edx ecx
  1894.   ;ecx = Row, from cycle
  1895.  
  1896.   xor ebx,ebx
  1897.   xor ecx,ecx
  1898.   mov edx,ted_tex
  1899.   @@:
  1900.     call ted_iterat_next
  1901.     cmp edx,ted_tex_1
  1902.     jle @f
  1903.     inc ebx
  1904.     cmp byte [edx],13
  1905.     jne @b
  1906.     dec ebx ;lenght minus 1 sumbol to paragraph
  1907.     cmp eax,ecx
  1908.     je @f
  1909.     xor ebx,ebx
  1910.     inc ecx
  1911.     jmp @b
  1912.   @@:
  1913.  
  1914.   cmp eax,ecx
  1915.   je @f
  1916.     xor ebx,ebx
  1917.   @@:
  1918.  
  1919.   pop ecx edx
  1920.   ret
  1921.  
  1922.  
  1923. ;input:
  1924. ; edx = symbol position
  1925. ; edi = pointer to tedit struct
  1926. ;output:
  1927. ; eax = number of line
  1928. ; ebx = symbol position in line
  1929. align 4
  1930. ted_get_text_coords:
  1931.   push edx
  1932.   xor eax,eax
  1933.   xor ebx,ebx
  1934.   @@:
  1935.     call ted_iterat_perv
  1936.  
  1937.     cmp eax,0
  1938.     jne .no_col_mov
  1939.     inc ebx
  1940.     .no_col_mov:
  1941.  
  1942.     cmp edx,ted_tex_1
  1943.     jle @f
  1944.     cmp byte [edx],13
  1945.     jne @b
  1946.     inc eax
  1947.     jmp @b
  1948.   @@:
  1949.   dec ebx
  1950.   pop edx
  1951.   ret
  1952.  
  1953. ;input:
  1954. ; edi = pointer to tedit struct
  1955. ;output:
  1956. ; eax = num lines
  1957. align 4
  1958. ted_get_num_lines:
  1959.         push edx
  1960.         mov eax,1
  1961.         mov edx,ted_tex
  1962.         @@:
  1963.                 call ted_iterat_next
  1964.                 cmp edx,ted_tex_1
  1965.                 jle @f
  1966.                 cmp byte [edx],13
  1967.                 jne @b
  1968.                 inc eax
  1969.                 jmp @b
  1970.         @@:
  1971. ;...
  1972. ;dec eax
  1973.         pop edx
  1974.         ret
  1975.  
  1976.  
  1977. ;input:
  1978. ; edi = pointer to tedit struct
  1979. ;description:
  1980. ; ®â¬¥­ï¥â ®â¬¥­¥­­ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥­¥­¨¥¬ ¤®ªã¬¥­â 
  1981. align 4
  1982. proc ted_set_undo
  1983.         mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  1984.         cmp ted_tim_undo,1
  1985.         jl .no_work
  1986.  
  1987.         push eax ebx edx
  1988.         mov edx,ted_tex
  1989.         call ted_get_text_next_pos ;long i=tex[0].next;
  1990.         mov eax,ted_tim_undo
  1991.         sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
  1992.         mov eax,ted_tim_ch
  1993.         cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
  1994.         jle @f
  1995.                 mov ted_tim_ls,0
  1996.         @@:
  1997.                 cmp edx,ted_tex_1
  1998.                 jle @f
  1999.  
  2000.                 ;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  2001.                 cmp [edx+10],eax
  2002.                 jle .no_u1
  2003.                         mov dword [edx+10],0
  2004.                         mov dword [edx+14],0
  2005.  
  2006.                         mov ebx,[edx+2]
  2007.                         imul ebx,sizeof.symbol
  2008.                         add ebx,ted_tex ;ebx=tex[i].perv
  2009.                         m2m dword [ebx+6],dword [edx+6] ;tex[tex[i].perv].next=tex[i].next;
  2010.  
  2011.                         mov ebx,[edx+6]
  2012.                         imul ebx,sizeof.symbol
  2013.                         add ebx,ted_tex ;ebx=tex[i].next
  2014.                         m2m dword [ebx+2],dword [edx+2] ;tex[tex[i].next].perv=tex[i].perv;
  2015.  
  2016.                         cmp ted_ptr_free_symb,edx
  2017.                         jle .no_cor_free
  2018.                                 mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
  2019.                         .no_cor_free:
  2020.                         mov edx,ebx ;®¯â¨¬¨§¨à㥬 ¯® ᪮à®á⨠(edx ¯®á«¥ ¢ë§®¢  ted_get_text_next_pos ¡ã¤¥â à ¢¥­ ebx)
  2021.                         jmp @b
  2022.                 .no_u1:
  2023.  
  2024.                 ;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  2025.                 cmp [edx+14],eax
  2026.                 jle .no_u2
  2027.                         mov dword [edx+14],0
  2028.                 .no_u2:
  2029.  
  2030.                 call ted_get_text_next_pos
  2031.                 jmp @b
  2032.         @@:
  2033.         mov ted_tim_undo,0
  2034.         mov eax,ted_tim_co
  2035.         cmp ted_tim_ch,eax
  2036.         jge @f
  2037.                 mov ted_tim_co,0
  2038.         @@:
  2039.         pop edx ebx eax
  2040.         .no_work:
  2041.         ret
  2042. endp
  2043.  
  2044. ;input:
  2045. ; ecx = Col
  2046. ; edx = Row
  2047. ; edi = pointer to tedit struct
  2048. align 4
  2049. ted_go_to_pos:
  2050.         push eax
  2051.         mov eax,ted_scr_w
  2052.         mov ted_cur_x,ecx
  2053.         sub edx,dword[eax+sb_offs_position]
  2054.  
  2055.         cmp edx,dword[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
  2056.         jl @f
  2057.                 push ebx
  2058.                 mov ebx,edx
  2059.                 sub ebx,dword[eax+sb_offs_cur_area]
  2060.                 inc ebx
  2061.                 add dword[eax+sb_offs_position],ebx
  2062.                 sub edx,ebx
  2063.                 pop ebx
  2064.                 ; ??? redrav
  2065.         @@:
  2066.         mov ted_cur_y,edx
  2067.         pop eax
  2068.         ret
  2069.  
  2070. ;input:
  2071. ; edi = pointer to tedit struct
  2072. align 4
  2073. ted_text_colored:
  2074.   push eax edx
  2075.   mov eax,ted_tim_ch
  2076.   sub eax,ted_tim_undo
  2077.   mov ted_tim_co,eax
  2078.   mov edx,ted_tex
  2079.   @@:
  2080.     call ted_iterat_next
  2081.     cmp edx,ted_tex_1
  2082.     jle @f
  2083.     mov byte[edx+1],0
  2084.     jmp @b
  2085.   @@:
  2086.  
  2087.   cmp ted_key_words_count,1
  2088.   jl .no_colors
  2089.   mov edx,ted_tex
  2090.   @@:
  2091.     call ted_text_find_sel_color
  2092.     cmp edx,ted_tex_1
  2093.     jle .no_colors
  2094.     jmp @b
  2095.   .no_colors:
  2096.   pop edx eax
  2097.   ret
  2098.  
  2099.  
  2100. ;input:
  2101. ; edx = pointer to start symbol
  2102. ; edi = pointer to tedit struct
  2103. ;output:
  2104. ; edx = pointer to next symbol
  2105. ;description:
  2106. ; ”ã­ªæ¨ï ¤«ï ¯®¨áª  ¨ ¢ë¤¥«¥­¨ï ¯®¤á¢¥ç¥­ëå á«®¢
  2107. align 4
  2108. proc ted_text_find_sel_color uses eax ebx ecx esi
  2109. locals
  2110.         begPos dd ? ;­ ç «ì­ ï ¯®§¨æ¨ï
  2111.         endPos dd ? ;ª®­¥ç­ ï ¯®§¨æ¨ï
  2112.         find db ? ;­ ©¤¥­® / ­¥ ­ ©¤¥­®
  2113.         f_color db ? ;¨­¤¥ªá æ¢¥â  ­ ©¤¥­®£® á«®¢ 
  2114. endl
  2115. ;eax = word_n ⥪ã騩 ­®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢  ¢ ᯨ᪥
  2116. ;ebx = ¤«ï à §­ëå 楫¥©
  2117. ;ecx = l_pos ¯®á«¥¤­¨© ­®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢  ¢ ᯨ᪥
  2118. ;esi = ¤«ï à §­ëå 楫¥©, ­®¬¥à ¯à®¢¥à塞®£® ᨬ¢®«  ¢ á«®¢¥
  2119.         mov dword[begPos],1
  2120.         mov dword[endPos],1
  2121.         mov byte[find],0
  2122.         mov byte[f_color],1
  2123.         @@:
  2124.                 call ted_iterat_next
  2125.                 cmp edx,ted_tex_1
  2126.                 jle @f
  2127.  
  2128.                 xor eax,eax
  2129.                 mov al,byte[edx]
  2130.                 shl ax,2 ;eax*=4
  2131.                 add eax,ted_arr_key_pos
  2132.                 mov eax,dword[eax]
  2133.                 cmp eax,0
  2134.                 jl @b ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
  2135.  
  2136.                 mov ecx,eax
  2137.                 ;while(l_pos<ted_key_words_count && Col[l_pos].Text[0]==Col[word_n].Text[0])
  2138.                 .wh_1b:
  2139.                         cmp ecx,ted_key_words_count
  2140.                         jge .wh_1e
  2141.                         ColToIndexOffset ecx,esi
  2142.                         mov bl,byte[esi]
  2143.                         ColToIndexOffset eax,esi
  2144.                         cmp bl,byte[esi]
  2145.                         jne .wh_1e
  2146.                                 inc ecx
  2147.                         jmp .wh_1b
  2148.                 .wh_1e:
  2149.  
  2150.                 mov dword[begPos],edx ;bP=i;
  2151.                 mov esi,1
  2152. align 4
  2153.                 .wh_2b: ;while(1){
  2154.                 call ted_iterat_next
  2155.  
  2156.                 ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
  2157.                 .wh_3b:
  2158.                         cmp ecx,eax
  2159.                         jle .wh_3e
  2160.                         dec ecx
  2161.                         ColToIndexOffset ecx,ebx
  2162.                         inc ecx
  2163.                         ;cmp byte[ebx+esi],byte[edx]
  2164.                         mov bl,byte[ebx+esi]
  2165.                         cmp bl,byte[edx]
  2166.                         je .wh_3e
  2167.                                 dec ecx
  2168.                         jmp .wh_3b
  2169.                 .wh_3e:
  2170.  
  2171.                 ColToIndexOffset eax,ebx
  2172.                 cmp byte[ebx+esi],0
  2173.                 jne .if_0 ;if(Col[word_n].Text[pos]==0){
  2174.                 mov dword[endPos],edx ;eP=i;
  2175.                 ColToIndexOffset eax,ebx
  2176.                 mov bl,byte[ebx+MAX_COLOR_WORD_LEN+7]
  2177.                 mov byte[f_color],bl ;f_color=Col[word_n].color;
  2178.  
  2179.                 mov byte[find],1
  2180.                 ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
  2181.                 mov bl,byte[ebx+MAX_COLOR_WORD_LEN+4]
  2182.                 cmp bl,0 ;if(Col[word_n].wwo)
  2183.                 je .if_2n
  2184.                         push edx
  2185.                         mov edx,dword[begPos]
  2186.                         call ted_iterat_perv
  2187.  
  2188.                         btr bx,0 ;1-1
  2189.                         jae .if_3e ;if(Col[word_n].wwo&1)
  2190.                                 ;u1= !(isalnum(cont_s)||cont_s=='_')
  2191.                                 call isalnum
  2192.                                 jae .if_3e
  2193.                                         mov byte[find],0
  2194.                                         jmp .if_4e
  2195.                         .if_3e:
  2196.  
  2197.                         btr bx,3 ;4-1
  2198.                         jae .if_4e ;if(Col[word_n].wwo&8)
  2199.                                 ;u1= !isalpha(cont_s);
  2200.                                 call isalpha
  2201.                                 jae .if_4e
  2202.                                         mov byte[find],0
  2203.                         .if_4e:
  2204.  
  2205.                         mov edx,dword[endPos]
  2206.                         ;call ted_iterat_next
  2207.  
  2208.                         btr bx,1 ;2-1
  2209.                         jae .if_5e ;if(Col[word_n].wwo&2)
  2210.                                 ;u1= !(isalnum(cont_s)||cont_s=='_')
  2211.                                 call isalnum
  2212.                                 jae .if_5e
  2213.                                         mov byte[find],0
  2214.                                         jmp .if_6e
  2215.                         .if_5e:
  2216.  
  2217.                         btr bx,4 ;5-1
  2218.                         jae .if_6e ;if(Col[word_n].wwo&16)
  2219.                                 ;u1= !isalpha(cont_s);
  2220.                                 call isalpha
  2221.                                 jae .if_6e
  2222.                                         mov byte[find],0
  2223.                         .if_6e:
  2224.  
  2225.                         btr bx,2 ;3-1
  2226.                         jae .if_7e ;if(Col[word_n].wwo&4)
  2227.                                 ColToIndexOffset eax,ebx
  2228.                                 mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
  2229.                                 call ted_iterat_next_pos_char
  2230.                                 cmp edx,ted_tex_1
  2231.                                 jle .if_7e
  2232.                                         mov dword[endPos],edx
  2233.                         .if_7e:
  2234.  
  2235.                         pop edx
  2236.                 .if_2n:
  2237. ;if(i!=1){ // ­¥ ª®­¥æ ¤®ªã¬¥­â 
  2238. ;  cont_s=tex[eP].c;
  2239. ;  if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // ­¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
  2240. ;  if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ­¥ ç¨á«. ᨬ¢®«
  2241. ;  if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
  2242.  
  2243.                         cmp eax,ecx
  2244.                         je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç­® ¯®á«¥¤­¥¥
  2245.                 .if_0:
  2246.  
  2247.                 cmp edx,ted_tex_1
  2248.                 jle .wh_2e ;if(i==1) break;
  2249.  
  2250.                 ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
  2251.                 .wh_4b:
  2252.                 cmp ecx,eax
  2253.                 jle .wh_4e
  2254.                         ColToIndexOffset eax,ebx
  2255.                         ;cmp byte[ebx+esi],byte[edx]
  2256.                         mov bl,byte[ebx+esi]
  2257.                         cmp bl,byte[edx]
  2258.                         je .wh_4e
  2259.                                 inc eax
  2260.                         jmp .wh_4b
  2261.                 .wh_4e:
  2262.  
  2263.                 cmp eax,ecx
  2264.                 je .wh_2e;if(word_n==l_pos) break;
  2265.                         inc esi ;pos++;
  2266.                         jmp .wh_2b
  2267.                 .wh_2e:
  2268.  
  2269.                 cmp byte[find],1 ;if(fnd)break;
  2270.                 je @f
  2271.                         mov edx,dword[begPos];i=bP;
  2272.                 jmp @b
  2273.         @@:
  2274.  
  2275.         cmp byte[find],1
  2276.         jne .if_1e ;if(fnd){ // ¢ë¤¥«¥­¨¥ ­ ©¤¥­®£® ⥪áâ 
  2277.                 ;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
  2278.                 mov eax,dword[begPos]
  2279.                 mov bl,byte[f_color]
  2280.                 mov byte[eax+1],bl ;tex[bP].col=f_color;
  2281.                 mov eax,dword[endPos]
  2282.                 mov byte[eax+1],0xff ;tex[eP].col=255;
  2283.                 ;return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®­æ  ¢å®¦¤¥­¨ï
  2284.                 mov edx,dword[endPos]
  2285.                 call ted_get_text_perv_pos
  2286.                 jmp @f
  2287.         .if_1e:
  2288.                 mov edx,ted_tex
  2289.         @@:
  2290.  
  2291.         ret
  2292. endp
  2293.  
  2294. ;input:
  2295. ; edx = pointer to char (byte)
  2296. ;output:
  2297. ; cf=1 if symbol is...
  2298. align 4
  2299. 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
  2300. 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
  2301.  
  2302. ;output:
  2303. ; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ , æ¨äà  ¨«¨ '_'
  2304. align 4
  2305. isalnum:
  2306.         push eax ebx
  2307.         movzx eax,byte[edx] ;al=offset
  2308.         shr eax,3
  2309.         lea ebx,[tab_all_num]
  2310.         add ebx,eax
  2311.         movzx ax,byte[edx] ;al=bit
  2312.         and ax,111b
  2313.         bt word[ebx],ax
  2314.         pop ebx eax
  2315.         ret
  2316.  
  2317. ;output:
  2318. ; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢  ¨«¨ '_'
  2319. align 4
  2320. isalpha:
  2321.         push eax ebx
  2322.         movzx eax,byte[edx] ;al=offset
  2323.         shr eax,3
  2324.         lea ebx,[tab_alpha]
  2325.         add ebx,eax
  2326.         movzx ax,byte[edx] ;al=bit
  2327.         and ax,111b
  2328.         bt word[ebx],ax
  2329.         pop ebx eax
  2330.         ret
  2331.  
  2332. align 4
  2333. proc ted_show_help_f1 uses eax edx edi, edit:dword
  2334.         mov edi,dword[edit]
  2335.  
  2336.         call ted_get_pos_by_cursor
  2337.         push edx
  2338.                 call ted_iterat_next_color_tag
  2339.                 mov eax,edx
  2340.         pop edx
  2341.         call ted_iterat_perv_color_tag
  2342.  
  2343.         cmp eax,ted_tex
  2344.         jle @f
  2345.         cmp edx,ted_tex_1
  2346.         jle @f
  2347.                 stdcall ted_find_help_id,eax
  2348.         @@:
  2349.         ;call ted_draw_main_cursor
  2350.         call ted_draw_help_f1
  2351.         ret
  2352. endp
  2353.  
  2354. ;input:
  2355. ; edx = position begin 'symbol' struct
  2356. ; edi = pointer to tedit struct
  2357. ; end_pos = position end 'symbol' struct
  2358. align 4
  2359. proc ted_find_help_id, end_pos:dword
  2360. ; ecx = word_n
  2361. ; ebx = l_pos
  2362.   mov ted_help_id,-1
  2363.  
  2364.   push ebx ecx
  2365.     xor ebx,ebx
  2366.     mov bl,byte[edx]
  2367.     shl bx,2 ;ebx*=4
  2368.     add ebx,ted_arr_key_pos
  2369.     mov ecx,dword[ebx]
  2370.     cmp ecx,0
  2371.     jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
  2372.       push esi eax
  2373.       mov ebx,ecx ;l_pos=word_n;
  2374.       ColToIndexOffset ecx,esi
  2375.       push cx
  2376.       mov cl,byte[esi]
  2377.       @@:
  2378.         cmp ebx,ted_key_words_count ;while(l_pos<ted_key_words_count)
  2379.         jge @f
  2380.         ;ColToIndexOffset ecx,esi
  2381.         ColToIndexOffset ebx,eax
  2382.         cmp cl,byte[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
  2383.         jne @f
  2384.           inc ebx ;l_pos++;
  2385.           jmp @b
  2386.       @@:
  2387.       pop cx
  2388.       call ted_iterat_next ;pos=1;
  2389.       mov esi,1
  2390.       @@:
  2391.         push dx
  2392.         push word[edx]
  2393.         pop dx
  2394.           .wh_0b:
  2395.             cmp ebx,ecx ;while(l_pos>word_n
  2396.             jle .wh_0e
  2397.             dec ebx
  2398.             ColToIndexOffset ebx,eax
  2399.             inc ebx
  2400.             cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
  2401.             je .wh_0e
  2402.               dec ebx ;l_pos--;
  2403.             jmp .wh_0b
  2404.           .wh_0e:
  2405.  
  2406.           .wh_1b:
  2407.             cmp ebx,ecx ;while(l_pos>word_n
  2408.             jle .wh_1e
  2409.             ColToIndexOffset ecx,eax
  2410.             cmp byte[eax+esi],dl
  2411.             je .wh_1e
  2412.               inc ecx ;word_n++;
  2413.             jmp .wh_1b
  2414.           .wh_1e:
  2415.         pop dx
  2416.  
  2417.         cmp ecx,ebx ;if(word_n==l_pos) break;
  2418.         je @f
  2419.         call ted_iterat_next ;pos++;
  2420.         cmp edx,dword[end_pos] ;for(...;i<strlen;...)
  2421.         je @f ;jge
  2422.         inc esi
  2423.         jmp @b
  2424.       @@:
  2425.       pop eax esi
  2426.  
  2427.       mov ted_help_id,ecx
  2428.       ;return word_n;
  2429.  
  2430.     .if_0e:
  2431.   pop ecx ebx
  2432.   ret
  2433. endp
  2434.  
  2435. ;output:
  2436. ; eax = ª®¤ ®è¨¡ª¨
  2437. ; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
  2438. align 4
  2439. proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
  2440.         mov edi,dword[edit]
  2441.  
  2442.         ; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ ***
  2443.         ;¯à®¡ã¥¬ ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ä ©«¥
  2444.         mov eax,70
  2445.         mov ebx,dword[file]
  2446.         mov dword[ebx], 5
  2447.         mov dword[ebx+4], 0
  2448.         mov dword[ebx+8], 0
  2449.         mov dword[ebx+12], 0
  2450.         m2m dword[ebx+16], ted_tex
  2451.         mov  byte[ebx+20], 0
  2452.         push dword[f_name]
  2453.         pop dword[ebx+21]
  2454.         int 0x40
  2455.         cmp eax,0
  2456.         je .end_0
  2457.                 mov edx,ted_max_chars
  2458.                 cmp eax,2 ;äã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë
  2459.                 je @f
  2460.                 jmp .ret_f
  2461.         .end_0:
  2462.         ;¯à®¢¥à塞 墠â¨â «¨ ¯ ¬ï⨠¤«ï § £à㧪¨ ä ©« 
  2463.         mov ecx,ted_max_chars
  2464.         sub ecx,2 ;ecx = ¬ ªá¨¬ «ì­®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë«  ¢ë¤¥«¥­  ¯ ¬ïâì
  2465.         mov edx,ted_tex
  2466.         mov edx,dword[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å
  2467.         cmp edx,ecx
  2468.         jl @f
  2469.                 ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫®
  2470.                 mov ecx,edx ;¯ ¬ïâì ­¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©« 
  2471.                 add ecx,2  ;¯ ¬ïâì ¤«ï á«ã¦¥¡­ëå ­ ç «ì­®£® ¨ ª®­¥ç­®£® ᨬ¢®«®¢
  2472.                 add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
  2473.                 mov ted_max_chars,ecx
  2474.                 imul ecx,sizeof.symbol
  2475.                 invoke mem.realloc, ted_tex,ecx
  2476.                 mov ted_tex,eax
  2477.                 mov ted_tex_1,eax
  2478.                 add ted_tex_1,sizeof.symbol
  2479.                 add eax,ecx
  2480.                 mov ted_tex_end,eax
  2481.                 mov ecx,ted_tex_1
  2482.                 add ecx,sizeof.symbol
  2483.                 mov ted_ptr_free_symb,ecx
  2484.         @@:
  2485.  
  2486.         ; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
  2487.         mov eax,70
  2488.         mov ebx,dword[file]
  2489.         mov dword[ebx], 0
  2490.         mov dword[ebx+4], 0
  2491.         mov dword[ebx+8], 0
  2492.         m2m dword[ebx+12], edx ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©«  (­¥ ¡®«ìè¥ ç¥¬ ted_max_chars)
  2493.         m2m dword[ebx+16], ted_tex
  2494.         mov  byte[ebx+20], 0
  2495.         push dword[f_name]
  2496.         pop dword[ebx+21]
  2497.         int 0x40
  2498.  
  2499.         cmp eax,0
  2500.         je @f
  2501.         cmp eax,6
  2502.         je @f
  2503.                 jmp .ret_f
  2504.         @@:
  2505.         cmp ebx,-1
  2506.         je .ret_f
  2507.                 ;if open file
  2508.                 call ted_on_open_file
  2509.         .ret_f:
  2510.         ret
  2511. endp
  2512.  
  2513. align 4
  2514. proc ted_but_select_word, edit:dword
  2515.         pushad
  2516.         mov edi,dword[edit]
  2517.  
  2518.         call ted_get_pos_by_cursor
  2519.         push edx
  2520.                 call ted_iterat_perv_color_tag
  2521.                 cmp edx,ted_tex_1
  2522.                 jle @f
  2523.                         call ted_get_text_coords
  2524.                         mov ted_sel_x0,ebx
  2525.                         mov ted_sel_y0,eax
  2526.                 @@:
  2527.         pop edx
  2528.         call ted_iterat_next_color_tag
  2529.         cmp edx,ted_tex_1
  2530.         jle @f
  2531.                 call ted_get_text_coords
  2532.                 mov ted_sel_x1,ebx
  2533.                 mov ted_sel_y1,eax
  2534.         @@:
  2535.  
  2536.         cmp ted_fun_draw_panel_buttons,0
  2537.         je @f
  2538.                 call ted_fun_draw_panel_buttons
  2539.         @@:
  2540.         stdcall ted_draw,edi
  2541.         popad
  2542.         ret
  2543. endp
  2544.  
  2545. align 4
  2546. proc ted_but_cut uses edi, edit:dword
  2547.         mov edi,dword[edit]
  2548.  
  2549.         stdcall ted_but_copy,edi
  2550.         call ted_set_undo
  2551.         stdcall ted_sel_text_del,ted_opt_ed_change_time
  2552.  
  2553.         cmp al,1
  2554.         jne @f
  2555.                 stdcall ted_draw,edi
  2556.                 cmp ted_fun_draw_panel_buttons,0
  2557.                 je @f
  2558.                         call ted_fun_draw_panel_buttons
  2559.         @@:
  2560.         ret
  2561. endp
  2562.  
  2563. ;output:
  2564. ; al = 1 if copy text
  2565. align 4
  2566. proc ted_but_copy, edit:dword
  2567.         pushad
  2568.         mov edi,dword[edit]
  2569.  
  2570.         call ted_is_select
  2571.         cmp al,0
  2572.         je .end_f ;if not selected text
  2573.         call ted_sel_normalize
  2574.  
  2575.         mov esi,ted_seln_x1
  2576.         mov ecx,ted_seln_y1
  2577.         call ted_get_pos_by_coords
  2578.         mov ebx,edx
  2579.         mov esi,ted_seln_x0
  2580.         mov ecx,ted_seln_y0
  2581.         call ted_get_pos_by_coords
  2582.         mov esi,ebx
  2583.  
  2584.         mov ecx,12 ;system buffer header size
  2585.         mov ebx,ted_buffer
  2586.         mov dword[ebx+4],0 ;text data
  2587.         mov dword[ebx+8],1 ;code 866
  2588.         add ebx,ecx
  2589.         @@:
  2590.                 cmp edx,ted_tex_1 ;end of file
  2591.                 jle @f
  2592.                 cmp edx,esi ;end of select
  2593.                 je @f
  2594.                 inc ecx
  2595.                 cmp ecx,ted_buffer_size ;owerflow bufer
  2596.                 je @f
  2597.  
  2598.                 mov al,byte[edx]
  2599.                 mov byte[ebx],al
  2600.                 inc ebx
  2601.                 cmp al,13
  2602.                 jne .no_13
  2603.                         mov byte[ebx],10 ;¤¥« ¥¬ ª®­¥æ áâப¨ ¢ ¡ãä¥à¥ 13,10 ¤«ï ᮢ¬¥á⨬®áâ¨ á ¤à㣨¬¨ ¯à®£à ¬¬ ¬¨
  2604.                         inc ebx
  2605.                         inc ecx
  2606.                 .no_13:
  2607.                
  2608.                 call ted_iterat_next
  2609.                 jmp @b
  2610.         @@:
  2611.         mov byte[ebx],0
  2612.  
  2613.         cmp ecx,12
  2614.         je .end_f
  2615.                 inc ecx ;à §¬¥à ¤ ­­ëå ¢ ¡ãä¥à¥ + ᨬ¢®« § ¢¥à襭¨ï áâப¨
  2616.                 mov ebx,ted_buffer
  2617.                 mov dword[ebx],ecx
  2618.                 mcall 54,2,ecx,ted_buffer
  2619.                 call ted_draw_buffer
  2620.                 cmp ted_fun_draw_panel_buttons,0
  2621.                 je .end_f
  2622.                         call ted_fun_draw_panel_buttons
  2623.         .end_f:
  2624.         popad
  2625.         ret
  2626. endp
  2627.  
  2628.  
  2629. align 4
  2630. proc ted_but_paste, edit:dword
  2631.         pushad
  2632.         mov edi,dword[edit]
  2633.  
  2634.         mcall 54,0
  2635.         cmp eax,1
  2636.         jl .no_buf_r
  2637.  
  2638.         mov esi,eax
  2639.         .cycle: ;®¡à â­ë© 横« ¯® ᫮⠬
  2640.         dec esi ;­®¬¥à ⥪ã饣®, ¯à®¢¥à塞®£® á«®â 
  2641.         mcall 54,1,esi ;read system buffer
  2642.         cmp eax,1
  2643.         je .no_buf_r
  2644.         cmp eax,-1
  2645.         je .no_buf_r
  2646.                 mov ecx,dword[eax]
  2647.                 cmp ecx,1 ;size
  2648.                 jl .no_buf_r
  2649.                 cmp dword[eax+4],0 ;text
  2650.                 je @f
  2651.                         cmp esi,1
  2652.                         jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ­¥ ⥪áâ,   ᫮⮢ ¢ ¡ãä¥à¥ ­¥áª®«ìª®, ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
  2653.                         jmp .no_buf_r
  2654.                 @@:
  2655.                 cmp dword[eax+8],1 ;866
  2656.                 je @f
  2657.                         cmp esi,1
  2658.                         jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ⥪áâ ­¥ ¢ ª®¤¨à®¢ª¥ 866 ... ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
  2659.                         jmp .no_buf_r
  2660.                 @@:
  2661.                 ;ª®¯¨à®¢ ­¨¥ ⥪áâ  ¨§ á¨á⥬­®£® ¡ãä¥à  ¢® ¢­ãâ७­¨©
  2662.                 cmp ecx,ted_buffer_size
  2663.                 jle @f
  2664.                         mov ecx,ted_buffer_size
  2665.                 @@:
  2666.                 mov edi,ted_buffer
  2667.                 mov esi,eax
  2668.                 add     esi,4 ;12
  2669.                 mov dword[edi],ecx
  2670.                 add edi,4 ;12
  2671.                 sub ecx,4 ;12
  2672.                 rep movsb
  2673.                 mov edi,dword[edit]
  2674.  
  2675.                 mov esi,eax
  2676.                 add     esi,12
  2677.                 jmp .buf_r
  2678.         .no_buf_r:
  2679.                
  2680.         ;¥á«¨ ­¥ 㤠«®áì ¯à®ç¨â âì ¤ ­­ë¥ ¨§ á¨á⥬­®£® ¡ãä¥à , ¯®¯ ¤ ¥¬ á
  2681.         mov esi,ted_buffer
  2682.         cmp dword[esi],1 ;¯à®¢¥à塞 ¥áâì «¨ ¤ ­­ë¥ ¢® ¢­ãâ७­¥¬ ¡ãä¥à¥
  2683.         jl .no_paste ;¥á«¨ ¢®®¡é¥ ­¨ç¥£® ­¥ 㤠«®áì ¯à®ç¨â âì ¨¤¥¬ ­  ¢ë室
  2684.         add esi,12 ;system buffer header size
  2685.         .buf_r:
  2686.        
  2687.         mov edx,esi
  2688.         call tl_strlen
  2689.         cmp eax,1
  2690.         jl .no_paste
  2691.                 mov esi,eax
  2692.                 call ted_set_undo
  2693.                 mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  2694.                 stdcall ted_sel_text_del,ebx
  2695.                 cmp al,1
  2696.                 jne .del
  2697.                         mov ebx,ted_opt_ed_move_cursor
  2698.                 .del:
  2699.                 stdcall ted_text_add,edi,edx,esi,ebx
  2700.                 stdcall ted_draw,edi
  2701.                 cmp ted_fun_draw_panel_buttons,0
  2702.                 je .no_paste
  2703.                         call ted_fun_draw_panel_buttons
  2704.         .no_paste:
  2705.         popad
  2706.         ret
  2707. endp
  2708.  
  2709. align 4
  2710. proc ted_but_sumb_upper uses edi esi, edit:dword
  2711.         mov edi,dword[edit]
  2712.  
  2713.         stdcall ted_convert_sel_text,fb_char_toupper
  2714.         cmp esi,0
  2715.         je @f
  2716.                 stdcall ted_draw,edi
  2717.         @@:
  2718.         ret
  2719. endp
  2720.  
  2721. align 4
  2722. proc ted_but_sumb_lover uses edi esi, edit:dword
  2723.         mov edi,dword[edit]
  2724.  
  2725.         stdcall ted_convert_sel_text,fb_char_todown
  2726.         cmp esi,0
  2727.         je @f
  2728.                 stdcall ted_draw,edi
  2729.         @@:
  2730.         ret
  2731. endp
  2732.  
  2733. align 4
  2734. proc ted_but_reverse uses eax ebx edi, edit:dword
  2735.         mov edi,dword[edit]
  2736.  
  2737.         call ted_is_select
  2738.         cmp al,0
  2739.         je @f
  2740.                 call ted_sel_normalize
  2741.                 push esi ecx edx
  2742.                         mov esi,ted_seln_x0
  2743.                         mov ecx,ted_seln_y0
  2744.                         call ted_get_pos_by_coords
  2745.                         mov eax,edx
  2746.                         mov esi,ted_seln_x1
  2747.                         cmp esi,0
  2748.                         je .beg_str
  2749.                                 dec esi
  2750.                         .beg_str:
  2751.                         mov ecx,ted_seln_y1
  2752.                         call ted_get_pos_by_coords
  2753.                         ;call ted_get_text_perv_pos
  2754.                         mov ebx,edx
  2755.                 pop edx ecx esi
  2756.                 ;cmp eax,...
  2757.                 ;je @f
  2758.                 call ted_revers
  2759.         @@:
  2760.         stdcall ted_draw,edi
  2761.         ret
  2762. endp
  2763.  
  2764. align 4
  2765. proc ted_but_undo uses eax edi, edit:dword
  2766.         mov edi,dword[edit]
  2767.  
  2768.         mov eax,ted_tim_undo
  2769.         cmp ted_tim_ch,eax
  2770.         jbe @f
  2771.                 inc ted_tim_undo
  2772.                 ;call ted_text_colored
  2773.                 stdcall ted_draw,edi
  2774.                 cmp ted_fun_draw_panel_buttons,0
  2775.                 je @f
  2776.                         call ted_fun_draw_panel_buttons
  2777.         @@:
  2778.         ret
  2779. endp
  2780.  
  2781. align 4
  2782. proc ted_but_redo uses edi, edit:dword
  2783.         mov edi,dword[edit]
  2784.  
  2785.         cmp ted_tim_undo,1
  2786.         jb @f
  2787.                 dec ted_tim_undo
  2788.                 ;call ted_text_colored
  2789.                 stdcall ted_draw,edi
  2790.                 cmp ted_fun_draw_panel_buttons,0
  2791.                 je @f
  2792.                         call ted_fun_draw_panel_buttons
  2793.         @@:
  2794.         ret
  2795. endp
  2796.  
  2797. align 4
  2798. proc ted_but_find_next, edit:dword
  2799.         pushad
  2800.         mov edi,dword[edit]
  2801.  
  2802.         call ted_get_pos_by_cursor
  2803.         mov eax,ted_buffer_find
  2804.         mov bl,byte[eax]
  2805.         @@:
  2806.                 call ted_get_find_rezult
  2807.                 cmp bh,1
  2808.                 je @f ; find
  2809.                         call ted_iterat_next
  2810.                         cmp edx,ted_tex_1
  2811.                         jle @f
  2812.                         jmp @b
  2813.         @@:
  2814.         cmp bh,0
  2815.         je @f
  2816.                 call ted_get_text_coords
  2817.                 inc ebx ;move cursor right
  2818.                 mov ted_sel_x1,ebx
  2819.                 mov ted_sel_y1,eax
  2820.                 mov edx,eax
  2821.                 mov ecx,ebx
  2822.                 call ted_go_to_pos
  2823.                 mov edx,esi ;esi ¡ë«® ãáâ ­®¢«¥® ¢ ted_get_find_rezult
  2824.                 call ted_get_text_coords
  2825.                 mov ted_sel_x0,ebx
  2826.                 mov ted_sel_y0,eax
  2827.                 stdcall ted_draw,edi
  2828.                 jmp .end_find
  2829.         @@:
  2830.                 ;¯®¯ ¤ ¥¬ á ¥á«¨ ⥪áâ ­¥ ­ ©¤¥­
  2831.                 cmp ted_fun_find_err,0
  2832.                 je .end_find
  2833.                         call ted_fun_find_err ;¯®«ì§®¢ â¥«ì᪠ï äã­ªæ¨ï
  2834.         .end_find:
  2835.         popad
  2836.         ret
  2837. endp
  2838.  
  2839. ;input:
  2840. ; edi = pointer to tedit struct
  2841. align 4
  2842. ted_key_ctrl_home:
  2843.         mov ted_cur_x,0
  2844.         mov ted_cur_y,0
  2845.         push eax
  2846.                 mov eax,ted_scr_w
  2847.                 mov dword[eax+sb_offs_position],0
  2848.                 mov eax,ted_scr_h
  2849.                 mov dword[eax+sb_offs_position],0
  2850.         pop eax
  2851.         stdcall ted_draw,edi
  2852.         cmp ted_fun_draw_panel_buttons,0
  2853.         je @f
  2854.                 call ted_fun_draw_panel_buttons
  2855.         @@:
  2856.         ret
  2857.  
  2858. ;input:
  2859. ; edi = pointer to tedit struct
  2860. align 4
  2861. ted_key_ctrl_end:
  2862.         push eax ebx
  2863.                 call ted_get_num_lines
  2864.                 mov ebx,ted_scr_w
  2865.                 mov dword[ebx+sb_offs_position],eax ;áâ ¢¨¬ ¯®«§ã­®ª ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
  2866.                 cmp eax,dword[ebx+sb_offs_cur_area]
  2867.                 jle @f
  2868.                         mov eax,dword[ebx+sb_offs_cur_area] ;¯®«ãç ¥¬ ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­®
  2869.                 @@:
  2870.                 sub dword[ebx+sb_offs_position],eax ;®â­¨¬ ¥¬ ®â ¯®«§ã­ª  ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­® (­® ­¥ ¡®«ìè¥ â¥å, çâ® ¥áâì ¢ ¤®ªã¬¥­â¥)
  2871.                 dec eax
  2872.                 mov ted_cur_y,eax ;áâ ¢¨¬ ªãàá®à ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
  2873.         pop ebx eax
  2874.         call ted_cur_move_x_last_char
  2875.         stdcall ted_draw,edi
  2876.         cmp ted_fun_draw_panel_buttons,0
  2877.         je @f
  2878.                 call ted_fun_draw_panel_buttons
  2879.         @@:
  2880.         ret
  2881.  
  2882. ;input:
  2883. ; edi = pointer to tedit struct
  2884. align 4
  2885. proc ted_sel_key_up
  2886.   cmp ted_drag_k,1
  2887.   je @f
  2888.     call ted_sel_start
  2889.     mov ted_drag_k,1
  2890.   @@:
  2891.   push dx
  2892.     call ted_cur_move_up
  2893.     cmp dl,8
  2894.     jne @f
  2895.       call ted_scroll_set_redraw
  2896.     @@:
  2897.   pop dx
  2898.   call ted_sel_move
  2899.   stdcall ted_draw,edi
  2900.   ret
  2901. endp
  2902.  
  2903. ;input:
  2904. ; edi = pointer to tedit struct
  2905. align 4
  2906. proc ted_sel_key_down
  2907.   cmp ted_drag_k,1
  2908.   je @f
  2909.     call ted_sel_start
  2910.     mov ted_drag_k,1
  2911.   @@:
  2912.   push dx
  2913.     call ted_cur_move_down
  2914.     cmp dl,8
  2915.     jne @f
  2916.       call ted_scroll_set_redraw
  2917.     @@:
  2918.   pop dx
  2919.   call ted_sel_move
  2920.   stdcall ted_draw,edi
  2921.   ret
  2922. endp
  2923.  
  2924. ;input:
  2925. ; edi = pointer to tedit struct
  2926. align 4
  2927. proc ted_sel_key_left
  2928.   cmp ted_drag_k,1
  2929.   je @f
  2930.     call ted_sel_start
  2931.   @@:
  2932.   push dx
  2933.     call ted_cur_move_left
  2934.     call ted_sel_move
  2935.     cmp ted_drag_k,1
  2936.     je @f
  2937.       mov ted_drag_k,1
  2938.       mov dl,8
  2939.     @@:
  2940.     cmp dl,8
  2941.     jne @f
  2942.       call ted_scroll_set_redraw
  2943.       stdcall ted_draw,edi
  2944.       jmp .end_f
  2945.     @@:
  2946.       stdcall ted_draw_cur_line,edi
  2947.     .end_f:
  2948.   pop dx
  2949.   ret
  2950. endp
  2951.  
  2952. ;input:
  2953. ; edi = pointer to tedit struct
  2954. align 4
  2955. proc ted_sel_key_right
  2956.   cmp ted_drag_k,1
  2957.   je @f
  2958.     call ted_sel_start
  2959.   @@:
  2960.   push dx
  2961.     call ted_cur_move_right
  2962.     call ted_sel_move
  2963.     cmp ted_drag_k,1
  2964.     je @f
  2965.       mov ted_drag_k,1
  2966.       mov dl,8
  2967.     @@:
  2968.     cmp dl,8
  2969.     jne @f
  2970.       call ted_scroll_set_redraw
  2971.       stdcall ted_draw,edi
  2972.       jmp .end_f
  2973.     @@:
  2974.       stdcall ted_draw_cur_line,edi
  2975.     .end_f:
  2976.   pop dx
  2977.   ret
  2978. endp
  2979.  
  2980. ;input:
  2981. ; edi = pointer to tedit struct
  2982. ;description:
  2983. ; this function need to optimize output
  2984. align 4
  2985. proc ted_draw_cursor_sumb
  2986. pushad
  2987.         mov eax,SF_DRAW_RECT
  2988.         mov ebx,ted_wnd_l
  2989.         add ebx,ted_rec_l
  2990.         mov edx,ted_cur_x
  2991.         imul edx,ted_rec_w
  2992.         add ebx,edx
  2993.         shl ebx,16
  2994.         add ebx,ted_rec_w
  2995.  
  2996.         mov ecx,ted_wnd_t ;calc rect -> y0,y1
  2997.         add ecx,ted_rec_t
  2998.         mov edx,ted_cur_y
  2999.         imul edx,ted_rec_h
  3000.         add ecx,edx
  3001.         shl ecx,16
  3002.         add ecx,ted_rec_h
  3003.  
  3004.         mov edx,ted_color_wnd_work
  3005.         push ecx
  3006.                 call ted_sel_normalize
  3007.  
  3008.                 mov esi,ted_scr_w
  3009.                 mov ecx,dword[esi+sb_offs_position]
  3010.                 sub ted_seln_y0,ecx
  3011.                 sub ted_seln_y1,ecx
  3012.  
  3013.                 mov ecx,ted_cur_y
  3014.                 cmp ecx,ted_seln_y0
  3015.                 jl .no_cur_sel
  3016.                 cmp ecx,ted_seln_y1
  3017.                 jg .no_cur_sel
  3018.                 mov edx,ted_color_select ;¬¥­ï¥¬ 梥â ä®­  ­  梥⠢뤥«¥­¨ï
  3019.    
  3020.                 mov esi,ted_scr_h
  3021.                 cmp ecx,ted_seln_y0
  3022.                 jne @f
  3023.                         mov ecx,ted_cur_x
  3024.                         add ecx,dword[esi+sb_offs_position]
  3025.                         cmp ecx,ted_seln_x0
  3026.                         jge @f
  3027.                         mov edx,ted_color_wnd_work
  3028.                 @@:
  3029.                 mov ecx,ted_cur_y
  3030.                 cmp ecx,ted_seln_y1
  3031.                 jne .no_cur_sel
  3032.                         mov ecx,ted_cur_x
  3033.                         add ecx,dword[esi+sb_offs_position]
  3034.                         cmp ecx,ted_seln_x1
  3035.                         jl .no_cur_sel
  3036.                         mov edx,ted_color_wnd_work
  3037.                 .no_cur_sel:
  3038.         pop ecx
  3039.         int 0x40 ;à¨á®¢ ­¨¥ ¯àאַ㣮«ì­¨ª 
  3040.  
  3041.         call ted_get_pos_by_cursor ;¡¥à¥¬ ¯®§¨æ¨î ᨬ¢®« 
  3042.         cmp ted_gp_opt,2
  3043.         jne @f
  3044.                 mov esi,1
  3045.                 ror ecx,16
  3046.                 mov bx,cx
  3047.                 add ebx,0x10001
  3048.                 call ted_get_symb_color
  3049.                 call ted_convert_invis_symb
  3050.                 mcall SF_DRAW_TEXT ;à¨á®¢ ­¨¥ ᨬ¢®« 
  3051.         @@:
  3052. popad
  3053.         ret
  3054. endp
  3055.  
  3056. ;input:
  3057. ; edx -> pointer to text
  3058. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  3059. ;output:
  3060. ; ecx = color
  3061. ; if ted_mode_color=0 then ecx=ted_color_wnd_text
  3062. align 4
  3063. ted_get_symb_color:
  3064.         mov ecx,ted_color_wnd_text ;§ ¤ ¥¬ 梥â ⥪áâ  ¯® 㬮«ç ­¨î
  3065.  
  3066.         push eax edx
  3067.         cmp ted_mode_color,0
  3068.         je .exit
  3069.                 jmp .on_first
  3070.                 @@:
  3071.                         call ted_iterat_perv
  3072.                         cmp edx,ted_tex_1
  3073.                         jle .exit
  3074.                 .on_first:
  3075.                         xor eax,eax
  3076.                         mov al,byte[edx+1]
  3077.                         or al,al ;¥á«¨ al=0 ⮠梥⠭¥ ¬¥­ï¥âáï
  3078.                         jz @b
  3079.  
  3080.                 cmp eax,ted_colors_text_count
  3081.                 jge .exit
  3082.  
  3083.                 shl ax,2 ;㬭®¦ ¥¬ ¨­¤¥ªá æ¢¥â  ­  4 ¡ ©â 
  3084.                 mov ecx,ted_text_colors ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 1-£® 梥â 
  3085.                 add ecx,eax
  3086.                 mov ecx,dword[ecx] ;ãáâ ­ ¢«¨¢ ¥¬ ⥪ã騩 梥â ⥪áâ  ¯® ᬥ饭¨î
  3087.         .exit:
  3088.         or ecx,ted_font_size
  3089.         pop edx eax
  3090.         ret
  3091.  
  3092. ;input:
  3093. ; edx = pointer to text
  3094. ; edi = pointer to tedit struct
  3095. ;description:
  3096. ; ”ã­ªæ¨ï ¯à¥®¡à §ã¥â ­¥¢¨¤¨¬ë¥ ᨬ¢®«ë ¢ ¯¥ç â ¥¬ë¥ ­  íªà ­¥
  3097. align 4
  3098. ted_convert_invis_symb:
  3099.         cmp ted_mode_invis,1
  3100.         jne .end_f
  3101.                 cmp byte[edx],9
  3102.                 jne @f
  3103.                         lea edx,[ted_symbol_tab]
  3104.                 @@:
  3105.                 cmp byte[edx],13
  3106.                 jne @f
  3107.                         mov edx,edi
  3108.                         add edx,ted_offs_symbol_new_line
  3109.                 @@:
  3110.         .end_f:
  3111.         ret
  3112.  
  3113. ;input:
  3114. ; edi = pointer to tedit struct
  3115. align 4
  3116. ted_scroll_set_redraw:
  3117.         push eax
  3118.         mov eax,ted_scr_w
  3119.         mov dword[eax+sb_offs_redraw],1
  3120.         mov eax,ted_scr_h
  3121.         mov dword[eax+sb_offs_redraw],1
  3122.         pop eax
  3123.         ret
  3124.  
  3125. align 4
  3126. proc ted_draw, edit:dword
  3127.         locals
  3128.                 line_num dd ?
  3129.         endl
  3130.         pushad
  3131.         mov edi,dword[edit]
  3132.  
  3133.         mov eax,SF_DRAW_TEXT
  3134.         mov ecx,ted_text_colors
  3135.         mov ecx,dword[ecx]
  3136.  
  3137.         mov ebx,ted_wnd_l
  3138.         add ebx,ted_rec_l
  3139.         shl ebx,16
  3140.         add ebx,ted_wnd_t
  3141.         add ebx,ted_rec_t
  3142.         add ebx,0x10001 ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3143.  
  3144.         call ted_sel_normalize ;need before draw select
  3145.         mov esi,ted_scr_w
  3146.         mov esi,dword[esi+sb_offs_position]
  3147.         mov dword[line_num],esi
  3148.  
  3149.         stdcall ted_clear_line_before_draw, edi,ebx,1,esi
  3150.         call ted_get_first_visible_pos
  3151.         cmp edx,0
  3152.         je .no_draw_text
  3153.         mov esi,1 ;¤«¨­­  ¢ë¢®¤¨¬®£® ⥪áâ  ¯® 1-¬ã ᨬ¢®«ã
  3154.         @@:
  3155.                 call ted_iterat_next
  3156.                 cmp edx,ted_tex_1
  3157.                 jle .no_draw_text
  3158.  
  3159.                 ; *** 梥⮢ ï à §¬¥âª 
  3160.                 cmp ted_mode_color,0
  3161.                 je .no_col_change
  3162.                 cmp byte[edx+1],0
  3163.                 je .no_col_change
  3164.                         call ted_get_symb_color
  3165.                 .no_col_change:
  3166.  
  3167.                 cmp byte [edx],13
  3168.                 jne .no_13
  3169.                         cmp ted_mode_invis,1
  3170.                         jne .no_invis
  3171.                                 push edx
  3172.                                 mov edx,edi
  3173.                                 add edx,ted_offs_symbol_new_line
  3174.                                 int 0x40
  3175.                                 pop edx
  3176.                         .no_invis:
  3177.                         add ebx,ted_rec_h
  3178.                         ;optimized output \/
  3179.                         mov eax,ted_wnd_h
  3180.                         add eax,ted_wnd_t
  3181.                         cmp bx,ax
  3182.                         jg .no_draw_text
  3183.                         mov eax,SF_DRAW_TEXT
  3184.                         ;optimized output /\        
  3185.                         and ebx,0xffff
  3186.                         ror ebx,16
  3187.                         add ebx,ted_wnd_l
  3188.                         add ebx,ted_rec_l
  3189.                         inc ebx
  3190.                         ror ebx,16
  3191.                         inc dword[line_num] ;increment line number
  3192.                         stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
  3193.                         call ted_opt_draw_line_left
  3194.                         jmp @b
  3195. align 4
  3196.                 .no_13:
  3197.  
  3198.                 int 0x40
  3199.                 ror ebx,16
  3200.                 add ebx,ted_rec_w
  3201.                 mov esi,ted_wnd_l
  3202.                 add esi,ted_wnd_w
  3203.                 cmp bx,si
  3204.                 jl .no_opt
  3205.                         call ted_opt_draw_line_right
  3206.                 .no_opt:
  3207.                 mov si,1
  3208.                 ror ebx,16
  3209.                 jmp @b
  3210.         .no_draw_text:
  3211.  
  3212.         inc dword[line_num]
  3213.         stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
  3214.         call ted_draw_line_numbers
  3215.         call ted_draw_main_cursor
  3216.  
  3217. ;---------------------------------------------
  3218. ; set all_redraw flag for draw all ScrollBar
  3219. ; In some cases it is necessity to draw only the area
  3220. ; of moving of a "runner", for acceleration of output -
  3221. ; in this case the flag needs to be reset to 0 (zero).
  3222.         mov eax,ted_scr_h
  3223.         mov esi,ted_scr_w
  3224.         mov dword[eax+sb_offs_all_redraw],1
  3225.         mov dword[esi+sb_offs_all_redraw],1
  3226.  
  3227. ; à¨á®¢ ­¨¥ ¯®«®á ¯à®ªàã⪨
  3228.         stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
  3229.         stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
  3230. ; reset all_redraw flag
  3231.         mov dword[eax+sb_offs_all_redraw],0
  3232.         mov dword[esi+sb_offs_all_redraw],0
  3233. ;---------------------------------------------
  3234.  
  3235.         ;left-bottom square
  3236.         mov ebx,ted_wnd_l
  3237.         shl ebx,16
  3238.         add ebx,ted_rec_l
  3239.         mov ecx,ted_wnd_t
  3240.         add ecx,ted_wnd_h
  3241.         shl ecx,16
  3242.         mov cx,word[eax+sb_offs_size_y]
  3243.         inc cx
  3244.         mcall SF_DRAW_RECT,,,ted_color_wnd_capt ;[sc.work]
  3245.  
  3246.         ;right-bottom square
  3247.         mov ebx,ted_wnd_l
  3248.         add ebx,ted_wnd_w
  3249.         shl ebx,16
  3250.         mov bx,word[esi+sb_offs_size_x]
  3251.         inc bx
  3252.         int 0x40
  3253.  
  3254.         cmp ted_fun_draw_panel_find,0
  3255.         je @f
  3256.                 call ted_fun_draw_panel_find
  3257.         @@:
  3258.         cmp ted_fun_draw_panel_syntax,0
  3259.         je @f
  3260.                 call ted_fun_draw_panel_syntax
  3261.         @@:
  3262.         popad
  3263.         ret
  3264. endp
  3265.  
  3266. ;input:
  3267. ; edi = pointer to tedit struct
  3268. align 4
  3269. proc ted_draw_main_cursor
  3270.   pushad
  3271.  
  3272.   mov eax,SF_DRAW_RECT ;draw cursor
  3273.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  3274.   add ecx,ted_rec_t
  3275.   mov edx,ted_cur_y
  3276.   imul edx,ted_rec_h
  3277.   add ecx,edx
  3278.  
  3279.   cmp ted_cur_ins,1 ;¯à®¢¥àª  ०¨¬  à ¡®âë ªãàá®à  (®¡ëç­ë© ¨«¨ ¢áâ ¢ª )
  3280.   jne @f
  3281.     mov edx,ted_rec_h
  3282.     inc edx   ;1->1, 3->2, 5->3, ...
  3283.     shr edx,1 ;edx = ¢ëá®â  áâப¨ ¤¥«¥­­ ï ­  2 (ª®£¤  ªãàá®à ­¥ ¯®«­ë©)
  3284.     add ecx,edx
  3285.   @@:
  3286.   shl ecx,16
  3287.   add ecx,ted_rec_h
  3288.   cmp ted_cur_ins,1
  3289.   jne @f
  3290.     shr cx,1 ;¤¥«¨¬ ¢ëá®âã ªãàá®à  ­  2
  3291.   @@:
  3292.  
  3293.   mov ebx,ted_wnd_l ;calc rect -> x0,x1
  3294.   add ebx,ted_rec_l
  3295.   mov edx,ted_cur_x
  3296.   imul edx,ted_rec_w
  3297.   add ebx,edx
  3298.   shl ebx,16
  3299.   add ebx,ted_rec_w
  3300.  
  3301.   mov edx,ted_color_cursor
  3302.   int 0x40 ;¢ë¢®¤ ªãàá®à 
  3303.  
  3304.   call ted_get_pos_by_cursor
  3305.   cmp ted_gp_opt,2
  3306.   jne @f
  3307.     mov esi,1
  3308.     ror ecx,16
  3309.     mov bx,cx
  3310.     add ebx,0x10001
  3311.     cmp ted_cur_ins,1
  3312.     jne .no_up_tetx
  3313.       mov ecx,ted_rec_h
  3314.       inc cx ; 1->1, 3->2, 5->3, ...
  3315.       shr cx,1
  3316.       sub bx,cx
  3317.     .no_up_tetx:
  3318.     mov ecx,ted_color_cur_text
  3319.         or ecx,ted_font_size
  3320.     call ted_convert_invis_symb
  3321.     mcall SF_DRAW_TEXT
  3322.   @@:
  3323.  
  3324.   mov ebx,ted_wnd_l
  3325.   add ebx,ted_rec_l
  3326.   shl ebx,16
  3327.   add ebx,ted_wnd_t
  3328.   add ebx,3
  3329.   mov ecx,ted_color_wnd_bord
  3330.   or  ecx,0x80000000
  3331.   lea edx,[txtRow]
  3332.   mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ '‘âப '
  3333.  
  3334.   add ebx,0x500000
  3335.   lea edx,[txtCol]
  3336.   int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‡­ ª'
  3337.  
  3338.   cmp ted_tim_undo,0
  3339.   je @f
  3340.     add ebx,0x500000
  3341.     lea edx,[txtOtm]
  3342.     int 0x40
  3343.     sub ebx,0x500000
  3344.   @@:
  3345.  
  3346.   call ted_draw_buffer
  3347.   call ted_draw_help_f1
  3348.  
  3349.   mov eax,47 ;draw cursor coords
  3350.   mov esi,ted_color_wnd_bord
  3351.   or  esi,0x40000000
  3352.  
  3353.   mov edx,ebx
  3354.   ror edx,16
  3355.   sub edx,35
  3356.   ror edx,16
  3357.   ;add edx,3
  3358.   mov ebx,0x40000 ;Row=...
  3359.   mov ecx,ted_scr_w
  3360.   mov ecx,dword[ecx+sb_offs_position]
  3361.   add ecx,ted_cur_y
  3362.   inc ecx
  3363.  
  3364. push edi
  3365.   mov edi,ted_color_wnd_work
  3366.   int 0x40 ;¢ë¢®¤ ç¨á«  ⥪ã饩 áâப¨
  3367. pop edi
  3368.  
  3369.   ;mov ebx,0x40000 ;Col=...
  3370.   mov ecx,ted_scr_h
  3371.   mov ecx,dword[ecx+sb_offs_position]
  3372.   add ecx,ted_cur_x
  3373.   inc ecx
  3374.   add edx,0x500000
  3375. push edi
  3376.   mov edi,ted_color_wnd_work
  3377.   int 0x40 ;¢ë¢®¤ ç¨á«  §­ ª®¢
  3378. pop edi
  3379.  
  3380.   cmp ted_tim_undo,0
  3381.   je @f
  3382.     mov ecx,ted_tim_undo
  3383.     add edx,0x500000
  3384.         mov edi,ted_color_wnd_work ;¯®à⨬ ॣ¨áâà edi, ­® ¢ ª®­æ¥ ä㭪樨 í⮠㦥 ­¥ ¢ ¦­®
  3385.     int 0x40 ;¢ë¢®¤ ç¨á«  ®â¬¥­¥­­ëå ¤¥©á⢨©
  3386.   @@:
  3387.  
  3388.   popad
  3389.   ret
  3390. endp
  3391.  
  3392. ;input:
  3393. ; edi = pointer to tedit struct
  3394. proc ted_draw_buffer
  3395.         pushad
  3396.  
  3397.         mov eax,ted_buffer
  3398.         cmp dword[eax],1 ;ᬮâਬ à §¬¥à ¡ãä¥à 
  3399.         jl @f
  3400.                 mov ebx,ted_rec_l
  3401.                 add bx,300
  3402.                 cmp ebx,ted_wnd_w ;áà ¢­¨¢ ¥¬ ª®®à¤¨­ âã ¤«ï ¢ë¢®¤ ⥪áâ 
  3403.                 jge @f ;¯®¤¯¨áì ­¥ ¢« §¨â ¢ ®ª­®
  3404.  
  3405.                 add ebx,ted_wnd_l
  3406.                 shl ebx,16
  3407.                 add ebx,ted_wnd_t
  3408.                 add ebx,3
  3409.                 mov ecx,ted_color_wnd_bord
  3410.                 or ecx,0x40000000
  3411.  
  3412.                 mov edx,ted_buffer
  3413.                 add edx,12
  3414.                 mov esi,edx
  3415.                 mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
  3416.                 call tl_strlen
  3417.                 ;cmp eax,0 ;¡ãä¥à ¯ãáâ
  3418.                 ;je @f
  3419.                 cmp eax,20
  3420.                 jle .crop_buf
  3421.                         mov eax,20 ;®¡à¥§ª  ¯®¤¯¨á¨ ¤® 20 ᨬ¢®«®¢
  3422.                 .crop_buf:
  3423.                 mov esi,eax
  3424.                 mcall SF_DRAW_TEXT ;¢ë¢®¤ ᮤ¥à¦¨¬®£® ¡ãä¥à 
  3425.  
  3426.                 sub ebx,50 shl 16
  3427.                 lea edx,[txtBuf]
  3428.                 mov esi,edx
  3429.                 call tl_strlen
  3430.                 mov esi,eax
  3431.                 xor ecx,0x40000000 ;㡨ࠥ¬ 梥â ä®­ 
  3432.                 mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ ¤«ï ¡ãä¥à 
  3433.         @@:
  3434.         popad
  3435.         ret
  3436. endp
  3437.  
  3438. ;input:
  3439. ; edi = pointer to tedit struct
  3440. align 4
  3441. proc ted_draw_help_f1
  3442.         pushad
  3443.         cmp ted_rec_t,13 ;¬¨­¨¬ «ì­ ï ¢ëá®â  ¤«ï à¨á®¢ ­¨ï á¯à ¢ª¨
  3444.         jle @f
  3445.                 ;clear place before draw help
  3446.                 mov ebx,ted_wnd_l
  3447.                 add ebx,ted_rec_l
  3448.                 shl ebx,16
  3449.                 add ebx,ted_wnd_w
  3450.                 sub ebx,ted_rec_l
  3451.                 mov ecx,ted_wnd_t
  3452.                 add ecx,13
  3453.                 shl ecx,16
  3454.                 add ecx,9 ;9 - ¢ëá®â  0-£® èà¨äâ , áâ ¢¨âì ted_rec_h ¯®ª  ¥é¥ à ­®
  3455.                 mcall SF_DRAW_RECT,,,ted_color_wnd_capt
  3456.  
  3457.         cmp ted_help_id,-1
  3458.         je @f
  3459.                 mov eax,ted_help_id
  3460.                 ColToIndexOffset eax,edx
  3461.  
  3462.                 ;SetCoordinates
  3463.                 mov ebx,ted_wnd_l
  3464.                 add ebx,ted_rec_l
  3465.                 shl ebx,16
  3466.                 add ebx,ted_wnd_t
  3467.                 add ebx,13 ;=3+10
  3468.  
  3469.                 ;SetTextColor
  3470.                 xor eax,eax
  3471.                 mov al,byte[edx+MAX_COLOR_WORD_LEN+7]
  3472.                 shl ax,2
  3473.                 mov ecx,ted_text_colors
  3474.                 add ecx,eax
  3475.                 mov ecx,dword[ecx]
  3476.                 or      ecx,0xc0000000 ;SetTextStyles
  3477.                 mov esi,edi
  3478.                 mcall SF_DRAW_TEXT,,,,,ted_color_wnd_work
  3479.                 mov edi,esi
  3480.  
  3481.                 mov esi,edx
  3482.                 call tl_strlen
  3483.  
  3484.                 ;*** draw help string ***
  3485.                 mov ecx,ted_color_wnd_bord
  3486.                 or ecx,0x80000000
  3487.                 mov edx,dword[edx+MAX_COLOR_WORD_LEN]
  3488.                 cmp edx,0
  3489.                 je @f
  3490.                         add edx,ted_help_text_f1
  3491.                         inc eax
  3492.                         imul eax,6 ;è¨à¨­  ᨬ¢®«  ¢ á¨áâ. èà¨äâ¥
  3493.                         shl eax,16                     
  3494.                         add ebx,eax
  3495.                         mcall SF_DRAW_TEXT
  3496.         @@:
  3497.         popad
  3498.         ret
  3499. endp
  3500.  
  3501. ;input:
  3502. ; edi = pointer to tedit struct
  3503. align 4
  3504. proc ted_draw_line_numbers
  3505. pushad
  3506.         ;top panel with caption
  3507.         mov ebx,ted_wnd_l
  3508. ;  add ebx,ted_rec_l
  3509.         shl ebx,16
  3510.         add ebx,ted_wnd_w
  3511. ;  sub ebx,ted_rec_l
  3512.         mov edx,ted_color_wnd_work
  3513.         mov ecx,ted_wnd_t
  3514.         shl ecx,16
  3515.         add ecx,ted_rec_t
  3516.         mov edx,ted_color_wnd_capt
  3517.         mcall SF_DRAW_RECT
  3518.  
  3519.         ;line numbers
  3520.         mov ebx,0x40000 ;format
  3521.         mov ecx,ted_scr_w
  3522.         mov ecx,dword[ecx+sb_offs_position]
  3523.         inc ecx
  3524.         mov edx,3
  3525.         add edx,ted_wnd_l
  3526.         rol edx,16
  3527.         add edx,ted_wnd_t
  3528.         add edx,ted_rec_t
  3529.         @@:
  3530.  
  3531. push ebx ecx edx
  3532.         ;left panel with numbers
  3533.         mov ebx,ted_wnd_l
  3534.         shl ebx,16
  3535.         add ebx,ted_rec_l
  3536.         mov ecx,ted_rec_h
  3537.         rol ecx,16
  3538.         mov cx,dx
  3539.         rol ecx,16
  3540.         mov edx,ted_color_wnd_capt
  3541.         mcall SF_DRAW_RECT ;à¨á㥬 ¯àאַ㣮«ì­¨ª ¯®¤ ­®¬¥à®¬ áâப¨
  3542. pop edx ecx ebx
  3543.  
  3544.                 mov eax,47
  3545.                 mov esi,ted_color_wnd_bord
  3546.                 int 0x40 ;à¨á㥬 ­®¬¥à áâப¨
  3547.                 inc ecx
  3548.                 add edx,ted_rec_h
  3549.                 sub edx,ted_wnd_t
  3550.                 mov esi,edx
  3551.                 and esi,0xffff
  3552.                 cmp esi,ted_wnd_h
  3553.                 jge @f
  3554.                 add edx,ted_wnd_t
  3555.                 jmp @b
  3556. align 4
  3557.         @@:
  3558. popad
  3559.         ret
  3560. endp
  3561.  
  3562. ;output:
  3563. ; ah = symbol
  3564. align 4
  3565. proc KeyConvertToASCII, table:dword
  3566.         push ebx
  3567.         mov ebx,dword[table] ;convert scan to ascii
  3568.         ror ax,8
  3569.         xor ah,ah
  3570.         add bx,ax ;? ebx,eax
  3571.         mov ah,byte[ebx]
  3572.         pop ebx
  3573.         ret
  3574. endp
  3575.  
  3576. align 4
  3577. proc ted_draw_cur_line, edit:dword
  3578.   pushad
  3579.     mov edi,dword[edit]
  3580.  
  3581.     mov ebx,ted_wnd_l
  3582.     add ebx,ted_rec_l
  3583.     shl ebx,16
  3584.     mov eax,ted_cur_y
  3585.     imul eax,ted_rec_h
  3586.         mov bx,ax
  3587.     add ebx,ted_wnd_t
  3588.     add ebx,ted_rec_t ;ebx - ª®®à¤¨­ âë ¤«ï ¯àאַ㣮«ì­¨ª  ®ç¨á⪨ «¨­¨¨
  3589.         add ebx,0x10001   ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3590.  
  3591.     call ted_sel_normalize ;need before draw select
  3592.         mov ecx,ted_cur_y
  3593.         mov eax,ted_scr_w
  3594.     add ecx,dword[eax+sb_offs_position]
  3595.     stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
  3596.  
  3597.     mov eax,ted_scr_h
  3598.         mov esi,dword[eax+sb_offs_position]
  3599.     call ted_get_pos_by_coords
  3600.  
  3601.   cmp ted_gp_opt,2
  3602.   jne .no_draw_text
  3603. ;  mov eax,SF_DRAW_TEXT
  3604.   call ted_get_symb_color
  3605.   mov esi,1 ;draw 1 symbol
  3606.   @@:
  3607.     ;call ted_iterat_next
  3608.     cmp edx,ted_tex_1
  3609.     jle .no_draw_text
  3610.  
  3611.     ; *** 梥⮢ ï à §¬¥âª 
  3612.     cmp ted_mode_color,0
  3613.     je .no_col_change
  3614.     cmp byte[edx+1],0
  3615.     je .no_col_change
  3616.       call ted_get_symb_color
  3617.     .no_col_change:
  3618.  
  3619.     mov eax,SF_DRAW_TEXT
  3620.     cmp byte [edx],13
  3621.     jne .no_13
  3622.       cmp ted_mode_invis,1
  3623.       jne .no_draw_text
  3624.  push edx
  3625.  mov edx,edi
  3626.  add edx,ted_offs_symbol_new_line
  3627.  int 0x40
  3628.  pop edx
  3629.       jmp .no_draw_text
  3630.     .no_13:
  3631.  
  3632.     int 0x40
  3633.     ror ebx,16
  3634.     add ebx,ted_rec_w
  3635.     mov eax,ted_wnd_w
  3636.     add eax,ted_wnd_l ;ax = ®âáâ㯠¯® ®á¨ x
  3637.     cmp bx,ax
  3638.     jge .no_draw_text ;Opt
  3639.     ror ebx,16
  3640.     call ted_iterat_next
  3641.     jmp @b
  3642.   .no_draw_text:
  3643.  
  3644.   call ted_draw_main_cursor
  3645.   popad
  3646.   ret
  3647. endp
  3648.  
  3649. ;input:
  3650. ; eax - text need find
  3651. ; bl - first symbol to find
  3652. ; edx - first symbol pointer
  3653. ; edi - pointer to tedit struct
  3654. ;output:
  3655. ; bh - rezult
  3656. ; edx - last text position (if find sucess)
  3657. ; esi - first symbol pointer
  3658. ;description:
  3659. ; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ eax
  3660. ; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
  3661. ; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
  3662. ; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
  3663. align 4
  3664. ted_get_find_rezult:
  3665.   push eax
  3666.     mov bh,1
  3667.     mov esi,edx ;copy edx
  3668.     @@:
  3669.       cmp byte[edx],bl
  3670.       jne .no_text
  3671.  
  3672.       inc eax ;*** get next symbol (in find text) ***
  3673.       mov bl,byte[eax]
  3674.       cmp bl,0
  3675.       je @f ;end of find text
  3676.  
  3677.       call ted_iterat_next ;*** get next symbol (in editor text) ***
  3678.       cmp edx,ted_tex_1
  3679.       jle @f ;end of editor text
  3680.  
  3681.       jmp @b
  3682.       .no_text:
  3683.         xor bh,bh
  3684.         mov edx,esi ;restore edx
  3685.     @@:
  3686.   pop eax
  3687.   mov bl,byte[eax] ;restore bl
  3688.   ret
  3689.  
  3690. ;input:
  3691. ;  clear_o - ¥á«¨ =1 ®ç¨áâ¨âì ®¤­ã áâபã, =0 ®ç¨áâ¨âì ¢á¥ áâப¨ ®ª­  ¤® ­¨§ã
  3692. align 4
  3693. proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
  3694.         pushad
  3695.         mov edi,dword[edit]
  3696.         mov ebx,dword[coords]   ;ebx = x*2^16+y coords to left up point clear line
  3697.         mov esi,dword[numb_lin] ;esi - number text line
  3698.  
  3699.         sub ebx,0x10001 ;®â­¨¬ ¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3700.         cmp dword[clear_o],0
  3701.         jne @f
  3702.                 add ebx,ted_rec_h
  3703.                 ror ebx,16
  3704.                 xor bx,bx
  3705.                 add ebx,ted_wnd_l
  3706.                 add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
  3707.                 ror ebx,16
  3708.         @@:
  3709.  
  3710.         mov eax,ted_wnd_h
  3711.         add eax,ted_wnd_t
  3712.         cmp ax,bx
  3713.         jl .no_clear
  3714.         sub ax,bx
  3715.  
  3716.         mov cx,bx
  3717.         shl ecx,16
  3718.  
  3719.         xor bx,bx
  3720.         add ebx,ted_wnd_w
  3721.         sub ebx,ted_rec_l
  3722.         xor cx,cx
  3723.         add ecx,ted_rec_h
  3724.         mov edx,ted_color_wnd_work
  3725.  
  3726.         cmp dword[clear_o],0
  3727.         je .pusto
  3728.         cmp ax,cx
  3729.         jge @f
  3730.         .pusto:
  3731.                 mov cx,ax
  3732.                 jmp .no_select ;¥á«¨ ®ç¨á⪠ ®ª­  ¤® ­¨§ã, â® ¢á¥£¤  ä®­®¢ë¬ 梥⮬
  3733.         @@:
  3734.  
  3735.         call ted_is_select
  3736.         cmp al,0
  3737.         je .no_select
  3738.         cmp ted_seln_y0,esi
  3739.         jg .no_select
  3740.         cmp ted_seln_y1,esi
  3741.         jl .no_select
  3742.                 mov edx,ted_color_select ;draw selected line
  3743.         .no_select:
  3744.  
  3745.         mcall SF_DRAW_RECT ;§ ªà áª  ¯®«­®© áâப¨ 梥⮬ ä®­  ¨«¨ 梥⮬ ¢ë¤¥«¥­¨ï
  3746.  
  3747.         call ted_is_select
  3748.         or al,al
  3749.         jz .no_clear
  3750.  
  3751.         mov al,SF_DRAW_RECT
  3752.         xor cx,cx
  3753.         add ecx,ted_rec_h
  3754.         cmp ted_seln_y0,esi
  3755.         jne @f
  3756.                 push bx esi
  3757.                 mov edx,ted_seln_x0 ; ¢¥àå­ïï ¯®«®á  (§ â¨à ¥â á«¥¢ )
  3758.                 mov esi,ted_scr_h
  3759.                 cmp edx,dword[esi+sb_offs_position]
  3760.                 jle .in_wnd
  3761.                         sub edx,dword[esi+sb_offs_position]
  3762.                         imul edx,ted_rec_w
  3763.                         mov bx,dx
  3764.                         jmp .no_wnd
  3765.                 .in_wnd:
  3766.                 mov bx,0
  3767.                 .no_wnd:
  3768.                 mov edx,ted_color_wnd_work
  3769.                 int 0x40
  3770.                 pop esi bx
  3771.         @@:
  3772.         cmp ted_seln_y1,esi
  3773.         jne @f
  3774.                 ;push esi
  3775.                 ;¥á«¨ ¢ë¤¥«¥­ ¢¥áì ä ©« âãâ ¬®¦­® ᤥ« âì ¢ë室, ­® ⮣¤  ­ã¦­® ¢ëè¥ ã¡à âì jmp .no_select
  3776.                 mov edx,ted_seln_x1 ; ­¨¦­ïï ¯®«®á  (§ â¨à ¥â á¯à ¢ )
  3777.                 mov esi,ted_scr_h
  3778.                 cmp edx,dword[esi+sb_offs_position]
  3779.                 jle .in_wnd2
  3780.                         sub edx,dword[esi+sb_offs_position]
  3781.                         imul edx,ted_rec_w
  3782.                         sub bx,dx
  3783.                         shl edx,16
  3784.                         add ebx,edx
  3785.                 .in_wnd2:
  3786.                 mov edx,ted_color_wnd_work
  3787.                 int 0x40
  3788.                 ;pop esi
  3789.         @@:
  3790.  
  3791.         .no_clear:
  3792.         popad
  3793.         ret
  3794. endp
  3795.  
  3796. ;input:
  3797. ; edi = pointer to tedit struct
  3798. ;output:
  3799. ; ecx = ­®¢ë© 梥â ᨬ¢®« 
  3800. ; edx = pointer to symbol
  3801. ; edx = 0 if text not in screen
  3802. align 4
  3803. ted_get_first_visible_pos:
  3804.         push eax ecx
  3805.         mov eax,ted_scr_w
  3806.         mov edx,ted_tex
  3807.         xor ecx,ecx
  3808.         @@:
  3809.                 cmp ecx,dword[eax+sb_offs_position]
  3810.                 je @f
  3811.                 call ted_iterat_next
  3812.                 cmp edx,ted_tex_1
  3813.                 jle @f
  3814.                 cmp byte[edx],13
  3815.                 jne @b
  3816.                 inc ecx
  3817.                 jmp @b
  3818. align 4
  3819.         @@:
  3820.  
  3821.         cmp ecx,dword[eax+sb_offs_position]
  3822.         je @f
  3823.                 xor edx,edx
  3824.         @@:
  3825.         cmp ecx,dword[eax+sb_offs_max_area]
  3826.         jle @f
  3827.                 mov dword[eax+sb_offs_max_area],ecx
  3828.         @@:
  3829.         pop ecx eax
  3830.         call ted_opt_draw_line_left
  3831.         ret
  3832.  
  3833. ;input:
  3834. ; edx = pointer to symbol
  3835. ; edi = pointer to tedit struct
  3836. ;output:
  3837. ; ecx = 梥â ᨬ¢®« 
  3838. ; edx = 㪠§ â¥«ì ­  ¯¥à¢ë© «¥¢ë© ᨬ¢®«
  3839. ;description:
  3840. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  3841. align 4
  3842. proc ted_opt_draw_line_left uses ebx
  3843.         mov ebx,ted_scr_h
  3844.         mov ebx,dword[ebx+sb_offs_position]
  3845.         or ebx,ebx
  3846.         jz .ret_f
  3847.         push eax
  3848.         mov eax,edx
  3849.  
  3850.         cmp edx,ted_tex
  3851.         jne @f
  3852.                 call ted_iterat_next
  3853.                 jmp .beg_cycle
  3854.         @@:
  3855.  
  3856.         or ebx,ebx
  3857.         jz @f
  3858.  
  3859.         cmp byte[edx],13
  3860.         jne @f
  3861.                 call ted_iterat_next
  3862.                 .beg_cycle:
  3863.         @@:
  3864.                 cmp edx,ted_tex_1
  3865.                 jle @f
  3866.                 cmp byte[edx],13
  3867.                 je @f
  3868.                 or ebx,ebx
  3869.                 jz @f
  3870. ;--------------------------------------
  3871. xor eax,eax ;eax ¡ã¤¥â ¬¥­ïâìáï
  3872. mov al,byte[edx+1]
  3873. or al,al
  3874. jz .no_color
  3875. cmp eax,ted_colors_text_count
  3876. jge .no_color
  3877.         xor ecx,ecx
  3878.         mov cl,byte[edx+1]
  3879.         shl cx,2
  3880.         add ecx,ted_text_colors
  3881.         mov ecx,dword[ecx]
  3882. .no_color:
  3883. ;--------------------------------------
  3884.                 mov eax,edx
  3885.                 call ted_iterat_next
  3886.                 dec ebx
  3887.                 jmp @b
  3888. align 4
  3889.         @@:
  3890.                 mov edx,eax
  3891.         pop eax
  3892.         .ret_f:
  3893.         call ted_get_symb_color
  3894.         ret
  3895. endp
  3896.  
  3897. ;input:
  3898. ; edx = pointer to symbol
  3899. ; edi = pointer to tedit struct
  3900. ;output:
  3901. ; ecx = symbol color
  3902. ; edx = pointer to 13 symbol
  3903. ;description:
  3904. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  3905. align 4
  3906. proc ted_opt_draw_line_right
  3907.         push eax
  3908.         mov eax,edx
  3909.         @@:
  3910.                 cmp edx,ted_tex_1
  3911.                 jle @f
  3912.                 cmp byte[edx],13
  3913.                 je @f
  3914.                 mov eax,edx
  3915.                 call ted_iterat_next
  3916.                 jmp @b
  3917.         @@:
  3918.         mov edx,eax ;perv sumbol
  3919.         call ted_get_symb_color
  3920.  
  3921.         pop eax
  3922.         ret
  3923. endp
  3924.  
  3925. align 4
  3926. proc ted_mouse, edit:dword
  3927.         pushad
  3928.         mov edi,dword[edit]
  3929.  
  3930.         ;®¡à ¡ â뢠¥¬ áªà®««¨­£¨
  3931.         mov edx,ted_scr_h
  3932.         mov ecx,ted_scr_w
  3933.  
  3934.         cmp word[edx+sb_offs_delta2],0
  3935.         jne .horizontal
  3936.  
  3937.         mov eax,dword[ecx+sb_offs_max_area]
  3938.         cmp eax,dword[ecx+sb_offs_cur_area]
  3939.         jbe .horizontal
  3940.         ; mouse event for Vertical ScrollBar
  3941.         stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
  3942.         cmp dword[ecx+sb_offs_redraw],0
  3943.         je @f
  3944.                 mov dword[ecx+sb_offs_redraw],0
  3945.                 stdcall ted_draw,edi
  3946.                 jmp .no_in_wnd
  3947.         @@:
  3948.         cmp word[ecx+sb_offs_delta2],0
  3949.         jne .no_in_wnd
  3950.         .horizontal:
  3951.         mov eax,dword[edx+sb_offs_max_area]
  3952.         cmp eax,dword[edx+sb_offs_cur_area]
  3953.         jbe .other
  3954.         ; mouse event for Horizontal ScrollBar
  3955.         stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
  3956.         cmp dword[edx+sb_offs_redraw],0
  3957.         je .other
  3958.                 mov dword[edx+sb_offs_redraw],0
  3959.                 stdcall ted_draw,edi
  3960.                 jmp .no_in_wnd
  3961.         .other:
  3962.         cmp word[ecx+sb_offs_delta2],0
  3963.         jne .no_in_wnd
  3964.         cmp word[edx+sb_offs_delta2],0
  3965.         jne .no_in_wnd
  3966.  
  3967.         ;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
  3968.         mcall 37,2 ;get mouse buttons
  3969.         cmp al,1
  3970.         jne @f
  3971.                 mcall 37,1 ;get mouse coords
  3972.                 mov ebx,ted_wnd_t
  3973.                 add ebx,ted_rec_t
  3974.                 cmp ax,bx
  3975.                 jl @f ;y_mouse<y_wnd
  3976.  
  3977.                 sub ebx,ted_rec_t
  3978.                 add ebx,ted_wnd_h
  3979.                 cmp bx,ax
  3980.                 jl @f ;y_mouse>y_wnd
  3981.  
  3982.                 mov ebx,ted_wnd_l
  3983.                 add ebx,ted_rec_l
  3984.                 mov ecx,eax
  3985.                 shr ecx,16
  3986.                 cmp cx,bx
  3987.                 jl @f ;x_mouse<x_wnd
  3988.  
  3989.                 sub ebx,ted_rec_l
  3990.                 add ebx,ted_wnd_w
  3991.                 cmp bx,cx
  3992.                 jl @f ;x_mouse>x_wnd
  3993.  
  3994.                 call ted_draw_cursor_sumb
  3995.                 call ted_wnd_main_click
  3996.                 jmp .no_in_wnd
  3997.         @@:
  3998.         mov edx,ted_el_focus
  3999.         cmp dword[edx],edi
  4000.         jne @f
  4001.                 call ted_wnd_main_mouse_scroll ;ᬮâਬ ­  ¯à®ªàãâªã ª®«¥á  ¬ëè¨
  4002.         @@:
  4003.         cmp ted_drag_m,0
  4004.         je .no_in_wnd
  4005.                 mov ted_drag_m,0
  4006.                 stdcall ted_draw,edi
  4007.                 cmp ted_fun_draw_panel_buttons,0
  4008.                 je .no_in_wnd
  4009.                         call ted_fun_draw_panel_buttons
  4010.         .no_in_wnd:
  4011.         popad
  4012.         ret
  4013. endp
  4014.  
  4015. ;input:
  4016. ; eax -> (x,y)
  4017. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  4018. ;description:
  4019. ; äã­ªæ¨ï ¢ë§ë¢¥âáï ¯à¨ ­ ¦ â¨¨ ª­®¯ª®© ¬ëè¨ ¨ ¯®¯ ¤¥­¨¨ ªãàá®à®¬ ¢ ®ª­® । ªâ®à 
  4020. align 4
  4021. ted_wnd_main_click:
  4022.         push ebx ecx edx
  4023.         mov ebx,ted_el_focus
  4024.         mov dword[ebx],edi ;áâ ¢¨¬ 䮪ãá
  4025.  
  4026.         push eax
  4027.                 shr eax,16
  4028.                 sub eax,ted_wnd_l
  4029.                 sub eax,ted_rec_l
  4030.  
  4031.                 xor edx,edx
  4032.                 mov ecx,ted_rec_w
  4033.                 div cx
  4034.                 ;inc eax
  4035.                 mov ebx,ted_scr_h
  4036.                 cmp eax,dword[ebx+sb_offs_cur_area]
  4037.                 jle @f
  4038.                         mov eax,dword[ebx+sb_offs_cur_area]
  4039.                 @@:
  4040.                 ;dec eax
  4041.                 mov ted_cur_x,eax
  4042.         pop eax
  4043.  
  4044.         push eax
  4045.                 and eax,0xffff
  4046.                 sub eax,ted_wnd_t
  4047.                 sub eax,ted_rec_t
  4048.  
  4049.                 xor edx,edx
  4050.                 mov ecx,ted_rec_h
  4051.                 div cx
  4052.                 inc eax
  4053.                 mov ebx,ted_scr_w
  4054.                 cmp eax,dword[ebx+sb_offs_cur_area]
  4055.                 jle @f
  4056.                         mov eax,dword[ebx+sb_offs_cur_area]
  4057.                 @@:
  4058.                 dec eax
  4059.                 mov ted_cur_y,eax
  4060.         pop eax
  4061.  
  4062.         cmp ted_drag_m,0
  4063.         je @f
  4064.                 call ted_sel_move
  4065.                 jmp .sel_move
  4066.         @@:
  4067.                 mov ted_drag_m,1
  4068.                 call ted_sel_start
  4069.         .sel_move:
  4070.         pop edx ecx ebx
  4071.         ret
  4072.  
  4073. ;input:
  4074. ; edi = pointer to tedit struct
  4075. align 4
  4076. ted_wnd_main_mouse_scroll:
  4077.         push eax ebx ecx
  4078.         mcall 37,7 ;¯à®ªàã⪠ ª®«¥á  ¬ëè¨
  4079.         cmp ax,0
  4080.         je .no_scroll
  4081.                 mov ecx,ted_scr_w
  4082.                 mov ebx,dword[ecx+sb_offs_position] ;copy old scroll position
  4083.                 and eax,0xffff
  4084.                 btr ax,15
  4085.                 jae @f
  4086.                         or eax,0xffff8000
  4087.                 @@:
  4088.                 add dword[ecx+sb_offs_position],eax
  4089.  
  4090.                 mov eax,[ecx+sb_offs_position]
  4091.                 cmp eax,[ecx+sb_offs_max_area]
  4092.                 jb @f
  4093.                         mov dword[ecx+sb_offs_position],ebx ;if scroll position out of range
  4094.                         jmp .no_scroll
  4095.                 @@:
  4096.                 stdcall ted_draw,edi
  4097.         .no_scroll:
  4098.         pop ecx ebx eax
  4099.         ret
  4100.  
  4101. align 4
  4102. proc ted_save_file, edit:dword, file:dword, f_name:dword
  4103.   pushad
  4104.   mov edi,dword[edit]
  4105.  
  4106.   stdcall ted_can_save,edi
  4107.   cmp al,0
  4108. ;  je .no_save
  4109.  
  4110.   mov ecx,ted_max_chars
  4111.   invoke mem.alloc,ecx
  4112.   push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4113.  
  4114.   mov edx,ted_tex
  4115.   xor ecx,ecx
  4116.   @@:
  4117.     call ted_iterat_next
  4118.     cmp edx,ted_tex_1
  4119.     jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
  4120.     mov bl,[edx]
  4121.     mov byte[eax],bl
  4122.     inc eax
  4123.     inc ecx
  4124.     jmp @b
  4125.   @@:
  4126.  
  4127.   cmp ecx,0
  4128.   je @f
  4129.     mov ebx,dword[file]
  4130.     pop eax ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4131.     mov dword[ebx+16],eax
  4132.     push eax ;®¡à â­® § ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4133.     mov eax,70
  4134.     mov dword[ebx], 2
  4135.     mov dword[ebx+4], 0
  4136.     mov dword[ebx+8], 0
  4137.     mov dword[ebx+12], ecx
  4138.     mov  byte[ebx+20], 0
  4139.     push dword[f_name]
  4140.     pop dword[ebx+21]
  4141.     int 0x40
  4142.  
  4143.     mov ted_err_save,al
  4144.  
  4145.     cmp eax,0
  4146.     je .no_msg
  4147. ;    cmp eax,6
  4148. ;    je @f
  4149.       cmp ax,10
  4150.       jl .zifra_0_9
  4151.         mov al,'?'
  4152.         sub ax,48
  4153.       .zifra_0_9:
  4154.       add ax,48
  4155. cmp ted_fun_save_err,0
  4156. je @f
  4157. call ted_fun_save_err
  4158.       jmp @f
  4159.     .no_msg:
  4160.     m2m ted_tim_ls,ted_tim_ch
  4161.   @@:
  4162.  
  4163.   pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4164.   invoke mem.free,ecx
  4165.   .no_save:
  4166.   popad
  4167.   ret
  4168. endp
  4169. }