Subversion Repositories Kolibri OS

Rev

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

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