Subversion Repositories Kolibri OS

Rev

Rev 7571 | Rev 7577 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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