Subversion Repositories Kolibri OS

Rev

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

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