Subversion Repositories Kolibri OS

Rev

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