Subversion Repositories Kolibri OS

Rev

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

  1. ; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
  2. ; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
  3. ; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 22.08.2011 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 edi
  2343.         mov edi,dword[edit]
  2344.  
  2345.         mov eax,70
  2346.         mov ebx,dword[file]
  2347.         mov dword[ebx], 0
  2348.         mov dword[ebx+4], 0
  2349.         mov dword[ebx+8], 0
  2350.         m2m dword[ebx+12], ted_max_chars ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©« 
  2351.         m2m dword[ebx+16], ted_tex
  2352.         mov  byte[ebx+20], 0
  2353.         push dword[f_name]
  2354.         pop dword[ebx+21]
  2355.         int 0x40
  2356.  
  2357.         cmp eax,0
  2358.         je @f
  2359.         cmp eax,6
  2360.         je @f
  2361.                 jmp .ret_f
  2362.         @@:
  2363.         cmp ebx,-1
  2364.         je .ret_f
  2365.                 ;if open file
  2366.                 call ted_on_open_file
  2367.         .ret_f:
  2368.         pop edi
  2369.         ret
  2370. endp
  2371.  
  2372. align 4
  2373. proc ted_but_select_word, edit:dword
  2374.         pushad
  2375.         mov edi,dword[edit]
  2376.  
  2377.         call ted_get_pos_by_cursor
  2378.         push edx
  2379.                 call ted_iterat_perv_color_tag
  2380.                 cmp edx,ted_tex_1
  2381.                 jle @f
  2382.                         call ted_get_text_coords
  2383.                         mov ted_sel_x0,ebx
  2384.                         mov ted_sel_y0,eax
  2385.                 @@:
  2386.         pop edx
  2387.         call ted_iterat_next_color_tag
  2388.         cmp edx,ted_tex_1
  2389.         jle @f
  2390.                 call ted_get_text_coords
  2391.                 mov ted_sel_x1,ebx
  2392.                 mov ted_sel_y1,eax
  2393.         @@:
  2394.  
  2395.         cmp ted_fun_draw_panel_buttons,0
  2396.         je @f
  2397.                 call ted_fun_draw_panel_buttons
  2398.         @@:
  2399.         stdcall ted_draw,edi
  2400.         popad
  2401.         ret
  2402. endp
  2403.  
  2404. align 4
  2405. proc ted_but_cut, edit:dword
  2406.         push edi
  2407.         mov edi,dword[edit]
  2408.  
  2409.         stdcall ted_but_copy,edi
  2410.         call ted_set_undo
  2411.         stdcall ted_sel_text_del,ted_opt_ed_change_time
  2412.  
  2413.         cmp al,1
  2414.         jne @f
  2415.                 stdcall ted_draw,edi
  2416.                 cmp ted_fun_draw_panel_buttons,0
  2417.                 je @f
  2418.                         call ted_fun_draw_panel_buttons
  2419.         @@:
  2420.         pop edi
  2421.         ret
  2422. endp
  2423.  
  2424. ;output:
  2425. ; al = 1 if copy text
  2426. align 4
  2427. proc ted_but_copy, edit:dword
  2428.         pushad
  2429.         mov edi,dword[edit]
  2430.  
  2431.         call ted_is_select
  2432.         cmp al,0
  2433.         je .end_f ;if not selected text
  2434.         call ted_sel_normalize
  2435.  
  2436.         mov esi,ted_seln_x1
  2437.         mov ecx,ted_seln_y1
  2438.         call ted_get_pos_by_coords
  2439.         mov ebx,edx
  2440.         mov esi,ted_seln_x0
  2441.         mov ecx,ted_seln_y0
  2442.         call ted_get_pos_by_coords
  2443.         mov esi,ebx
  2444.  
  2445.         xor ecx,ecx
  2446.         mov ebx,ted_buffer
  2447.         ;mov edx,ted_tex
  2448.         @@:
  2449.                 cmp edx,ted_tex_1 ;end of file
  2450.                 jle @f
  2451.                 cmp edx,esi ;end of select
  2452.                 je @f
  2453.                 inc ecx
  2454.                 cmp ecx,ted_buffer_size ;owerflow bufer
  2455.                 je @f
  2456.  
  2457.                 mov al,byte[edx]
  2458.                 mov byte[ebx],al
  2459.                 inc ebx
  2460.  
  2461.                 call ted_iterat_next
  2462.                 jmp @b
  2463.         @@:
  2464.         add ecx,ted_buffer
  2465.         mov byte[ebx],0
  2466.  
  2467.         cmp ecx,0
  2468.         je .end_f
  2469.                 call ted_draw_buffer
  2470.                 cmp ted_fun_draw_panel_buttons,0
  2471.                 je .end_f
  2472.                         call ted_fun_draw_panel_buttons
  2473.         .end_f:
  2474.         popad
  2475.         ret
  2476. endp
  2477.  
  2478.  
  2479. align 4
  2480. proc ted_but_paste, edit:dword
  2481.         push eax ebx esi edi
  2482.         mov edi,dword[edit]
  2483.  
  2484.         mov esi,ted_buffer
  2485.         call tl_strlen
  2486.         cmp eax,1
  2487.         jl @f
  2488.                 mov esi,eax
  2489.                 call ted_set_undo
  2490.                 mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  2491.                 stdcall ted_sel_text_del,ebx
  2492.                 cmp al,1
  2493.                 jne .del
  2494.                         mov ebx,ted_opt_ed_move_cursor
  2495.                 .del:
  2496.                 stdcall ted_text_add,edi,ted_buffer,esi,ebx
  2497.                 stdcall ted_draw,edi
  2498.                 cmp ted_fun_draw_panel_buttons,0
  2499.                 je @f
  2500.                         call ted_fun_draw_panel_buttons
  2501.         @@:
  2502.         pop edi esi ebx eax
  2503.         ret
  2504. endp
  2505.  
  2506. align 4
  2507. proc ted_but_sumb_upper uses edi esi, edit:dword
  2508.         mov edi,dword[edit]
  2509.  
  2510.         stdcall ted_convert_sel_text,fb_char_toupper
  2511.         cmp esi,0
  2512.         je @f
  2513.                 stdcall ted_draw,edi
  2514.         @@:
  2515.         ret
  2516. endp
  2517.  
  2518. align 4
  2519. proc ted_but_sumb_lover uses edi esi, edit:dword
  2520.         mov edi,dword[edit]
  2521.  
  2522.         stdcall ted_convert_sel_text,fb_char_todown
  2523.         cmp esi,0
  2524.         je @f
  2525.                 stdcall ted_draw,edi
  2526.         @@:
  2527.         ret
  2528. endp
  2529.  
  2530. align 4
  2531. proc ted_but_reverse, edit:dword
  2532.   push eax ebx edi
  2533.   mov edi,dword[edit]
  2534.  
  2535.   call ted_is_select
  2536.   cmp al,0
  2537.   je @f
  2538.     call ted_sel_normalize
  2539.     push esi ecx edx
  2540.       mov esi,ted_seln_x0
  2541.       mov ecx,ted_seln_y0
  2542.       call ted_get_pos_by_coords
  2543.       mov eax,edx
  2544.       mov esi,ted_seln_x1
  2545.       cmp esi,0
  2546.       je .beg_str
  2547.         dec esi
  2548.       .beg_str:
  2549.       mov ecx,ted_seln_y1
  2550.       call ted_get_pos_by_coords
  2551.       ;call ted_get_text_perv_pos
  2552.       mov ebx,edx
  2553.     pop edx ecx esi
  2554.     ;cmp eax,...
  2555.     ;je @f
  2556.     call ted_revers
  2557.   @@:
  2558.   stdcall ted_draw,edi
  2559.   pop edi ebx eax
  2560.   ret
  2561. endp
  2562.  
  2563. align 4
  2564. proc ted_but_undo, edit:dword
  2565.         push eax edi
  2566.         mov edi,dword[edit]
  2567.  
  2568.         mov eax,ted_tim_undo
  2569.         cmp ted_tim_ch,eax
  2570.         jbe @f
  2571.                 inc ted_tim_undo
  2572.                 ;call ted_text_colored
  2573.                 stdcall ted_draw,edi
  2574.                 cmp ted_fun_draw_panel_buttons,0
  2575.                 je @f
  2576.                         call ted_fun_draw_panel_buttons
  2577.         @@:
  2578.         pop edi eax
  2579.         ret
  2580. endp
  2581.  
  2582. align 4
  2583. proc ted_but_redo, edit:dword
  2584.         push edi
  2585.         mov edi,dword[edit]
  2586.  
  2587.         cmp ted_tim_undo,1
  2588.         jb @f
  2589.                 dec ted_tim_undo
  2590.                 ;call ted_text_colored
  2591.                 stdcall ted_draw,edi
  2592.                 cmp ted_fun_draw_panel_buttons,0
  2593.                 je @f
  2594.                         call ted_fun_draw_panel_buttons
  2595.         @@:
  2596.         pop edi
  2597.         ret
  2598. endp
  2599.  
  2600. align 4
  2601. proc ted_but_find_next, edit:dword
  2602.         pushad
  2603.         mov edi,dword[edit]
  2604.  
  2605.         call ted_get_pos_by_cursor
  2606.         mov eax,ted_buffer_find
  2607.         mov bl,byte[eax]
  2608.         @@:
  2609.                 call ted_get_find_rezult
  2610.                 cmp bh,1
  2611.                 je @f ; find
  2612.                         call ted_iterat_next
  2613.                         cmp edx,ted_tex_1
  2614.                         jle @f
  2615.                         jmp @b
  2616.         @@:
  2617.         cmp bh,0
  2618.         je @f
  2619.                 call ted_get_text_coords
  2620.                 inc ebx ;move cursor right
  2621.                 mov ted_sel_x1,ebx
  2622.                 mov ted_sel_y1,eax
  2623.                 mov edx,eax
  2624.                 mov ecx,ebx
  2625.                 call ted_go_to_pos
  2626.                 mov edx,esi ;esi ¡ë«® ãáâ ­®¢«¥® ¢ ted_get_find_rezult
  2627.                 call ted_get_text_coords
  2628.                 mov ted_sel_x0,ebx
  2629.                 mov ted_sel_y0,eax
  2630.                 stdcall ted_draw,edi
  2631.                 jmp .end_find
  2632.         @@:
  2633.                 ;¯®¯ ¤ ¥¬ á ¥á«¨ ⥪áâ ­¥ ­ ©¤¥­
  2634.                 cmp ted_fun_find_err,0
  2635.                 je .end_find
  2636.                         call ted_fun_find_err ;¯®«ì§®¢ â¥«ì᪠ï äã­ªæ¨ï
  2637.         .end_find:
  2638.         popad
  2639.         ret
  2640. endp
  2641.  
  2642. ;input:
  2643. ; edi = pointer to tedit struct
  2644. align 4
  2645. ted_key_ctrl_home:
  2646.         mov ted_cur_x,0
  2647.         mov ted_cur_y,0
  2648.         push eax
  2649.                 mov eax,ted_scr_w
  2650.                 mov dword[eax+sb_offs_position],0
  2651.                 mov eax,ted_scr_h
  2652.                 mov dword[eax+sb_offs_position],0
  2653.         pop eax
  2654.         stdcall ted_draw,edi
  2655.         cmp ted_fun_draw_panel_buttons,0
  2656.         je @f
  2657.                 call ted_fun_draw_panel_buttons
  2658.         @@:
  2659.         ret
  2660.  
  2661. ;input:
  2662. ; edi = pointer to tedit struct
  2663. align 4
  2664. proc ted_sel_key_up
  2665.   cmp ted_drag_k,1
  2666.   je @f
  2667.     call ted_sel_start
  2668.     mov ted_drag_k,1
  2669.   @@:
  2670.   push dx
  2671.     call ted_cur_move_up
  2672.     cmp dl,8
  2673.     jne @f
  2674.       call ted_scroll_set_redraw
  2675.     @@:
  2676.   pop dx
  2677.   call ted_sel_move
  2678.   stdcall ted_draw,edi
  2679.   ret
  2680. endp
  2681.  
  2682. ;input:
  2683. ; edi = pointer to tedit struct
  2684. align 4
  2685. proc ted_sel_key_down
  2686.   cmp ted_drag_k,1
  2687.   je @f
  2688.     call ted_sel_start
  2689.     mov ted_drag_k,1
  2690.   @@:
  2691.   push dx
  2692.     call ted_cur_move_down
  2693.     cmp dl,8
  2694.     jne @f
  2695.       call ted_scroll_set_redraw
  2696.     @@:
  2697.   pop dx
  2698.   call ted_sel_move
  2699.   stdcall ted_draw,edi
  2700.   ret
  2701. endp
  2702.  
  2703. ;input:
  2704. ; edi = pointer to tedit struct
  2705. align 4
  2706. proc ted_sel_key_left
  2707.   cmp ted_drag_k,1
  2708.   je @f
  2709.     call ted_sel_start
  2710.   @@:
  2711.   push dx
  2712.     call ted_cur_move_left
  2713.     call ted_sel_move
  2714.     cmp ted_drag_k,1
  2715.     je @f
  2716.       mov ted_drag_k,1
  2717.       mov dl,8
  2718.     @@:
  2719.     cmp dl,8
  2720.     jne @f
  2721.       call ted_scroll_set_redraw
  2722.       stdcall ted_draw,edi
  2723.       jmp .end_f
  2724.     @@:
  2725.       stdcall ted_draw_cur_line,edi
  2726.     .end_f:
  2727.   pop dx
  2728.   ret
  2729. endp
  2730.  
  2731. ;input:
  2732. ; edi = pointer to tedit struct
  2733. align 4
  2734. proc ted_sel_key_right
  2735.   cmp ted_drag_k,1
  2736.   je @f
  2737.     call ted_sel_start
  2738.   @@:
  2739.   push dx
  2740.     call ted_cur_move_right
  2741.     call ted_sel_move
  2742.     cmp ted_drag_k,1
  2743.     je @f
  2744.       mov ted_drag_k,1
  2745.       mov dl,8
  2746.     @@:
  2747.     cmp dl,8
  2748.     jne @f
  2749.       call ted_scroll_set_redraw
  2750.       stdcall ted_draw,edi
  2751.       jmp .end_f
  2752.     @@:
  2753.       stdcall ted_draw_cur_line,edi
  2754.     .end_f:
  2755.   pop dx
  2756.   ret
  2757. endp
  2758.  
  2759. ;input:
  2760. ; edi = pointer to tedit struct
  2761. ;description:
  2762. ; this function need to optimize output
  2763. align 4
  2764. proc ted_draw_cursor_sumb
  2765.   pushad
  2766.  
  2767.   mov eax,13 ;rect
  2768.   mov ebx,ted_wnd_l
  2769.   add ebx,ted_rec_l
  2770.   mov edx,ted_cur_x
  2771.   imul edx,ted_rec_w
  2772.   add ebx,edx
  2773.   shl ebx,16
  2774.   add ebx,ted_rec_w
  2775.  
  2776.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  2777.   add ecx,ted_rec_t
  2778.   mov edx,ted_cur_y
  2779.   imul edx,ted_rec_h
  2780.   add ecx,edx
  2781.   shl ecx,16
  2782.   add ecx,ted_rec_h
  2783.  
  2784.   mov edx,ted_color_wnd_work
  2785.   push ecx
  2786.     call ted_sel_normalize
  2787.  
  2788.     mov esi,ted_scr_w
  2789.         mov ecx,dword[esi+sb_offs_position]
  2790.     sub ted_seln_y0,ecx
  2791.     sub ted_seln_y1,ecx
  2792.  
  2793.     mov ecx,ted_cur_y
  2794.     cmp ecx,ted_seln_y0
  2795.     jl .no_cur_sel
  2796.     cmp ecx,ted_seln_y1
  2797.     jg .no_cur_sel
  2798.     mov edx,ted_color_select ;¬¥­ï¥¬ 梥â ä®­  ­  梥⠢뤥«¥­¨ï
  2799.    
  2800.     mov esi,ted_scr_h
  2801.         cmp ecx,ted_seln_y0
  2802.     jne @f
  2803.       mov ecx,ted_cur_x
  2804.       add ecx,dword[esi+sb_offs_position]
  2805.       cmp ecx,ted_seln_x0
  2806.       jge @f
  2807.       mov edx,ted_color_wnd_work
  2808.     @@:
  2809.  
  2810.     mov ecx,ted_cur_y
  2811.     cmp ecx,ted_seln_y1
  2812.     jne .no_cur_sel
  2813.       mov ecx,ted_cur_x
  2814.       add ecx,dword[esi+sb_offs_position]
  2815.       cmp ecx,ted_seln_x1
  2816.       jl .no_cur_sel
  2817.       mov edx,ted_color_wnd_work
  2818.  
  2819.     .no_cur_sel:
  2820.   pop ecx
  2821.   int 0x40 ;à¨á®¢ ­¨¥ ¯àאַ㣮«ì­¨ª 
  2822.  
  2823.   call ted_get_pos_by_cursor ;¡¥à¥¬ ¯®§¨æ¨î ᨬ¢®« 
  2824.   cmp ted_gp_opt,2
  2825.   jne @f
  2826.     mov eax,4
  2827.     mov esi,1
  2828.     ror ecx,16
  2829.     mov bx,cx
  2830.     add ebx,0x10001
  2831.     call ted_get_symb_color
  2832.     call ted_convert_invis_symb
  2833.     int 0x40 ;à¨á®¢ ­¨¥ ᨬ¢®« 
  2834.   @@:
  2835.  
  2836.   popad
  2837.   ret
  2838. endp
  2839.  
  2840. ;input:
  2841. ; edx -> pointer to text
  2842. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  2843. ;output:
  2844. ; ecx = color
  2845. ; if ted_mode_color=0 then ecx=ted_color_wnd_text
  2846. align 4
  2847. ted_get_symb_color:
  2848.   mov ecx,ted_color_wnd_text ;§ ¤ ¥¬ 梥â ⥪áâ  ¯® 㬮«ç ­¨î
  2849.  
  2850.   push eax edx
  2851.   cmp ted_mode_color,0
  2852.   je .exit
  2853.     jmp .on_first
  2854.     @@:
  2855.       call ted_iterat_perv
  2856.       cmp edx,ted_tex_1
  2857.       jle .exit
  2858.     .on_first:
  2859.       xor eax,eax
  2860.       mov al,byte[edx+1]
  2861.       cmp al,0 ;¥á«¨ al=0 ⮠梥⠭¥ ¬¥­ï¥âáï
  2862.     je @b
  2863.  
  2864.     cmp eax,ted_colors_text_count
  2865.     jge .exit
  2866.  
  2867.     shl ax,2 ;㬭®¦ ¥¬ ¨­¤¥ªá æ¢¥â  ­  4 ¡ ©â 
  2868.     mov ecx,ted_text_colors ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 1-£® 梥â 
  2869.     add ecx,eax
  2870.     mov ecx,dword[ecx] ;ãáâ ­ ¢«¨¢ ¥¬ ⥪ã騩 梥â ⥪áâ  ¯® ᬥ饭¨î
  2871.   .exit:
  2872.   pop edx eax
  2873.   ret
  2874.  
  2875. ;input:
  2876. ; edx = pointer to text
  2877. ; edi = pointer to tedit struct
  2878. ;description:
  2879. ; ”ã­ªæ¨ï ¯à¥®¡à §ã¥â ­¥¢¨¤¨¬ë¥ ᨬ¢®«ë ¢ ¯¥ç â ¥¬ë¥ ­  íªà ­¥
  2880. align 4
  2881. ted_convert_invis_symb:
  2882.         cmp ted_mode_invis,1
  2883.         jne .end_f
  2884.                 cmp byte[edx],9
  2885.                 jne @f
  2886.                         lea edx,[ted_symbol_tab]
  2887.                 @@:
  2888.                 cmp byte[edx],13
  2889.                 jne @f
  2890.                         mov edx,edi
  2891.                         add edx,ted_offs_symbol_new_line
  2892.                 @@:
  2893.         .end_f:
  2894.         ret
  2895.  
  2896. ;input:
  2897. ; edi = pointer to tedit struct
  2898. align 4
  2899. ted_scroll_set_redraw:
  2900.         push eax
  2901.         mov eax,ted_scr_w
  2902.         mov dword[eax+sb_offs_redraw],1
  2903.         mov eax,ted_scr_h
  2904.         mov dword[eax+sb_offs_redraw],1
  2905.         pop eax
  2906.         ret
  2907.  
  2908. align 4
  2909. proc ted_draw, edit:dword
  2910.         locals
  2911.                 line_num dd ?
  2912.         endl
  2913.         pushad
  2914.         mov edi,dword[edit]
  2915.  
  2916.         mov eax,4 ;draw text
  2917.         mov ecx,ted_text_colors
  2918.         mov ecx,dword[ecx]
  2919.  
  2920.         mov ebx,ted_wnd_l
  2921.         add ebx,ted_rec_l
  2922.         shl ebx,16
  2923.         add ebx,ted_wnd_t
  2924.         add ebx,ted_rec_t
  2925.         add ebx,0x10001 ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  2926.  
  2927.         call ted_sel_normalize ;need before draw select
  2928.         mov esi,ted_scr_w
  2929.         mov esi,dword[esi+sb_offs_position]
  2930.         mov dword[line_num],esi
  2931.  
  2932.         stdcall ted_clear_line_before_draw, edi,ebx,1,esi
  2933.         call ted_get_first_visible_pos
  2934.         cmp edx,0
  2935.         je .no_draw_text
  2936.         mov esi,1 ;¤«¨­­  ¢ë¢®¤¨¬®£® ⥪áâ  ¯® 1-¬ã ᨬ¢®«ã
  2937.         @@:
  2938.                 call ted_iterat_next
  2939.                 cmp edx,ted_tex_1
  2940.                 jle .no_draw_text
  2941.  
  2942.                 ; *** 梥⮢ ï à §¬¥âª 
  2943.                 cmp ted_mode_color,0
  2944.                 je .no_col_change
  2945.                 cmp byte[edx+1],0
  2946.                 je .no_col_change
  2947.                         call ted_get_symb_color
  2948.                 .no_col_change:
  2949.  
  2950.                 cmp byte [edx],13
  2951.                 jne .no_13
  2952.                         cmp ted_mode_invis,1
  2953.                         jne .no_invis
  2954.                                 push edx
  2955.                                 mov edx,edi
  2956.                                 add edx,ted_offs_symbol_new_line
  2957.                                 int 0x40
  2958.                                 pop edx
  2959.                         .no_invis:
  2960.                         add ebx,ted_rec_h
  2961.                         ;optimized output \/
  2962.                         mov eax,ted_wnd_h
  2963.                         add eax,ted_wnd_t
  2964.                         cmp bx,ax
  2965.                         jg .no_draw_text
  2966.                         mov eax,4
  2967.                         ;optimized output /\        
  2968.                         and ebx,0xffff
  2969.                         ror ebx,16
  2970.                         add ebx,ted_wnd_l
  2971.                         add ebx,ted_rec_l
  2972.                         inc ebx
  2973.                         ror ebx,16
  2974.                         inc dword[line_num] ;increment line number
  2975.                         stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
  2976.                         call ted_opt_draw_line_left
  2977.                         jmp @b
  2978.                 .no_13:
  2979.  
  2980.                 int 0x40
  2981.                 ror ebx,16
  2982.                 add ebx,ted_rec_w
  2983.                 mov esi,ted_wnd_l
  2984.                 add esi,ted_wnd_w
  2985.                 cmp bx,si
  2986.                 jl .no_opt
  2987.                         call ted_opt_draw_line_right
  2988.                 .no_opt:
  2989.                 mov si,1
  2990.                 ror ebx,16
  2991.                 jmp @b
  2992.         .no_draw_text:
  2993.  
  2994.         stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
  2995.         call ted_draw_line_numbers
  2996.         call ted_draw_main_cursor
  2997.  
  2998. ;---------------------------------------------
  2999. ; set all_redraw flag for draw all ScrollBar
  3000. ; In some cases it is necessity to draw only the area
  3001. ; of moving of a "runner", for acceleration of output -
  3002. ; in this case the flag needs to be reset to 0 (zero).
  3003.         mov eax,ted_scr_h
  3004.         mov esi,ted_scr_w
  3005.         mov dword[eax+sb_offs_all_redraw],1
  3006.         mov dword[esi+sb_offs_all_redraw],1
  3007.  
  3008. ; à¨á®¢ ­¨¥ ¯®«®á ¯à®ªàã⪨
  3009.         stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
  3010.         stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
  3011. ; reset all_redraw flag
  3012.         mov dword[eax+sb_offs_all_redraw],0
  3013.         mov dword[esi+sb_offs_all_redraw],0
  3014. ;---------------------------------------------
  3015.  
  3016.   ;left-bottom square
  3017.   mov ebx,ted_wnd_l
  3018.   shl ebx,16
  3019.   add ebx,ted_rec_l
  3020.   mov ecx,ted_wnd_t
  3021.   add ecx,ted_wnd_h
  3022.   shl ecx,16
  3023.   mov cx,word[eax+sb_offs_size_y]
  3024.   inc cx
  3025.   mov edx,ted_color_wnd_capt ;[sc.work]
  3026.   mov eax,13
  3027.   int 0x40
  3028.  
  3029.         ;right-bottom square
  3030.         mov ebx,ted_wnd_l
  3031.         add ebx,ted_wnd_w
  3032.         shl ebx,16
  3033.         mov bx,word[esi+sb_offs_size_x]
  3034.         inc bx
  3035.         int 0x40
  3036.  
  3037.         cmp ted_fun_draw_panel_find,0
  3038.         je @f
  3039.                 call ted_fun_draw_panel_find
  3040.         @@:
  3041.         cmp ted_fun_draw_panel_syntax,0
  3042.         je @f
  3043.                 call ted_fun_draw_panel_syntax
  3044.         @@:
  3045.         popad
  3046.         ret
  3047. endp
  3048.  
  3049. ;input:
  3050. ; edi = pointer to tedit struct
  3051. align 4
  3052. proc ted_draw_main_cursor
  3053.   pushad
  3054.  
  3055.   mov eax,13 ;draw cursor
  3056.   mov ecx,ted_wnd_t ;calc rect -> y0,y1
  3057.   add ecx,ted_rec_t
  3058.   mov edx,ted_cur_y
  3059.   imul edx,ted_rec_h
  3060.   add ecx,edx
  3061.  
  3062.   cmp ted_cur_ins,1 ;¯à®¢¥àª  ०¨¬  à ¡®âë ªãàá®à  (®¡ëç­ë© ¨«¨ ¢áâ ¢ª )
  3063.   jne @f
  3064.     mov edx,ted_rec_h
  3065.     inc edx   ;1->1, 3->2, 5->3, ...
  3066.     shr edx,1 ;edx = ¢ëá®â  áâப¨ ¤¥«¥­­ ï ­  2 (ª®£¤  ªãàá®à ­¥ ¯®«­ë©)
  3067.     add ecx,edx
  3068.   @@:
  3069.   shl ecx,16
  3070.   add ecx,ted_rec_h
  3071.   cmp ted_cur_ins,1
  3072.   jne @f
  3073.     shr cx,1 ;¤¥«¨¬ ¢ëá®âã ªãàá®à  ­  2
  3074.   @@:
  3075.  
  3076.   mov ebx,ted_wnd_l ;calc rect -> x0,x1
  3077.   add ebx,ted_rec_l
  3078.   mov edx,ted_cur_x
  3079.   imul edx,ted_rec_w
  3080.   add ebx,edx
  3081.   shl ebx,16
  3082.   add ebx,ted_rec_w
  3083.  
  3084.   mov edx,ted_color_cursor
  3085.   int 0x40 ;¢ë¢®¤ ªãàá®à 
  3086.  
  3087.   call ted_get_pos_by_cursor
  3088.   cmp ted_gp_opt,2
  3089.   jne @f
  3090.     mov eax,4 ;draw text
  3091.     mov esi,1
  3092.     ror ecx,16
  3093.     mov bx,cx
  3094.     add ebx,0x10001
  3095.     cmp ted_cur_ins,1
  3096.     jne .no_up_tetx
  3097.       mov ecx,ted_rec_h
  3098.       inc cx ; 1->1, 3->2, 5->3, ...
  3099.       shr cx,1
  3100.       sub bx,cx
  3101.     .no_up_tetx:
  3102.     mov ecx,ted_color_cur_text
  3103.     call ted_convert_invis_symb
  3104.     int 0x40
  3105.   @@:
  3106.  
  3107.   mov eax,4
  3108.   mov ebx,ted_wnd_l
  3109.   add ebx,ted_rec_l
  3110.   shl ebx,16
  3111.   add ebx,ted_wnd_t
  3112.   add ebx,3
  3113.   mov ecx,ted_color_wnd_bord
  3114.   or  ecx,0x80000000
  3115.   lea edx,[txtRow]
  3116.   int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‘âப '
  3117.  
  3118.   add ebx,0x500000
  3119.   lea edx,[txtCol]
  3120.   int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‡­ ª'
  3121.  
  3122.   cmp ted_tim_undo,0
  3123.   je @f
  3124.     add ebx,0x500000
  3125.     lea edx,[txtOtm]
  3126.     int 0x40
  3127.     sub ebx,0x500000
  3128.   @@:
  3129.  
  3130.   call ted_draw_buffer
  3131.   call ted_draw_help_f1
  3132.  
  3133.   mov eax,47 ;draw cursor coords
  3134.   mov esi,ted_color_wnd_bord
  3135.   or  esi,0x40000000
  3136.  
  3137.   mov edx,ebx
  3138.   ror edx,16
  3139.   sub edx,35
  3140.   ror edx,16
  3141.   ;add edx,3
  3142.   mov ebx,0x40000 ;Row=...
  3143.   mov ecx,ted_scr_w
  3144.   mov ecx,dword[ecx+sb_offs_position]
  3145.   add ecx,ted_cur_y
  3146.   inc ecx
  3147.  
  3148. push edi
  3149.   mov edi,ted_color_wnd_work
  3150.   int 0x40 ;¢ë¢®¤ ç¨á«  ⥪ã饩 áâப¨
  3151. pop edi
  3152.  
  3153.   ;mov ebx,0x40000 ;Col=...
  3154.   mov ecx,ted_scr_h
  3155.   mov ecx,dword[ecx+sb_offs_position]
  3156.   add ecx,ted_cur_x
  3157.   inc ecx
  3158.   add edx,0x500000
  3159. push edi
  3160.   mov edi,ted_color_wnd_work
  3161.   int 0x40 ;¢ë¢®¤ ç¨á«  §­ ª®¢
  3162. pop edi
  3163.  
  3164.   cmp ted_tim_undo,0
  3165.   je @f
  3166.     mov ecx,ted_tim_undo
  3167.     add edx,0x500000
  3168.         mov edi,ted_color_wnd_work ;¯®à⨬ ॣ¨áâà edi, ­® ¢ ª®­æ¥ ä㭪樨 í⮠㦥 ­¥ ¢ ¦­®
  3169.     int 0x40 ;¢ë¢®¤ ç¨á«  ®â¬¥­¥­­ëå ¤¥©á⢨©
  3170.   @@:
  3171.  
  3172.   popad
  3173.   ret
  3174. endp
  3175.  
  3176. ;input:
  3177. ; edi = pointer to tedit struct
  3178. proc ted_draw_buffer
  3179.         pushad
  3180.  
  3181.         mov eax,ted_buffer
  3182.         cmp byte[eax],0 ;ᬮâਬ 1-© ᨬ¢®« ¨§ ¡ãä¥à 
  3183.         je @f
  3184.                 mov ebx,ted_rec_l
  3185.                 add bx,300
  3186.                 cmp ebx,ted_wnd_w ;áà ¢­¨¢ ¥¬ ª®®à¤¨­ âã ¤«ï ¢ë¢®¤ ⥪áâ 
  3187.                 jge @f ;¯®¤¯¨áì ­¥ ¢« §¨â ¢ ®ª­®
  3188.  
  3189.                 add ebx,ted_wnd_l
  3190.                 shl ebx,16
  3191.                 add ebx,ted_wnd_t
  3192.                 add ebx,3
  3193.                 mov ecx,ted_color_wnd_bord
  3194.                 or ecx,0x40000000
  3195.  
  3196.                 mov edx,ted_buffer
  3197.                 mov esi,edx
  3198.                 mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
  3199.                 call tl_strlen
  3200.                 ;cmp eax,0 ;¡ãä¥à ¯ãáâ
  3201.                 ;je @f
  3202.                 cmp eax,20
  3203.                 jle .crop_buf
  3204.                         mov eax,20 ;®¡à¥§ª  ¯®¤¯¨á¨ ¤® 20 ᨬ¢®«®¢
  3205.                 .crop_buf:
  3206.                 mov esi,eax
  3207.                 mov eax,4
  3208.                 int 0x40 ;¢ë¢®¤ ᮤ¥à¦¨¬®£® ¡ãä¥à 
  3209.  
  3210.                 sub ebx,50 shl 16
  3211.                 lea edx,[txtBuf]
  3212.                 mov esi,edx
  3213.                 call tl_strlen
  3214.                 mov esi,eax
  3215.                 mov eax,4
  3216.                 xor ecx,0x40000000 ;㡨ࠥ¬ 梥â ä®­ 
  3217.                 int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ ¤«ï ¡ãä¥à 
  3218.         @@:
  3219.         popad
  3220.         ret
  3221. endp
  3222.  
  3223. ;input:
  3224. ; edi = pointer to tedit struct
  3225. align 4
  3226. proc ted_draw_help_f1
  3227.         pushad
  3228.         cmp ted_rec_t,13 ;¬¨­¨¬ «ì­ ï ¢ëá®â  ¤«ï à¨á®¢ ­¨ï á¯à ¢ª¨
  3229.         jle @f
  3230.                 mov eax,13 ;clear place before draw help
  3231.                 mov ebx,ted_wnd_l
  3232.                 add ebx,ted_rec_l
  3233.                 shl ebx,16
  3234.                 add ebx,ted_wnd_w
  3235.                 sub ebx,ted_rec_l
  3236.                 mov ecx,ted_wnd_t
  3237.                 add ecx,13
  3238.                 shl ecx,16
  3239.                 add ecx,ted_rec_h
  3240.                 mov edx,ted_color_wnd_capt
  3241.                 int 0x40
  3242.  
  3243.         cmp ted_help_id,-1
  3244.         je @f
  3245.                 mov eax,ted_help_id
  3246.                 ColToIndexOffset eax,edx
  3247.  
  3248.                 ;SetCoordinates
  3249.                 mov ebx,ted_wnd_l
  3250.                 add ebx,ted_rec_l
  3251.                 shl ebx,16
  3252.                 add ebx,ted_wnd_t
  3253.                 add ebx,13 ;=3+10
  3254.  
  3255.                 ;SetTextColor
  3256.                 xor eax,eax
  3257.                 mov al,byte[edx+MAX_COLOR_WORD_LEN+7]
  3258.                 shl ax,2
  3259.                 mov ecx,ted_text_colors
  3260.                 add ecx,eax
  3261.                 mov ecx,dword[ecx]
  3262.                 or      ecx,0xc0000000 ;SetTextStyles
  3263.                 mov esi,edi
  3264.                         mov edi,ted_color_wnd_work
  3265.                         mov eax,4
  3266.                         int 0x40
  3267.                 mov edi,esi
  3268.  
  3269.                 ;*** draw help string ***
  3270.                 mov ecx,ted_color_wnd_bord
  3271.                 or ecx,0x80000000
  3272.                 mov edx,dword[edx+MAX_COLOR_WORD_LEN]
  3273.                 cmp edx,0
  3274.                 je @f
  3275.                         add edx,ted_help_text_f1
  3276.                         add ebx,0x500000
  3277.                         int 0x40
  3278.         @@:
  3279.         popad
  3280.         ret
  3281. endp
  3282.  
  3283. ;input:
  3284. ; edi = pointer to tedit struct
  3285. align 4
  3286. proc ted_draw_line_numbers
  3287.   pushad
  3288.  
  3289.   ;top panel with caption
  3290.   mov ebx,ted_wnd_l
  3291. ;  add ebx,ted_rec_l
  3292.   shl ebx,16
  3293.   add ebx,ted_wnd_w
  3294. ;  sub ebx,ted_rec_l
  3295.   mov edx,ted_color_wnd_work
  3296.   mov ecx,ted_wnd_t
  3297.   shl ecx,16
  3298.   add ecx,ted_rec_t
  3299.   mov eax,13
  3300.   mov edx,ted_color_wnd_capt
  3301.   int 0x40
  3302.  
  3303.   ;line numbers
  3304.   mov ebx,0x40000 ;format
  3305.   mov ecx,ted_scr_w
  3306.   mov ecx,dword[ecx+sb_offs_position]
  3307.   inc ecx
  3308.   mov edx,3
  3309.   add edx,ted_wnd_l
  3310.   rol edx,16
  3311.   add edx,ted_wnd_t
  3312.   add edx,ted_rec_t
  3313.   @@:
  3314.  
  3315. push ebx ecx edx
  3316.   ;left panel with numbers
  3317.   mov ebx,ted_wnd_l
  3318.   shl ebx,16
  3319.   add ebx,ted_rec_l
  3320.   mov ecx,ted_rec_h
  3321.   rol ecx,16
  3322.   mov cx,dx
  3323.   rol ecx,16
  3324.   mov eax,13
  3325.   mov edx,ted_color_wnd_capt
  3326.   int 0x40 ;à¨á㥬 ¯àאַ㣮«ì­¨ª ¯®¤ ­®¬¥à®¬ áâப¨
  3327. pop edx ecx ebx
  3328.  
  3329.     mov eax,47
  3330.     mov esi,ted_color_wnd_bord
  3331.     int 0x40 ;à¨á㥬 ­®¬¥à áâப¨
  3332.     inc ecx
  3333.     add edx,ted_rec_h
  3334.     sub edx,ted_wnd_t
  3335.         mov esi,edx
  3336.         and esi,0xffff
  3337.     cmp esi,ted_wnd_h
  3338.     jge @f
  3339.     add edx,ted_wnd_t
  3340.     jmp @b
  3341.   @@:
  3342.  
  3343.   popad
  3344.   ret
  3345. endp
  3346.  
  3347. ;output:
  3348. ; ah = symbol
  3349. align 4
  3350. proc KeyConvertToASCII, table:dword
  3351.         push ebx
  3352.         mov ebx,dword[table] ;convert scan to ascii
  3353.         ror ax,8
  3354.         xor ah,ah
  3355.         add bx,ax ;? ebx,eax
  3356.         mov ah,byte[ebx]
  3357.         pop ebx
  3358.         ret
  3359. endp
  3360.  
  3361. align 4
  3362. proc ted_draw_cur_line, edit:dword
  3363.   pushad
  3364.     mov edi,dword[edit]
  3365.  
  3366.     mov ebx,ted_wnd_l
  3367.     add ebx,ted_rec_l
  3368.     shl ebx,16
  3369.     mov eax,ted_cur_y
  3370.     imul eax,ted_rec_h
  3371.         mov bx,ax
  3372.     add ebx,ted_wnd_t
  3373.     add ebx,ted_rec_t ;ebx - ª®®à¤¨­ âë ¤«ï ¯àאַ㣮«ì­¨ª  ®ç¨á⪨ «¨­¨¨
  3374.         add ebx,0x10001   ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3375.  
  3376.     call ted_sel_normalize ;need before draw select
  3377.         mov ecx,ted_cur_y
  3378.         mov eax,ted_scr_w
  3379.     add ecx,dword[eax+sb_offs_position]
  3380.     stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
  3381.  
  3382.     mov eax,ted_scr_h
  3383.         mov esi,dword[eax+sb_offs_position]
  3384.     call ted_get_pos_by_coords
  3385.  
  3386.   cmp ted_gp_opt,2
  3387.   jne .no_draw_text
  3388. ;  mov eax,4 ;draw text
  3389.   call ted_get_symb_color
  3390.   mov esi,1 ;draw 1 symbol
  3391.   @@:
  3392.     ;call ted_iterat_next
  3393.     cmp edx,ted_tex_1
  3394.     jle .no_draw_text
  3395.  
  3396.     ; *** 梥⮢ ï à §¬¥âª 
  3397.     cmp ted_mode_color,0
  3398.     je .no_col_change
  3399.     cmp byte[edx+1],0
  3400.     je .no_col_change
  3401.       call ted_get_symb_color
  3402.     .no_col_change:
  3403.  
  3404.     mov eax,4 ;draw text
  3405.     cmp byte [edx],13
  3406.     jne .no_13
  3407.       cmp ted_mode_invis,1
  3408.       jne .no_draw_text
  3409.  push edx
  3410.  mov edx,edi
  3411.  add edx,ted_offs_symbol_new_line
  3412.  int 0x40
  3413.  pop edx
  3414.       jmp .no_draw_text
  3415.     .no_13:
  3416.  
  3417.     int 0x40
  3418.     ror ebx,16
  3419.     add ebx,ted_rec_w
  3420.     mov eax,ted_wnd_w
  3421.     add eax,ted_wnd_l ;ax = ®âáâ㯠¯® ®á¨ x
  3422.     cmp bx,ax
  3423.     jge .no_draw_text ;Opt
  3424.     ror ebx,16
  3425.     call ted_iterat_next
  3426.     jmp @b
  3427.   .no_draw_text:
  3428.  
  3429.   call ted_draw_main_cursor
  3430.   popad
  3431.   ret
  3432. endp
  3433.  
  3434. ;input:
  3435. ; eax - text need find
  3436. ; bl - first symbol to find
  3437. ; edx - first symbol pointer
  3438. ; edi - pointer to tedit struct
  3439. ;output:
  3440. ; bh - rezult
  3441. ; edx - last text position (if find sucess)
  3442. ; esi - first symbol pointer
  3443. ;description:
  3444. ; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ eax
  3445. ; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
  3446. ; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
  3447. ; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
  3448. align 4
  3449. ted_get_find_rezult:
  3450.   push eax
  3451.     mov bh,1
  3452.     mov esi,edx ;copy edx
  3453.     @@:
  3454.       cmp byte[edx],bl
  3455.       jne .no_text
  3456.  
  3457.       inc eax ;*** get next symbol (in find text) ***
  3458.       mov bl,byte[eax]
  3459.       cmp bl,0
  3460.       je @f ;end of find text
  3461.  
  3462.       call ted_iterat_next ;*** get next symbol (in editor text) ***
  3463.       cmp edx,ted_tex_1
  3464.       jle @f ;end of editor text
  3465.  
  3466.       jmp @b
  3467.       .no_text:
  3468.         xor bh,bh
  3469.         mov edx,esi ;restore edx
  3470.     @@:
  3471.   pop eax
  3472.   mov bl,byte[eax] ;restore bl
  3473.   ret
  3474.  
  3475. ;input:
  3476. ;  clear_o - ¥á«¨ =1 ®ç¨áâ¨âì ®¤­ã áâபã, =0 ®ç¨áâ¨âì ¢á¥ áâப¨ ®ª­  ¤® ­¨§ã
  3477. align 4
  3478. proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
  3479.         pushad
  3480.         mov edi,dword[edit]
  3481.         mov ebx,dword[coords]   ;ebx = x*2^16+y coords to left up point clear line
  3482.         mov esi,dword[numb_lin] ;esi - number text line
  3483.  
  3484.         sub ebx,0x10001 ;®â­¨¬ ¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3485.         cmp dword[clear_o],0
  3486.         jne @f
  3487.                 add ebx,ted_rec_h
  3488.                 inc esi
  3489.                 ror ebx,16
  3490.                 xor bx,bx
  3491.                 add ebx,ted_wnd_l
  3492.                 add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
  3493.                 ror ebx,16
  3494.         @@:
  3495.  
  3496.         mov eax,ted_wnd_h
  3497.         add eax,ted_wnd_t
  3498.         cmp ax,bx
  3499.         jl .no_clear
  3500.         sub ax,bx
  3501.  
  3502.         mov cx,bx
  3503.         shl ecx,16
  3504.  
  3505.         xor bx,bx
  3506.         add ebx,ted_wnd_w
  3507.         sub ebx,ted_rec_l
  3508.         xor cx,cx
  3509.         add ecx,ted_rec_h
  3510.         mov edx,ted_color_wnd_work
  3511.  
  3512.         cmp dword[clear_o],0
  3513.         je .pusto
  3514.         cmp ax,cx
  3515.         jge @f
  3516.         .pusto:
  3517.                 mov cx,ax
  3518.         @@:
  3519.  
  3520.         call ted_is_select
  3521.         cmp al,0
  3522.         je @f
  3523.         cmp ted_seln_y0,esi
  3524.         jg @f
  3525.         cmp ted_seln_y1,esi
  3526.         jl @f
  3527.                 mov edx,ted_color_select ;draw selected line
  3528.         @@:
  3529.  
  3530.         mov eax,13 ;rect
  3531.         int 0x40
  3532.  
  3533.         call ted_is_select
  3534.         cmp al,0
  3535.         je .no_clear
  3536.  
  3537.         mov al,13 ;rect
  3538.         xor cx,cx
  3539.         add ecx,ted_rec_h
  3540.         cmp ted_seln_y0,esi
  3541.         jne @f
  3542.                 push bx esi
  3543.                 mov edx,ted_seln_x0 ; ¢¥àå­ïï ¯®«®á  (§ â¨à ¥â á«¥¢ )
  3544.                 mov esi,ted_scr_h
  3545.                 cmp edx,dword[esi+sb_offs_position]
  3546.                 jle .in_wnd
  3547.                         sub edx,dword[esi+sb_offs_position]
  3548.                         imul edx,ted_rec_w
  3549.                         mov bx,dx
  3550.                         jmp .no_wnd
  3551.                 .in_wnd:
  3552.                 mov bx,0
  3553.                 .no_wnd:
  3554.                 mov edx,ted_color_wnd_work
  3555.                 int 0x40
  3556.                 pop esi bx
  3557.         @@:
  3558.         cmp ted_seln_y1,esi
  3559.         jne @f
  3560.                 push esi
  3561.                 mov edx,ted_seln_x1 ; ­¨¦­ïï ¯®«®á  (§ â¨à ¥â á¯à ¢ )
  3562.                 mov esi,ted_scr_h
  3563.                 cmp edx,dword[esi+sb_offs_position]
  3564.                 jle .in_wnd2
  3565.                         sub edx,dword[esi+sb_offs_position]
  3566.                         imul edx,ted_rec_w
  3567.                         sub bx,dx
  3568.                         shl edx,16
  3569.                         add ebx,edx
  3570.                 .in_wnd2:
  3571.  
  3572.                 mov edx,ted_color_wnd_work
  3573.                 int 0x40
  3574.                 pop esi
  3575.         @@:
  3576.  
  3577.         .no_clear:
  3578.         popad
  3579.         ret
  3580. endp
  3581.  
  3582. ;input:
  3583. ; edi = pointer to tedit struct
  3584. ;output:
  3585. ; ecx = ­®¢ë© 梥â ᨬ¢®« 
  3586. ; edx = pointer to symbol
  3587. ; edx = 0 if text not in screen
  3588. align 4
  3589. ted_get_first_visible_pos:
  3590.         push eax ecx
  3591.         mov eax,ted_scr_w
  3592.         mov edx,ted_tex
  3593.         xor ecx,ecx
  3594.         @@:
  3595.                 cmp ecx,dword[eax+sb_offs_position]
  3596.                 je @f
  3597.                 call ted_iterat_next
  3598.                 cmp edx,ted_tex_1
  3599.                 jle @f
  3600.                 cmp byte [edx],13
  3601.                 jne @b
  3602.                 inc ecx
  3603.                 jmp @b
  3604.         @@:
  3605.  
  3606.         cmp ecx,dword[eax+sb_offs_position]
  3607.         je @f
  3608.                 xor edx,edx
  3609.         @@:
  3610.         cmp ecx,dword[eax+sb_offs_max_area]
  3611.         jle @f
  3612.                 mov dword[eax+sb_offs_max_area],ecx
  3613.         @@:
  3614.         pop ecx eax
  3615.         call ted_opt_draw_line_left
  3616.         ret
  3617.  
  3618. ;input:
  3619. ; edx = pointer to symbol
  3620. ; edi = pointer to tedit struct
  3621. ;output:
  3622. ; ecx = 梥â ᨬ¢®« 
  3623. ; edx = 㪠§ â¥«ì ­  ¯¥à¢ë© «¥¢ë© ᨬ¢®«
  3624. ;description:
  3625. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  3626. align 4
  3627. proc ted_opt_draw_line_left
  3628.   push ebx
  3629.  
  3630.   mov ebx,ted_scr_h
  3631.   mov ebx,dword[ebx+sb_offs_position]
  3632.   cmp ebx,0
  3633.   je .ret_f
  3634.   push eax
  3635.   mov eax,edx
  3636.  
  3637.   cmp edx,ted_tex
  3638.   jne @f
  3639.     call ted_iterat_next
  3640.     jmp .beg_cycle
  3641.   @@:
  3642.  
  3643.   cmp ebx,0
  3644.   je @f
  3645.  
  3646.   cmp byte[edx],13
  3647.   jne @f
  3648.     call ted_iterat_next
  3649.     .beg_cycle:
  3650.   @@:
  3651.     cmp edx,ted_tex_1
  3652.     jle @f
  3653.     cmp byte[edx],13
  3654.     je @f
  3655.     cmp ebx,0
  3656.     je @f
  3657. ;--------------------------------------
  3658. xor eax,eax ;eax ¡ã¤¥â ¬¥­ïâìáï
  3659. mov al,byte[edx+1]
  3660. cmp al,0
  3661. je .no_color
  3662. cmp eax,ted_colors_text_count
  3663. jge .no_color
  3664.   xor ecx,ecx
  3665.   mov cl,byte[edx+1]
  3666.   shl cx,2
  3667.   add ecx,ted_text_colors
  3668.   mov ecx,dword[ecx]
  3669. .no_color:
  3670. ;--------------------------------------
  3671.     mov eax,edx
  3672.     call ted_iterat_next
  3673.     dec ebx
  3674.     jmp @b
  3675.   @@:
  3676.     mov edx,eax
  3677.   pop eax
  3678.   .ret_f:
  3679.   call ted_get_symb_color
  3680.   pop ebx
  3681.   ret
  3682. endp
  3683.  
  3684. ;input:
  3685. ; edx = pointer to symbol
  3686. ; edi = pointer to tedit struct
  3687. ;output:
  3688. ; ecx = symbol color
  3689. ; edx = pointer to 13 symbol
  3690. ;description:
  3691. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  3692. align 4
  3693. proc ted_opt_draw_line_right
  3694.         push eax
  3695.         mov eax,edx
  3696.         @@:
  3697.                 cmp edx,ted_tex_1
  3698.                 jle @f
  3699.                 cmp byte[edx],13
  3700.                 je @f
  3701.                 mov eax,edx
  3702.                 call ted_iterat_next
  3703.                 jmp @b
  3704.         @@:
  3705.         mov edx,eax ;perv sumbol
  3706.         call ted_get_symb_color
  3707.  
  3708.         pop eax
  3709.         ret
  3710. endp
  3711.  
  3712. align 4
  3713. proc ted_mouse, edit:dword
  3714.         pushad
  3715.         mov edi,dword[edit]
  3716.  
  3717.         ;®¡à ¡ â뢠¥¬ áªà®««¨­£¨
  3718.         mov edx,ted_scr_h
  3719.         mov ecx,ted_scr_w
  3720.  
  3721.         cmp word[edx+sb_offs_delta2],0
  3722.         jne .horizontal
  3723.  
  3724.         mov eax,dword[ecx+sb_offs_max_area]
  3725.         cmp eax,dword[ecx+sb_offs_cur_area]
  3726.         jbe .horizontal
  3727.         ; mouse event for Vertical ScrollBar
  3728.         stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
  3729.         cmp dword[ecx+sb_offs_redraw],0
  3730.         je @f
  3731.                 mov dword[ecx+sb_offs_redraw],0
  3732.                 stdcall ted_draw,edi
  3733.                 jmp .no_in_wnd
  3734.         @@:
  3735.         cmp word[ecx+sb_offs_delta2],0
  3736.         jne .no_in_wnd
  3737.         .horizontal:
  3738.         mov eax,dword[edx+sb_offs_max_area]
  3739.         cmp eax,dword[edx+sb_offs_cur_area]
  3740.         jbe .other
  3741.         ; mouse event for Horizontal ScrollBar
  3742.         stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
  3743.         cmp dword[edx+sb_offs_redraw],0
  3744.         je .other
  3745.                 mov dword[edx+sb_offs_redraw],0
  3746.                 stdcall ted_draw,edi
  3747.                 jmp .no_in_wnd
  3748.         .other:
  3749.         cmp word[ecx+sb_offs_delta2],0
  3750.         jne .no_in_wnd
  3751.         cmp word[edx+sb_offs_delta2],0
  3752.         jne .no_in_wnd
  3753.  
  3754.         ;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
  3755.         mcall 37,2 ;get mouse buttons
  3756.         cmp al,1
  3757.         jne @f
  3758.                 mcall 37,1 ;get mouse coords
  3759.                 mov ebx,ted_wnd_t
  3760.                 add ebx,ted_rec_t
  3761.                 cmp ax,bx
  3762.                 jl @f ;y_mouse<y_wnd
  3763.  
  3764.                 sub ebx,ted_rec_t
  3765.                 add ebx,ted_wnd_h
  3766.                 cmp bx,ax
  3767.                 jl @f ;y_mouse>y_wnd
  3768.  
  3769.                 mov ebx,ted_wnd_l
  3770.                 add ebx,ted_rec_l
  3771.                 mov ecx,eax
  3772.                 shr ecx,16
  3773.                 cmp cx,bx
  3774.                 jl @f ;x_mouse<x_wnd
  3775.  
  3776.                 sub ebx,ted_rec_l
  3777.                 add ebx,ted_wnd_w
  3778.                 cmp bx,cx
  3779.                 jl @f ;x_mouse>x_wnd
  3780.  
  3781.                 call ted_draw_cursor_sumb
  3782.                 call ted_wnd_main_click
  3783.                 jmp .no_in_wnd
  3784.         @@:
  3785.         mov edx,ted_el_focus
  3786.         cmp dword[edx],edi
  3787.         jne @f
  3788.                 call ted_wnd_main_mouse_scroll ;ᬮâਬ ­  ¯à®ªàãâªã ª®«¥á  ¬ëè¨
  3789.         @@:
  3790.         cmp ted_drag_m,0
  3791.         je .no_in_wnd
  3792.                 mov ted_drag_m,0
  3793.                 stdcall ted_draw,edi
  3794.                 cmp ted_fun_draw_panel_buttons,0
  3795.                 je .no_in_wnd
  3796.                         call ted_fun_draw_panel_buttons
  3797.         .no_in_wnd:
  3798.         popad
  3799.         ret
  3800. endp
  3801.  
  3802. ;input:
  3803. ; eax -> (x,y)
  3804. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  3805. ;description:
  3806. ; äã­ªæ¨ï ¢ë§ë¢¥âáï ¯à¨ ­ ¦ â¨¨ ª­®¯ª®© ¬ëè¨ ¨ ¯®¯ ¤¥­¨¨ ªãàá®à®¬ ¢ ®ª­® । ªâ®à 
  3807. align 4
  3808. ted_wnd_main_click:
  3809.         push ebx ecx edx
  3810.         mov ebx,ted_el_focus
  3811.         mov dword[ebx],edi ;áâ ¢¨¬ 䮪ãá
  3812.  
  3813.   push eax
  3814.     shr eax,16
  3815.     and eax,0xffff
  3816.     sub eax,ted_wnd_l
  3817.     sub eax,ted_rec_l
  3818.  
  3819.     xor edx,edx
  3820.     mov ecx,ted_rec_w
  3821.     div cx
  3822.     ;inc eax
  3823.         mov ebx,ted_scr_h
  3824.     cmp eax,dword[ebx+sb_offs_cur_area]
  3825.     jle @f
  3826.       mov eax,dword[ebx+sb_offs_cur_area]
  3827.     @@:
  3828.     ;dec eax
  3829.     mov ted_cur_x,eax
  3830.   pop eax
  3831.  
  3832.   push eax
  3833.     and eax,0xffff
  3834.     sub eax,ted_wnd_t
  3835.     sub eax,ted_rec_t
  3836.  
  3837.     xor edx,edx
  3838.     mov ecx,ted_rec_h
  3839.     div cx
  3840.     inc eax
  3841.         mov ebx,ted_scr_w
  3842.     cmp eax,dword[ebx+sb_offs_cur_area]
  3843.     jle @f
  3844.       mov eax,dword[ebx+sb_offs_cur_area]
  3845.     @@:
  3846.     dec eax
  3847.     mov ted_cur_y,eax
  3848.   pop eax
  3849.  
  3850.         cmp ted_drag_m,0
  3851.         je @f
  3852.                 call ted_sel_move
  3853.                 jmp .sel_move
  3854.         @@:
  3855.                 mov ted_drag_m,1
  3856.                 call ted_sel_start
  3857.         .sel_move:
  3858.         pop edx ecx ebx
  3859.         ret
  3860.  
  3861. ;input:
  3862. ; edi = pointer to tedit struct
  3863. align 4
  3864. ted_wnd_main_mouse_scroll:
  3865.         push eax ebx ecx
  3866.         mcall 37,7 ;¯à®ªàã⪠ ª®«¥á  ¬ëè¨
  3867.         cmp ax,0
  3868.         je .no_scroll
  3869.                 mov ecx,ted_scr_w
  3870.                 mov ebx,dword[ecx+sb_offs_position] ;copy old scroll position
  3871.                 and eax,0xffff
  3872.                 btr ax,15
  3873.                 jae @f
  3874.                         or eax,0xffff8000
  3875.                 @@:
  3876.                 add dword[ecx+sb_offs_position],eax
  3877.  
  3878.                 mov eax,[ecx+sb_offs_position]
  3879.                 cmp eax,[ecx+sb_offs_max_area]
  3880.                 jb @f
  3881.                         mov dword[ecx+sb_offs_position],ebx ;if scroll position out of range
  3882.                         jmp .no_scroll
  3883.                 @@:
  3884.                 stdcall ted_draw,edi
  3885.         .no_scroll:
  3886.         pop ecx ebx eax
  3887.         ret
  3888.  
  3889. align 4
  3890. proc ted_but_save_file, edit:dword, file:dword, f_name:dword
  3891.   pushad
  3892.   mov edi,dword[edit]
  3893.  
  3894.   stdcall ted_can_save,edi
  3895.   cmp al,0
  3896. ;  je .no_save
  3897.  
  3898.   mov ecx,ted_max_chars
  3899.   invoke mem.alloc,ecx
  3900.   push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3901.  
  3902.   mov edx,ted_tex
  3903.   xor ecx,ecx
  3904.   @@:
  3905.     call ted_iterat_next
  3906.     cmp edx,ted_tex_1
  3907.     jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
  3908.     mov bl,[edx]
  3909.     mov byte[eax],bl
  3910.     inc eax
  3911.     inc ecx
  3912.     jmp @b
  3913.   @@:
  3914.  
  3915.   cmp ecx,0
  3916.   je @f
  3917.     mov ebx,dword[file]
  3918.     pop eax ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3919.     mov dword[ebx+16],eax
  3920.     push eax ;®¡à â­® § ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3921.     mov eax,70
  3922.     mov dword[ebx], 2
  3923.     mov dword[ebx+4], 0
  3924.     mov dword[ebx+8], 0
  3925.     mov dword[ebx+12], ecx
  3926.     mov  byte[ebx+20], 0
  3927.     push dword[f_name]
  3928.     pop dword[ebx+21]
  3929.     int 0x40
  3930.  
  3931.     mov ted_err_save,al
  3932.  
  3933.     cmp eax,0
  3934.     je .no_msg
  3935. ;    cmp eax,6
  3936. ;    je @f
  3937.       cmp ax,10
  3938.       jl .zifra_0_9
  3939.         mov al,'?'
  3940.         sub ax,48
  3941.       .zifra_0_9:
  3942.       add ax,48
  3943. cmp ted_fun_save_err,0
  3944. je @f
  3945. call ted_fun_save_err
  3946.       jmp @f
  3947.     .no_msg:
  3948.     m2m ted_tim_ls,ted_tim_ch
  3949.   @@:
  3950.  
  3951.   pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  3952.   invoke mem.free,ecx
  3953.   .no_save:
  3954.   popad
  3955.   ret
  3956. endp
  3957. }