Subversion Repositories Kolibri OS

Rev

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

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