Subversion Repositories Kolibri OS

Rev

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

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