Subversion Repositories Kolibri OS

Rev

Rev 7576 | Rev 7579 | 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,edi,0
  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. proc ted_get_pos_by_coords uses eax ebx
  1855.         xor eax,eax ;Row
  1856.         xor ebx,ebx ;Col
  1857.   mov ted_gp_opt,0
  1858.   mov edx,ted_tex
  1859.   @@:
  1860.     call ted_iterat_next
  1861.     cmp edx,ted_tex_1
  1862.     jle @f
  1863.     cmp ebx,esi
  1864.     jne .u1_0 ;Col <> ted_cur_x
  1865.       mov ted_gp_opt,1
  1866.       cmp eax,ecx
  1867.       jge @f ; Row >= ted_cur_y
  1868.     .u1_0:
  1869.     mov ted_gp_opt,0
  1870.     inc ebx
  1871.     cmp byte [edx],13
  1872.     jne @b
  1873.     cmp eax,ecx
  1874.     jge @f ; Row >= ted_cur_y
  1875.     inc eax
  1876.     xor ebx,ebx
  1877.     jmp @b
  1878.   @@:
  1879.   cmp eax,ecx
  1880.   jne @f ; Row = ted_cur_y
  1881.     inc ted_gp_opt
  1882.   @@:
  1883.   cmp ted_gp_opt,0
  1884.   jne @f
  1885.     mov edx,ted_tex_1
  1886.     ;call ted_get_text_perv_pos
  1887.   @@:
  1888.   ret
  1889. endp
  1890.  
  1891. ;input:
  1892. ; eax = Row
  1893. ; edi = pointer to tedit struct
  1894. ;output:
  1895. ; ebx = str len
  1896. align 16
  1897. ted_strlen:
  1898.   push edx ecx
  1899.   ;ecx = Row, from cycle
  1900.  
  1901.   xor ebx,ebx
  1902.   xor ecx,ecx
  1903.   mov edx,ted_tex
  1904.   @@:
  1905.     call ted_iterat_next
  1906.     cmp edx,ted_tex_1
  1907.     jle @f
  1908.     inc ebx
  1909.     cmp byte [edx],13
  1910.     jne @b
  1911.     dec ebx ;lenght minus 1 sumbol to paragraph
  1912.     cmp eax,ecx
  1913.     je @f
  1914.     xor ebx,ebx
  1915.     inc ecx
  1916.     jmp @b
  1917.   @@:
  1918.  
  1919.   cmp eax,ecx
  1920.   je @f
  1921.     xor ebx,ebx
  1922.   @@:
  1923.  
  1924.   pop ecx edx
  1925.   ret
  1926.  
  1927.  
  1928. ;input:
  1929. ; edx = symbol position
  1930. ; edi = pointer to tedit struct
  1931. ;output:
  1932. ; eax = number of line
  1933. ; ebx = symbol position in line
  1934. align 16
  1935. ted_get_text_coords:
  1936.   push edx
  1937.   xor eax,eax
  1938.   xor ebx,ebx
  1939.   @@:
  1940.     call ted_iterat_perv
  1941.  
  1942.     cmp eax,0
  1943.     jne .no_col_mov
  1944.     inc ebx
  1945.     .no_col_mov:
  1946.  
  1947.     cmp edx,ted_tex_1
  1948.     jle @f
  1949.     cmp byte [edx],13
  1950.     jne @b
  1951.     inc eax
  1952.     jmp @b
  1953.   @@:
  1954.   dec ebx
  1955.   pop edx
  1956.   ret
  1957.  
  1958. ;input:
  1959. ; edi = pointer to tedit struct
  1960. ;output:
  1961. ; eax = num lines
  1962. align 16
  1963. ted_get_num_lines:
  1964.         push edx
  1965.         mov eax,1
  1966.         mov edx,ted_tex
  1967.         @@:
  1968.                 call ted_iterat_next
  1969.                 cmp edx,ted_tex_1
  1970.                 jle @f
  1971.                 cmp byte [edx],13
  1972.                 jne @b
  1973.                 inc eax
  1974.                 jmp @b
  1975.         @@:
  1976. ;...
  1977. ;dec eax
  1978.         pop edx
  1979.         ret
  1980.  
  1981.  
  1982. ;input:
  1983. ; edi = pointer to tedit struct
  1984. ;description:
  1985. ; ®â¬¥­ï¥â ®â¬¥­¥­­ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥­¥­¨¥¬ ¤®ªã¬¥­â 
  1986. align 16
  1987. proc ted_set_undo
  1988.         mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  1989.         cmp ted_tim_undo,1
  1990.         jl .no_work
  1991.  
  1992.         push eax ebx edx
  1993.         mov edx,ted_tex
  1994.         call ted_get_text_next_pos ;long i=tex[0].next;
  1995.         mov eax,ted_tim_undo
  1996.         sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
  1997.         mov eax,ted_tim_ch
  1998.         cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
  1999.         jle @f
  2000.                 mov ted_tim_ls,0
  2001.         @@:
  2002.                 cmp edx,ted_tex_1
  2003.                 jle @f
  2004.  
  2005.                 ;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  2006.                 cmp [edx+symbol.tc],eax
  2007.                 jle .no_u1
  2008.                         mov dword [edx+symbol.tc],0
  2009.                         mov dword [edx+symbol.td],0
  2010.  
  2011.                         mov ebx,[edx+symbol.perv]
  2012.                         imul ebx,sizeof.symbol
  2013.                         add ebx,ted_tex ;ebx=tex[i].perv
  2014.                         m2m dword [ebx+symbol.next],dword [edx+symbol.next] ;tex[tex[i].perv].next=tex[i].next;
  2015.  
  2016.                         mov ebx,[edx+symbol.next]
  2017.                         imul ebx,sizeof.symbol
  2018.                         add ebx,ted_tex ;ebx=tex[i].next
  2019.                         m2m dword [ebx+symbol.perv],dword [edx+symbol.perv] ;tex[tex[i].next].perv=tex[i].perv;
  2020.  
  2021.                         cmp ted_ptr_free_symb,edx
  2022.                         jle .no_cor_free
  2023.                                 mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
  2024.                         .no_cor_free:
  2025.                         mov edx,ebx ;®¯â¨¬¨§¨à㥬 ¯® ᪮à®á⨠(edx ¯®á«¥ ¢ë§®¢  ted_get_text_next_pos ¡ã¤¥â à ¢¥­ ebx)
  2026.                         jmp @b
  2027.                 .no_u1:
  2028.  
  2029.                 ;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  2030.                 cmp [edx+symbol.td],eax
  2031.                 jle .no_u2
  2032.                         mov dword [edx+symbol.td],0
  2033.                 .no_u2:
  2034.  
  2035.                 call ted_get_text_next_pos
  2036.                 jmp @b
  2037.         @@:
  2038.         mov ted_tim_undo,0
  2039.         mov eax,ted_tim_co
  2040.         cmp ted_tim_ch,eax
  2041.         jge @f
  2042.                 mov ted_tim_co,0
  2043.         @@:
  2044.         pop edx ebx eax
  2045.         .no_work:
  2046.         ret
  2047. endp
  2048.  
  2049. ;input:
  2050. ; ecx = Col
  2051. ; edx = Row
  2052. ; edi = pointer to tedit struct
  2053. ;output:
  2054. ; ecx = cursor x
  2055. ; edx = cursor y
  2056. align 16
  2057. ted_go_to_pos:
  2058.         push eax ebx
  2059.         mov eax,ted_scr_h
  2060.         sub ecx,[eax+sb_offs_position]
  2061.         cmp ecx,0 ;ted_cur_x < 0
  2062.         jge @f
  2063.                 add [eax+sb_offs_position],ecx ;¯à®ªàã⪠ áªà®««¨­£  ¢«¥¢®
  2064.                 xor ecx,ecx
  2065.         @@:
  2066.         mov ebx,5 ;5 - ¦¥« ¥¬ë© ®âáâ㯠᫥¢ 
  2067.         cmp ecx,ebx
  2068.         jge .end0
  2069.                 sub ebx,ecx ;ebx - ­  ᪮«ìª® ᨬ¢®«®¢ ­ã¦­® ᤢ¨­ãâì ªãàá®à
  2070.                 cmp [eax+sb_offs_position],ebx
  2071.                 jge @f
  2072.                         add ecx,[eax+sb_offs_position]
  2073.                         mov dword[eax+sb_offs_position],0
  2074.                         jmp .end0
  2075.                 @@:
  2076.                         sub [eax+sb_offs_position],ebx
  2077.                         add ecx,ebx
  2078.         .end0:
  2079.         cmp ecx,[eax+sb_offs_cur_area] ;ted_cur_x > [.cur_area]
  2080.         jl .end1
  2081.                 mov ebx,ecx
  2082.                 sub ebx,[eax+sb_offs_cur_area]
  2083.                 inc ebx
  2084.                 add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢¯à ¢®
  2085.                 sub ecx,ebx
  2086.         .end1:
  2087.         mov ted_cur_x,ecx
  2088.  
  2089.         mov eax,ted_scr_w
  2090.         sub edx,[eax+sb_offs_position]
  2091.         cmp edx,0 ;ted_cur_y < 0
  2092.         jge @f
  2093.                 add [eax+sb_offs_position],edx ;¯à®ªàã⪠ áªà®««¨­£  ¢¢¥àå
  2094.                 xor edx,edx
  2095.                 jmp .end2
  2096.         @@:
  2097.         cmp edx,[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
  2098.         jl .end2
  2099.                 mov ebx,edx
  2100.                 sub ebx,[eax+sb_offs_cur_area]
  2101.                 inc ebx
  2102.                 add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢­¨§
  2103.                 sub edx,ebx
  2104.         .end2:
  2105.         mov ted_cur_y,edx
  2106.         pop ebx eax
  2107.         ret
  2108.  
  2109. ;input:
  2110. ; edi = pointer to tedit struct
  2111. align 16
  2112. ted_text_colored:
  2113.   push eax edx
  2114.   mov eax,ted_tim_ch
  2115.   sub eax,ted_tim_undo
  2116.   mov ted_tim_co,eax
  2117.   mov edx,ted_tex
  2118.   @@:
  2119.     call ted_iterat_next
  2120.     cmp edx,ted_tex_1
  2121.     jle @f
  2122.     mov byte[edx+1],0
  2123.     jmp @b
  2124.   @@:
  2125.  
  2126.   cmp ted_key_words_count,1
  2127.   jl .no_colors
  2128.   mov edx,ted_tex
  2129.   @@:
  2130.     call ted_text_find_sel_color
  2131.     cmp edx,ted_tex_1
  2132.     jle .no_colors
  2133.     jmp @b
  2134.   .no_colors:
  2135.   pop edx eax
  2136.   ret
  2137.  
  2138.  
  2139. ;input:
  2140. ; edx = pointer to start symbol
  2141. ; edi = pointer to tedit struct
  2142. ;output:
  2143. ; edx = pointer to next symbol
  2144. ;description:
  2145. ; ”ã­ªæ¨ï ¤«ï ¯®¨áª  ¨ ¢ë¤¥«¥­¨ï ¯®¤á¢¥ç¥­ëå á«®¢
  2146. align 16
  2147. proc ted_text_find_sel_color uses eax ebx ecx esi
  2148. locals
  2149.         begPos dd ? ;­ ç «ì­ ï ¯®§¨æ¨ï
  2150.         endPos dd ? ;ª®­¥ç­ ï ¯®§¨æ¨ï
  2151.         find db ? ;­ ©¤¥­® / ­¥ ­ ©¤¥­®
  2152.         f_color db ? ;¨­¤¥ªá æ¢¥â  ­ ©¤¥­®£® á«®¢ 
  2153. endl
  2154. ;eax = word_n ⥪ã騩 ­®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢  ¢ ᯨ᪥
  2155. ;ebx = ¤«ï à §­ëå 楫¥©
  2156. ;ecx = l_pos ¯®á«¥¤­¨© ­®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢  ¢ ᯨ᪥
  2157. ;esi = ¤«ï à §­ëå 楫¥©, ­®¬¥à ¯à®¢¥à塞®£® ᨬ¢®«  ¢ á«®¢¥
  2158.         mov dword[begPos],1
  2159.         mov dword[endPos],1
  2160.         mov byte[find],0
  2161.         mov byte[f_color],1
  2162.         @@:
  2163.                 call ted_iterat_next
  2164.                 cmp edx,ted_tex_1
  2165.                 jle @f
  2166.  
  2167.                 xor eax,eax
  2168.                 mov al,byte[edx]
  2169.                 shl ax,2 ;eax*=4
  2170.                 add eax,ted_arr_key_pos
  2171.                 mov eax,[eax]
  2172.                 cmp eax,0
  2173.                 jl @b ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
  2174.  
  2175.                 mov ecx,eax
  2176.                 ;while(l_pos<ted_key_words_count && Col[l_pos].Text[0]==Col[word_n].Text[0])
  2177.                 .wh_1b:
  2178.                         cmp ecx,ted_key_words_count
  2179.                         jge .wh_1e
  2180.                         ColToIndexOffset ecx,esi
  2181.                         mov bl,byte[esi]
  2182.                         ColToIndexOffset eax,esi
  2183.                         cmp bl,byte[esi]
  2184.                         jne .wh_1e
  2185.                                 inc ecx
  2186.                         jmp .wh_1b
  2187.                 .wh_1e:
  2188.  
  2189.                 mov [begPos],edx ;bP=i;
  2190.                 mov esi,1
  2191. align 4
  2192.                 .wh_2b: ;while(1){
  2193.                 call ted_iterat_next
  2194.  
  2195.                 ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
  2196.                 .wh_3b:
  2197.                         cmp ecx,eax
  2198.                         jle .wh_3e
  2199.                         dec ecx
  2200.                         ColToIndexOffset ecx,ebx
  2201.                         inc ecx
  2202.                         ;cmp byte[ebx+esi],byte[edx]
  2203.                         mov bl,byte[ebx+esi]
  2204.                         cmp bl,byte[edx]
  2205.                         je .wh_3e
  2206.                                 dec ecx
  2207.                         jmp .wh_3b
  2208.                 .wh_3e:
  2209.  
  2210.                 ColToIndexOffset eax,ebx
  2211.                 cmp byte[ebx+esi],0
  2212.                 jne .if_0 ;if(Col[word_n].Text[pos]==0){
  2213.                 mov [endPos],edx ;eP=i;
  2214.                 ColToIndexOffset eax,ebx
  2215.                 mov bl,[ebx+MAX_COLOR_WORD_LEN+7]
  2216.                 mov [f_color],bl ;f_color=Col[word_n].color;
  2217.  
  2218.                 mov byte[find],1
  2219.                 ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
  2220.                 mov bl,[ebx+MAX_COLOR_WORD_LEN+4]
  2221.                 cmp bl,0 ;if(Col[word_n].wwo)
  2222.                 je .if_2n
  2223.                         push edx
  2224.                         mov edx,[begPos]
  2225.                         call ted_iterat_perv
  2226.  
  2227.                         btr bx,0 ;1-1
  2228.                         jae .if_3e ;if(Col[word_n].wwo&1)
  2229.                                 ;u1= !(isalnum(cont_s)||cont_s=='_')
  2230.                                 call isalnum
  2231.                                 jae .if_3e
  2232.                                         mov byte[find],0
  2233.                                         jmp .if_4e
  2234.                         .if_3e:
  2235.  
  2236.                         btr bx,3 ;4-1
  2237.                         jae .if_4e ;if(Col[word_n].wwo&8)
  2238.                                 ;u1= !isalpha(cont_s);
  2239.                                 call isalpha
  2240.                                 jae .if_4e
  2241.                                         mov byte[find],0
  2242.                         .if_4e:
  2243.  
  2244.                         mov edx,[endPos]
  2245.                         ;call ted_iterat_next
  2246.  
  2247.                         btr bx,1 ;2-1
  2248.                         jae .if_5e ;if(Col[word_n].wwo&2)
  2249.                                 ;u1= !(isalnum(cont_s)||cont_s=='_')
  2250.                                 call isalnum
  2251.                                 jae .if_5e
  2252.                                         mov byte[find],0
  2253.                                         jmp .if_6e
  2254.                         .if_5e:
  2255.  
  2256.                         btr bx,4 ;5-1
  2257.                         jae .if_6e ;if(Col[word_n].wwo&16)
  2258.                                 ;u1= !isalpha(cont_s);
  2259.                                 call isalpha
  2260.                                 jae .if_6e
  2261.                                         mov byte[find],0
  2262.                         .if_6e:
  2263.  
  2264.                         btr bx,2 ;3-1
  2265.                         jae .if_7e ;if(Col[word_n].wwo&4)
  2266.                                 ColToIndexOffset eax,ebx
  2267.                                 mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
  2268.                                 call ted_iterat_next_pos_char
  2269.                                 cmp edx,ted_tex_1
  2270.                                 jle .if_7e
  2271.                                         mov dword[endPos],edx
  2272.                         .if_7e:
  2273.  
  2274.                         pop edx
  2275.                 .if_2n:
  2276. ;if(i!=1){ // ­¥ ª®­¥æ ¤®ªã¬¥­â 
  2277. ;  cont_s=tex[eP].c;
  2278. ;  if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // ­¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
  2279. ;  if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ­¥ ç¨á«. ᨬ¢®«
  2280. ;  if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
  2281.  
  2282.                         cmp eax,ecx
  2283.                         je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç­® ¯®á«¥¤­¥¥
  2284.                 .if_0:
  2285.  
  2286.                 cmp edx,ted_tex_1
  2287.                 jle .wh_2e ;if(i==1) break;
  2288.  
  2289.                 ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
  2290.                 .wh_4b:
  2291.                 cmp ecx,eax
  2292.                 jle .wh_4e
  2293.                         ColToIndexOffset eax,ebx
  2294.                         ;cmp byte[ebx+esi],byte[edx]
  2295.                         mov bl,byte[ebx+esi]
  2296.                         cmp bl,byte[edx]
  2297.                         je .wh_4e
  2298.                                 inc eax
  2299.                         jmp .wh_4b
  2300.                 .wh_4e:
  2301.  
  2302.                 cmp eax,ecx
  2303.                 je .wh_2e;if(word_n==l_pos) break;
  2304.                         inc esi ;pos++;
  2305.                         jmp .wh_2b
  2306.                 .wh_2e:
  2307.  
  2308.                 cmp byte[find],1 ;if(fnd)break;
  2309.                 je @f
  2310.                         mov edx,[begPos];i=bP;
  2311.                 jmp @b
  2312.         @@:
  2313.  
  2314.         cmp byte[find],1
  2315.         jne .if_1e ;if(fnd){ // ¢ë¤¥«¥­¨¥ ­ ©¤¥­®£® ⥪áâ 
  2316.                 ;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
  2317.                 mov eax,[begPos]
  2318.                 mov bl,[f_color]
  2319.                 mov [eax+1],bl ;tex[bP].col=f_color;
  2320.                 mov eax,[endPos]
  2321.                 mov byte[eax+1],0xff ;tex[eP].col=255;
  2322.                 ;return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®­æ  ¢å®¦¤¥­¨ï
  2323.                 mov edx,[endPos]
  2324.                 call ted_get_text_perv_pos
  2325.                 jmp @f
  2326.         .if_1e:
  2327.                 mov edx,ted_tex
  2328.         @@:
  2329.  
  2330.         ret
  2331. endp
  2332.  
  2333. ;input:
  2334. ; edx = pointer to char (byte)
  2335. ;output:
  2336. ; cf=1 if symbol is...
  2337. align 16
  2338. 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
  2339. 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
  2340.  
  2341. ;output:
  2342. ; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ , æ¨äà  ¨«¨ '_'
  2343. align 16
  2344. isalnum:
  2345.         push eax ebx
  2346.         movzx eax,byte[edx] ;al=offset
  2347.         shr eax,3
  2348.         lea ebx,[tab_all_num]
  2349.         add ebx,eax
  2350.         movzx ax,byte[edx] ;al=bit
  2351.         and ax,111b
  2352.         bt word[ebx],ax
  2353.         pop ebx eax
  2354.         ret
  2355.  
  2356. ;output:
  2357. ; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢  ¨«¨ '_'
  2358. align 16
  2359. isalpha:
  2360.         push eax ebx
  2361.         movzx eax,byte[edx] ;al=offset
  2362.         shr eax,3
  2363.         lea ebx,[tab_alpha]
  2364.         add ebx,eax
  2365.         movzx ax,byte[edx] ;al=bit
  2366.         and ax,111b
  2367.         bt word[ebx],ax
  2368.         pop ebx eax
  2369.         ret
  2370.  
  2371. align 16
  2372. proc ted_show_help_f1 uses eax edx edi, edit:dword
  2373.         mov edi,[edit]
  2374.  
  2375.         call ted_get_pos_by_cursor
  2376.         push edx
  2377.                 call ted_iterat_next_color_tag
  2378.                 mov eax,edx
  2379.         pop edx
  2380.         call ted_iterat_perv_color_tag
  2381.  
  2382.         cmp eax,ted_tex
  2383.         jle @f
  2384.         cmp edx,ted_tex_1
  2385.         jle @f
  2386.                 stdcall ted_find_help_id,eax
  2387.         @@:
  2388.         ;call ted_draw_main_cursor
  2389.         call ted_draw_help_f1
  2390.         ret
  2391. endp
  2392.  
  2393. ;input:
  2394. ; edx = position begin 'symbol' struct
  2395. ; edi = pointer to tedit struct
  2396. ; end_pos = position end 'symbol' struct
  2397. align 16
  2398. proc ted_find_help_id, end_pos:dword
  2399. ; ecx = word_n
  2400. ; ebx = l_pos
  2401.   mov ted_help_id,-1
  2402.  
  2403.   push ebx ecx
  2404.     xor ebx,ebx
  2405.     mov bl,[edx]
  2406.     shl bx,2 ;ebx*=4
  2407.     add ebx,ted_arr_key_pos
  2408.     mov ecx,[ebx]
  2409.     cmp ecx,0
  2410.     jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
  2411.       push esi eax
  2412.       mov ebx,ecx ;l_pos=word_n;
  2413.       ColToIndexOffset ecx,esi
  2414.       push cx
  2415.       mov cl,[esi]
  2416.       @@:
  2417.         cmp ebx,ted_key_words_count ;while(l_pos<ted_key_words_count)
  2418.         jge @f
  2419.         ;ColToIndexOffset ecx,esi
  2420.         ColToIndexOffset ebx,eax
  2421.         cmp cl,[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
  2422.         jne @f
  2423.           inc ebx ;l_pos++;
  2424.           jmp @b
  2425.       @@:
  2426.       pop cx
  2427.       call ted_iterat_next ;pos=1;
  2428.       mov esi,1
  2429.       @@:
  2430.         push dx
  2431.         push word[edx]
  2432.         pop dx
  2433.           .wh_0b:
  2434.             cmp ebx,ecx ;while(l_pos>word_n
  2435.             jle .wh_0e
  2436.             dec ebx
  2437.             ColToIndexOffset ebx,eax
  2438.             inc ebx
  2439.             cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
  2440.             je .wh_0e
  2441.               dec ebx ;l_pos--;
  2442.             jmp .wh_0b
  2443.           .wh_0e:
  2444.  
  2445.           .wh_1b:
  2446.             cmp ebx,ecx ;while(l_pos>word_n
  2447.             jle .wh_1e
  2448.             ColToIndexOffset ecx,eax
  2449.             cmp byte[eax+esi],dl
  2450.             je .wh_1e
  2451.               inc ecx ;word_n++;
  2452.             jmp .wh_1b
  2453.           .wh_1e:
  2454.         pop dx
  2455.  
  2456.         cmp ecx,ebx ;if(word_n==l_pos) break;
  2457.         je @f
  2458.         call ted_iterat_next ;pos++;
  2459.         cmp edx,[end_pos] ;for(...;i<strlen;...)
  2460.         je @f ;jge
  2461.         inc esi
  2462.         jmp @b
  2463.       @@:
  2464.       pop eax esi
  2465.  
  2466.       mov ted_help_id,ecx
  2467.       ;return word_n;
  2468.  
  2469.     .if_0e:
  2470.   pop ecx ebx
  2471.   ret
  2472. endp
  2473.  
  2474. ;output:
  2475. ; eax = ª®¤ ®è¨¡ª¨
  2476. ; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
  2477. align 16
  2478. proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
  2479.         mov edi,[edit]
  2480.  
  2481.         ; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ ***
  2482.         ;¯à®¡ã¥¬ ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ä ©«¥
  2483.         mov ebx,[file]
  2484.         mov dword[ebx], SSF_GET_INFO
  2485.         mov dword[ebx+4], 0
  2486.         mov dword[ebx+8], 0
  2487.         mov dword[ebx+12], 0
  2488.         m2m dword[ebx+16], ted_tex
  2489.         mov  byte[ebx+20], 0
  2490.         push dword[f_name]
  2491.         pop dword[ebx+21]
  2492.         mcall SF_FILE
  2493.         or eax,eax
  2494.         jz .end_0
  2495.                 mov edx,ted_max_chars
  2496.                 cmp eax,2 ;äã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë
  2497.                 je @f
  2498.                 jmp .ret_f
  2499. align 4
  2500.         .end_0:
  2501.         ;¯à®¢¥à塞 墠â¨â «¨ ¯ ¬ï⨠¤«ï § £à㧪¨ ä ©« 
  2502.         mov ecx,ted_max_chars
  2503.         sub ecx,2 ;ecx = ¬ ªá¨¬ «ì­®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë«  ¢ë¤¥«¥­  ¯ ¬ïâì
  2504.         mov edx,ted_tex
  2505.         mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å
  2506.         cmp edx,ecx
  2507.         jl @f
  2508.                 ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫®
  2509.                 mov ecx,edx ;¯ ¬ïâì ­¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©« 
  2510.                 add ecx,2  ;¯ ¬ïâì ¤«ï á«ã¦¥¡­ëå ­ ç «ì­®£® ¨ ª®­¥ç­®£® ᨬ¢®«®¢
  2511.                 add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
  2512.                 mov ted_max_chars,ecx
  2513.                 imul ecx,sizeof.symbol
  2514.                 invoke mem.realloc, ted_tex,ecx
  2515.                 mov ted_tex,eax
  2516.                 mov ted_tex_1,eax
  2517.                 add ted_tex_1,sizeof.symbol
  2518.                 add eax,ecx
  2519.                 mov ted_tex_end,eax
  2520.                 mov ecx,ted_tex_1
  2521.                 add ecx,sizeof.symbol
  2522.                 mov ted_ptr_free_symb,ecx
  2523.         @@:
  2524.  
  2525.         ; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
  2526.         mov ebx,[file]
  2527.         mov dword[ebx], SSF_READ_FILE
  2528.         mov dword[ebx+4], 0
  2529.         mov dword[ebx+8], 0
  2530.         m2m dword[ebx+12], edx ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©«  (­¥ ¡®«ìè¥ ç¥¬ ted_max_chars)
  2531.         m2m dword[ebx+16], ted_tex
  2532.         mov  byte[ebx+20], 0
  2533.         push dword[f_name]
  2534.         pop dword[ebx+21]
  2535.         mcall SF_FILE
  2536.  
  2537.         or eax,eax
  2538.         jz @f
  2539.         cmp eax,6
  2540.         je @f
  2541.                 jmp .ret_f
  2542.         @@:
  2543.         cmp ebx,-1
  2544.         je .ret_f
  2545.                 ;if open file
  2546.                 call ted_on_open_file
  2547.         .ret_f:
  2548.         ret
  2549. endp
  2550.  
  2551. align 16
  2552. proc ted_but_select_word, edit:dword
  2553.         pushad
  2554.         mov edi,[edit]
  2555.  
  2556.         call ted_get_pos_by_cursor
  2557.         push edx
  2558.                 call ted_iterat_perv_color_tag
  2559.                 cmp edx,ted_tex_1
  2560.                 jle @f
  2561.                         call ted_get_text_coords
  2562.                         mov ted_sel_x0,ebx
  2563.                         mov ted_sel_y0,eax
  2564.                 @@:
  2565.         pop edx
  2566.         call ted_iterat_next_color_tag
  2567.         cmp edx,ted_tex_1
  2568.         jle @f
  2569.                 call ted_get_text_coords
  2570.                 mov ted_sel_x1,ebx
  2571.                 mov ted_sel_y1,eax
  2572.         @@:
  2573.  
  2574.         cmp ted_fun_draw_panel_buttons,0
  2575.         je @f
  2576.                 call ted_fun_draw_panel_buttons
  2577.         @@:
  2578.         stdcall ted_draw,edi
  2579.         popad
  2580.         ret
  2581. endp
  2582.  
  2583. ;output:
  2584. ; al = 1 if delete
  2585. align 16
  2586. proc ted_but_cut uses edi, edit:dword
  2587.         mov edi,[edit]
  2588.  
  2589.         stdcall ted_but_copy,edi
  2590.         call ted_set_undo
  2591.         stdcall ted_sel_text_del,ted_opt_ed_change_time
  2592.  
  2593.         cmp al,1
  2594.         jne @f
  2595.                 stdcall ted_draw,edi
  2596.                 cmp ted_fun_draw_panel_buttons,0
  2597.                 je @f
  2598.                         call ted_fun_draw_panel_buttons
  2599.         @@:
  2600.         ret
  2601. endp
  2602.  
  2603. align 16
  2604. proc ted_but_copy, edit:dword
  2605.         pushad
  2606.         mov edi,[edit]
  2607.  
  2608.         call ted_is_select
  2609.         or al,al
  2610.         jz .end_f ;if not selected text
  2611.         call ted_sel_normalize
  2612.  
  2613.         mov esi,ted_seln_x1
  2614.         mov ecx,ted_seln_y1
  2615.         call ted_get_pos_by_coords
  2616.         mov ebx,edx
  2617.         mov esi,ted_seln_x0
  2618.         mov ecx,ted_seln_y0
  2619.         call ted_get_pos_by_coords
  2620.         mov esi,ebx
  2621.  
  2622.         mov ecx,12 ;system buffer header size
  2623.         mov ebx,ted_buffer
  2624.         mov dword[ebx+4],0 ;text data
  2625.         mov dword[ebx+8],1 ;code 866
  2626.         add ebx,ecx
  2627.         @@:
  2628.                 cmp edx,ted_tex_1 ;end of file
  2629.                 jle @f
  2630.                 cmp edx,esi ;end of select
  2631.                 je @f
  2632.                 inc ecx
  2633.                 cmp ecx,ted_buffer_size ;owerflow bufer
  2634.                 je @f
  2635.  
  2636.                 mov al,byte[edx]
  2637.                 mov byte[ebx],al
  2638.                 inc ebx
  2639.                 cmp al,13
  2640.                 jne .no_13
  2641.                         mov byte[ebx],10 ;¤¥« ¥¬ ª®­¥æ áâப¨ ¢ ¡ãä¥à¥ 13,10 ¤«ï ᮢ¬¥á⨬®áâ¨ á ¤à㣨¬¨ ¯à®£à ¬¬ ¬¨
  2642.                         inc ebx
  2643.                         inc ecx
  2644.                 .no_13:
  2645.                
  2646.                 call ted_iterat_next
  2647.                 jmp @b
  2648.         @@:
  2649.         mov byte[ebx],0
  2650.  
  2651.         cmp ecx,12
  2652.         je .end_f
  2653.                 mov ebx,ted_buffer
  2654.                 mov [ebx],ecx
  2655.                 mcall SF_CLIPBOARD,SSF_WRITE_CB,ecx,ted_buffer
  2656.                 call ted_draw_buffer
  2657.                 cmp ted_fun_draw_panel_buttons,0
  2658.                 je .end_f
  2659.                         call ted_fun_draw_panel_buttons
  2660.         .end_f:
  2661.         popad
  2662.         ret
  2663. endp
  2664.  
  2665.  
  2666. align 16
  2667. proc ted_but_paste, edit:dword
  2668.         pushad
  2669.         mov edi,[edit]
  2670.  
  2671.         mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
  2672.         cmp eax,1
  2673.         jl .no_buf_r
  2674.  
  2675.         mov esi,eax
  2676.         .cycle: ;®¡à â­ë© 横« ¯® ᫮⠬
  2677.         dec esi ;­®¬¥à ⥪ã饣®, ¯à®¢¥à塞®£® á«®â 
  2678.         mcall SF_CLIPBOARD,SSF_READ_CB,esi
  2679.         cmp eax,1
  2680.         je .no_buf_r
  2681.         cmp eax,-1
  2682.         je .no_buf_r
  2683.                 mov ecx,[eax]
  2684.                 cmp ecx,1 ;size
  2685.                 jl .no_buf_r
  2686.                 cmp dword[eax+4],0 ;text
  2687.                 je @f
  2688.                         cmp esi,1
  2689.                         jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ­¥ ⥪áâ,   ᫮⮢ ¢ ¡ãä¥à¥ ­¥áª®«ìª®, ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
  2690.                         jmp .no_buf_r
  2691.                 @@:
  2692.                 cmp dword[eax+8],1 ;866
  2693.                 je @f
  2694.                         cmp esi,1
  2695.                         jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ⥪áâ ­¥ ¢ ª®¤¨à®¢ª¥ 866 ... ¯à®¡ã¥¬ ¯¥à¥©â¨ ª ¢¥àå­¥¬ã á«®âã
  2696.                         jmp .no_buf_r
  2697.                 @@:
  2698.                 ;ª®¯¨à®¢ ­¨¥ ⥪áâ  ¨§ á¨á⥬­®£® ¡ãä¥à  ¢® ¢­ãâ७­¨©
  2699.                 cmp ecx,ted_buffer_size
  2700.                 jle @f
  2701.                         mov ecx,ted_buffer_size
  2702.                 @@:
  2703.                 mov edi,ted_buffer
  2704.                 mov esi,eax
  2705.                 add     esi,4 ;12
  2706.                 mov dword[edi],ecx
  2707.                 add edi,4 ;12
  2708.                 sub ecx,4 ;12
  2709.                 rep movsb
  2710.                 mov edi,[edit]
  2711.  
  2712.                 mov esi,eax
  2713.                 add     esi,12
  2714.                 jmp .buf_r
  2715.         .no_buf_r:
  2716.                
  2717.         ;¥á«¨ ­¥ 㤠«®áì ¯à®ç¨â âì ¤ ­­ë¥ ¨§ á¨á⥬­®£® ¡ãä¥à , ¯®¯ ¤ ¥¬ á
  2718.         mov esi,ted_buffer
  2719.         cmp dword[esi],1 ;¯à®¢¥à塞 ¥áâì «¨ ¤ ­­ë¥ ¢® ¢­ãâ७­¥¬ ¡ãä¥à¥
  2720.         jl .no_paste ;¥á«¨ ¢®®¡é¥ ­¨ç¥£® ­¥ 㤠«®áì ¯à®ç¨â âì ¨¤¥¬ ­  ¢ë室
  2721.         add esi,12 ;system buffer header size
  2722.         .buf_r:
  2723.        
  2724.         mov edx,esi
  2725.         call tl_strlen
  2726.         cmp eax,1
  2727.         jl .no_paste
  2728.                 mov esi,eax
  2729.                 call ted_set_undo
  2730.                 mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  2731.                 stdcall ted_sel_text_del,ebx
  2732.                 cmp al,1
  2733.                 jne .del
  2734.                         mov ebx,ted_opt_ed_move_cursor
  2735.                 .del:
  2736.                 stdcall ted_text_add,edi,edx,esi,ebx
  2737.                 stdcall ted_draw,edi
  2738.                 cmp ted_fun_draw_panel_buttons,0
  2739.                 je .no_paste
  2740.                         call ted_fun_draw_panel_buttons
  2741.         .no_paste:
  2742.         popad
  2743.         ret
  2744. endp
  2745.  
  2746. align 16
  2747. proc ted_but_sumb_upper uses edi esi, edit:dword
  2748.         mov edi,[edit]
  2749.  
  2750.         stdcall ted_convert_sel_text,fb_char_toupper
  2751.         or esi,esi
  2752.         jz @f
  2753.                 stdcall ted_draw,edi
  2754.         @@:
  2755.         ret
  2756. endp
  2757.  
  2758. align 16
  2759. proc ted_but_sumb_lover uses edi esi, edit:dword
  2760.         mov edi,[edit]
  2761.  
  2762.         stdcall ted_convert_sel_text,fb_char_todown
  2763.         or esi,esi
  2764.         jz @f
  2765.                 stdcall ted_draw,edi
  2766.         @@:
  2767.         ret
  2768. endp
  2769.  
  2770. align 16
  2771. proc ted_but_reverse uses eax ebx edi, edit:dword
  2772.         mov edi,[edit]
  2773.  
  2774.         call ted_is_select
  2775.         or al,al
  2776.         jz @f
  2777.                 call ted_sel_normalize
  2778.                 push esi ecx edx
  2779.                         mov esi,ted_seln_x0
  2780.                         mov ecx,ted_seln_y0
  2781.                         call ted_get_pos_by_coords
  2782.                         mov eax,edx
  2783.                         mov esi,ted_seln_x1
  2784.                         cmp esi,0
  2785.                         je .beg_str
  2786.                                 dec esi
  2787.                         .beg_str:
  2788.                         mov ecx,ted_seln_y1
  2789.                         call ted_get_pos_by_coords
  2790.                         ;call ted_get_text_perv_pos
  2791.                         mov ebx,edx
  2792.                 pop edx ecx esi
  2793.                 ;cmp eax,...
  2794.                 ;je @f
  2795.                 call ted_revers
  2796.         @@:
  2797.         stdcall ted_draw,edi
  2798.         ret
  2799. endp
  2800.  
  2801. align 16
  2802. proc ted_but_undo uses eax edi, edit:dword
  2803.         mov edi,[edit]
  2804.  
  2805.         mov eax,ted_tim_undo
  2806.         cmp ted_tim_ch,eax
  2807.         jbe @f
  2808.                 inc ted_tim_undo
  2809.                 ;call ted_text_colored
  2810.                 stdcall ted_draw,edi
  2811.                 cmp ted_fun_draw_panel_buttons,0
  2812.                 je @f
  2813.                         call ted_fun_draw_panel_buttons
  2814.         @@:
  2815.         ret
  2816. endp
  2817.  
  2818. align 16
  2819. proc ted_but_redo uses edi, edit:dword
  2820.         mov edi,[edit]
  2821.  
  2822.         cmp ted_tim_undo,1
  2823.         jb @f
  2824.                 dec ted_tim_undo
  2825.                 ;call ted_text_colored
  2826.                 stdcall ted_draw,edi
  2827.                 cmp ted_fun_draw_panel_buttons,0
  2828.                 je @f
  2829.                         call ted_fun_draw_panel_buttons
  2830.         @@:
  2831.         ret
  2832. endp
  2833.  
  2834. ;description:
  2835. ; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ­  ª®â®àë© ãª §ë¢ ¥â ted_buffer_find
  2836. ;input:
  2837. ; f_opt = ¯ à ¬¥âàë ¯®¨áª :
  2838. ;   (0 - ¨áª âì ­¨¦¥ ªãàá®à , 1 - ¨áª âì ¢ëè¥ ªãàá®à , 2 - ¨áª âì ®â ­ ç «  ä ©« )
  2839. ;   ¥á«¨ ãáâ ­®¢«¥­ 31-© ¡¨â, â® ­¥ ®¡­®¢«ï¥âáï ®ª­®
  2840. ;output:
  2841. ; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
  2842. align 16
  2843. proc ted_but_find uses ebx ecx edx edi esi, edit:dword, f_opt:dword
  2844.         push [edit]
  2845.         cmp word[f_opt],2
  2846.         jne @f
  2847.                 call _but_find_first
  2848.                 jmp .end0
  2849.         @@:
  2850.         cmp word[f_opt],0
  2851.         jne @f
  2852.                 call _but_find_next
  2853.                 jmp .end0
  2854.         @@:
  2855.         cmp word[f_opt],1
  2856.         jne .end0
  2857.                 call _but_find_perv
  2858.         .end0:
  2859.  
  2860.         bt dword[f_opt],31
  2861.         jc .end1
  2862.         or eax,eax
  2863.         jz @f
  2864.                 ;⥪áâ ­ ©¤¥­, ®¡­®¢«ï¥¬ ®ª­®
  2865.                 stdcall ted_draw,edi
  2866.                 jmp .end1
  2867.         @@:
  2868.                 ;⥪áâ ­¥ ­ ©¤¥­, ¯à®¡ã¥¬ ¢ë§¢ âì á®®¡é¥­¨¥
  2869.                 cmp ted_fun_find_err,0
  2870.                 je .end1
  2871.                         call ted_fun_find_err ;¯®«ì§®¢ â¥«ì᪠ï äã­ªæ¨ï
  2872.         .end1:
  2873.         ret
  2874. endp
  2875.  
  2876. ;description:
  2877. ; äã­ªæ¨ï ­ å®¤¨â ⥪á⠮⠭ ç «  ä ©« , ¨«¨ ®â ª®­æ  ⥪ã饣® ¢ë¤¥«¥­¨ï
  2878. ;output:
  2879. ; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
  2880. ; ebx, ecx, edx, edi, edi - ¯®àâïâáï
  2881. align 16
  2882. proc _but_find_first, edit:dword
  2883.         mov edi,[edit]
  2884.  
  2885.         call ted_is_select
  2886.         or al,al
  2887.         jz @f
  2888.                 call ted_sel_normalize
  2889.                 mov edx,ted_sel_y1
  2890.                 mov ecx,ted_sel_x1
  2891.                 call ted_go_to_pos ;¯¥à¥å®¤ ­  ª®­¥æ ¢ë¤¥«¥­¨ï
  2892.                 call ted_get_pos_by_cursor
  2893.                 jmp .end0
  2894.         @@:
  2895.                 mov edx,ted_tex
  2896.                 call ted_iterat_next
  2897.         .end0:
  2898.         mov eax,ted_buffer_find
  2899.         mov bl,byte[eax]
  2900.         @@:
  2901.                 call ted_get_find_rezult
  2902.                 cmp bh,1
  2903.                 je @f ; find
  2904.                         call ted_iterat_next
  2905.                         cmp edx,ted_tex_1
  2906.                         jle @f
  2907.                         jmp @b
  2908.         @@:
  2909.         call _but_find_select
  2910.         ret
  2911. endp
  2912.  
  2913. ;description:
  2914. ; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ¢ëè¥ ªãàá®à 
  2915. ;output:
  2916. ; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
  2917. ; ebx, ecx, edx, edi, edi - ¯®àâïâáï
  2918. align 16
  2919. proc _but_find_perv, edit:dword
  2920.         mov edi,[edit]
  2921.         call ted_is_select
  2922.         or al,al
  2923.         jz @f
  2924.                 call ted_sel_normalize
  2925.                 mov edx,ted_sel_y0
  2926.                 mov ecx,ted_sel_x0
  2927.                 call ted_go_to_pos ;¯¥à¥å®¤ ­  ­ ç «® ¢ë¤¥«¥­¨ï
  2928.                 call ted_get_pos_by_cursor
  2929.                 call ted_iterat_perv ;¯¥à¥å®¤ ­  1-© ᨬ¢®« ¯¥à¥¤ ¢ë¤¥«¥­¨¥¬
  2930.                 jmp .end0
  2931.         @@:
  2932.         call ted_get_pos_by_cursor
  2933.         .end0:
  2934.         mov eax,ted_buffer_find
  2935.         mov bl,byte[eax]
  2936.         @@:
  2937.                 call ted_get_find_rezult
  2938.                 cmp bh,1
  2939.                 je @f ; find
  2940.                         call ted_iterat_perv
  2941.                         cmp edx,ted_tex_1
  2942.                         jle @f
  2943.                         jmp @b
  2944.         @@:
  2945.         call _but_find_select
  2946.         ret
  2947. endp
  2948.  
  2949. ;description:
  2950. ; äã­ªæ¨ï ­ å®¤¨â ⥪áâ ­¨¦¥ ªãàá®à 
  2951. ;output:
  2952. ; eax = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
  2953. ; ebx, edx, edi, esi - ¯®àâïâáï
  2954. align 16
  2955. proc _but_find_next, edit:dword
  2956.         mov edi,[edit]
  2957.  
  2958.         call ted_get_pos_by_cursor
  2959.         mov eax,ted_buffer_find
  2960.         mov bl,byte[eax]
  2961.         @@:
  2962.                 call ted_get_find_rezult
  2963.                 cmp bh,1
  2964.                 je @f ; find
  2965.                         call ted_iterat_next
  2966.                         cmp edx,ted_tex_1
  2967.                         jle @f
  2968.                         jmp @b
  2969.         @@:
  2970.         call _but_find_select
  2971.         ret
  2972. endp
  2973.  
  2974. ;description:
  2975. ; ¢á¯®¬®£ â¥«ì­ ï äã­ªæ¨ï, ¢ë¤¥«ï¥â ­ ©¤¥­­ë© ⥪áâ
  2976. ;input:
  2977. ; bh = ¡ë« «¨ ­ ©¤¥­ ¨áª®¬ë© ⥪áâ (0 - ­¥â, 1 - ¤ )
  2978. ; esi = first symbol pointer
  2979. align 16
  2980. _but_find_select:
  2981.         or bh,bh
  2982.         jz @f
  2983.                 call ted_get_text_coords
  2984.                 inc ebx ;move cursor right
  2985.                 mov ted_sel_x1,ebx
  2986.                 mov ted_sel_y1,eax
  2987.                 mov edx,eax
  2988.                 mov ecx,ebx
  2989.                 call ted_go_to_pos
  2990.                 mov edx,esi
  2991.                 call ted_get_text_coords
  2992.                 mov ted_sel_x0,ebx
  2993.                 mov ted_sel_y0,eax
  2994.                 xor eax,eax
  2995.                 inc eax
  2996.                 jmp .end0
  2997.         @@:
  2998.                 xor eax,eax ;⥪áâ ­¥ ­ ©¤¥­
  2999.         .end0:
  3000.         ret
  3001.  
  3002. ;input:
  3003. ; rpl_text = ⥪áâ ¤«ï § ¬¥­ë
  3004. ; r_opt = ¯ à ¬¥âàë ¯®¨áª :
  3005. ;   (0 - ¨áª âì ­¨¦¥ ªãàá®à , 1 - ¨áª âì ¢ëè¥ ªãàá®à , 2 - ¨áª âì ®â ­ ç «  ä ©« )
  3006. ; n_tim = 䨪á¨à®¢ âì § ¬¥­ã ¢ ¨§¬¥­¥­¨ïå (0 - ­¥â, 1 - ¤ )
  3007. ;output:
  3008. ; eax = 0 - ­¥ 㤠筮, 1 - 㤠筮
  3009. align 16
  3010. proc ted_but_replace uses edx edi esi, edit:dword, rpl_text:dword, r_opt:dword, n_tim:dword
  3011.         mov edi,[edit]
  3012.         mov eax,[r_opt]
  3013.         bts eax,31
  3014.         stdcall ted_but_find, edi,eax
  3015.         or eax,eax
  3016.         jz .end0
  3017.  
  3018.         xor edx,edx
  3019.         cmp dword[n_tim],0
  3020.         je @f
  3021.                 call ted_set_undo
  3022.                 mov edx,ted_opt_ed_change_time
  3023.         @@:
  3024.         stdcall ted_sel_text_del, edx
  3025.         or eax,0xff
  3026.         jz .end0
  3027.                 mov esi,[rpl_text]
  3028.                 stdcall tl_strlen
  3029.                 or eax,eax
  3030.                 jz .end0
  3031.                 stdcall ted_text_add, edi,esi,eax,ted_opt_ed_move_cursor
  3032.                 xor eax,eax
  3033.                 inc eax
  3034.         .end0:
  3035.         ret
  3036. endp
  3037.  
  3038. ;input:
  3039. ; eax - text need find
  3040. ; bl - first symbol to find
  3041. ; edx - first symbol pointer
  3042. ; edi - pointer to tedit struct
  3043. ;output:
  3044. ; bh - rezult
  3045. ; edx - last text position (if find sucess)
  3046. ; esi - first symbol pointer
  3047. ;description:
  3048. ; ”ã­ªæ¨ï ¯à®¢¥àï¥â ᮢ¯ ¤ ¥â «¨ ⥪áâ ¢ ¡ãä¥à¥ eax
  3049. ; á ⥪á⮬ । ªâ®à  ¯® 㪠§ â¥«î edx.
  3050. ; ‘â ­¤ àâ­ë¥ ä㭪樨 (­ ¯à. strcmp) âãâ ­¥ ¯®¤®©¤ãâ, ¯®â®¬ã çâ®
  3051. ; ¢ ¯ ¬ï⨠। ªâ®à  ⥪áâ ᮤ¥à¦¨âáï ­¥ ¢ ¢¨¤¥ ascii áâப.
  3052. align 16
  3053. ted_get_find_rezult:
  3054. push eax
  3055.         mov bh,1
  3056.         mov esi,edx ;copy edx
  3057.         @@:
  3058.                 cmp byte[edx],bl
  3059.                 jne .no_text
  3060.  
  3061.                 inc eax ;*** get next symbol (in find text) ***
  3062.                 mov bl,byte[eax]
  3063.                 or bl,bl
  3064.                 jz @f ;end of find text
  3065.  
  3066.                 call ted_iterat_next ;*** get next symbol (in editor text) ***
  3067.                 cmp edx,ted_tex_1
  3068.                 jg @b
  3069. align 4
  3070.                 .no_text:
  3071.         xor bh,bh
  3072.         mov edx,esi ;restore edx
  3073.         @@:
  3074. pop eax
  3075.         mov bl,byte[eax] ;restore bl
  3076.         ret
  3077.  
  3078. ;input:
  3079. ; edi = pointer to tedit struct
  3080. align 16
  3081. ted_key_ctrl_home:
  3082.         mov ted_cur_x,0
  3083.         mov ted_cur_y,0
  3084.         push eax
  3085.                 mov eax,ted_scr_w
  3086.                 mov dword[eax+sb_offs_position],0
  3087.                 mov eax,ted_scr_h
  3088.                 mov dword[eax+sb_offs_position],0
  3089.         pop eax
  3090.         stdcall ted_draw,edi
  3091.         cmp ted_fun_draw_panel_buttons,0
  3092.         je @f
  3093.                 call ted_fun_draw_panel_buttons
  3094.         @@:
  3095.         ret
  3096.  
  3097. ;input:
  3098. ; edi = pointer to tedit struct
  3099. align 16
  3100. ted_key_ctrl_end:
  3101.         push eax ebx
  3102.                 call ted_get_num_lines
  3103.                 mov ebx,ted_scr_w
  3104.                 mov [ebx+sb_offs_position],eax ;áâ ¢¨¬ ¯®«§ã­®ª ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
  3105.                 cmp eax,[ebx+sb_offs_cur_area]
  3106.                 jle @f
  3107.                         mov eax,[ebx+sb_offs_cur_area] ;¯®«ãç ¥¬ ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­®
  3108.                 @@:
  3109.                 sub [ebx+sb_offs_position],eax ;®â­¨¬ ¥¬ ®â ¯®«§ã­ª  ç¨á«® áâப ¢« §ïé¨å ¢ ®ª­® (­® ­¥ ¡®«ìè¥ â¥å, çâ® ¥áâì ¢ ¤®ªã¬¥­â¥)
  3110.                 dec eax
  3111.                 mov ted_cur_y,eax ;áâ ¢¨¬ ªãàá®à ­  ¯®á«¥¤­îî áâப㠤®ªã¬¥­â 
  3112.         pop ebx eax
  3113.         call ted_cur_move_x_last_char
  3114.         stdcall ted_draw,edi
  3115.         cmp ted_fun_draw_panel_buttons,0
  3116.         je @f
  3117.                 call ted_fun_draw_panel_buttons
  3118.         @@:
  3119.         ret
  3120.  
  3121. ;input:
  3122. ; edi = pointer to tedit struct
  3123. align 16
  3124. proc ted_sel_key_up
  3125.   cmp ted_drag_k,1
  3126.   je @f
  3127.     call ted_sel_start
  3128.     mov ted_drag_k,1
  3129.   @@:
  3130.   push dx
  3131.     call ted_cur_move_up
  3132.     cmp dl,8
  3133.     jne @f
  3134.       call ted_scroll_set_redraw
  3135.     @@:
  3136.   pop dx
  3137.   call ted_sel_move
  3138.   stdcall ted_draw,edi
  3139.   ret
  3140. endp
  3141.  
  3142. ;input:
  3143. ; edi = pointer to tedit struct
  3144. align 16
  3145. proc ted_sel_key_down
  3146.   cmp ted_drag_k,1
  3147.   je @f
  3148.     call ted_sel_start
  3149.     mov ted_drag_k,1
  3150.   @@:
  3151.   push dx
  3152.     call ted_cur_move_down
  3153.     cmp dl,8
  3154.     jne @f
  3155.       call ted_scroll_set_redraw
  3156.     @@:
  3157.   pop dx
  3158.   call ted_sel_move
  3159.   stdcall ted_draw,edi
  3160.   ret
  3161. endp
  3162.  
  3163. ;input:
  3164. ; edi = pointer to tedit struct
  3165. align 16
  3166. proc ted_sel_key_left
  3167.   cmp ted_drag_k,1
  3168.   je @f
  3169.     call ted_sel_start
  3170.   @@:
  3171.   push dx
  3172.     call ted_cur_move_left
  3173.     call ted_sel_move
  3174.     cmp ted_drag_k,1
  3175.     je @f
  3176.       mov ted_drag_k,1
  3177.       mov dl,8
  3178.     @@:
  3179.     cmp dl,8
  3180.     jne @f
  3181.       call ted_scroll_set_redraw
  3182.       stdcall ted_draw,edi
  3183.       jmp .end_f
  3184.     @@:
  3185.       stdcall ted_draw_cur_line,edi
  3186.     .end_f:
  3187.   pop dx
  3188.   ret
  3189. endp
  3190.  
  3191. ;input:
  3192. ; edi = pointer to tedit struct
  3193. align 16
  3194. proc ted_sel_key_right
  3195.   cmp ted_drag_k,1
  3196.   je @f
  3197.     call ted_sel_start
  3198.   @@:
  3199.   push dx
  3200.     call ted_cur_move_right
  3201.     call ted_sel_move
  3202.     cmp ted_drag_k,1
  3203.     je @f
  3204.       mov ted_drag_k,1
  3205.       mov dl,8
  3206.     @@:
  3207.     cmp dl,8
  3208.     jne @f
  3209.       call ted_scroll_set_redraw
  3210.       stdcall ted_draw,edi
  3211.       jmp .end_f
  3212.     @@:
  3213.       stdcall ted_draw_cur_line,edi
  3214.     .end_f:
  3215.   pop dx
  3216.   ret
  3217. endp
  3218.  
  3219. ;input:
  3220. ; edi = pointer to tedit struct
  3221. ;description:
  3222. ; this function need to optimize output
  3223. align 16
  3224. proc ted_draw_cursor_sumb
  3225. pushad
  3226.         mov ebx,ted_wnd_l
  3227.         add ebx,ted_rec_l
  3228.         mov edx,ted_cur_x
  3229.         imul edx,ted_rec_w
  3230.         add ebx,edx
  3231.         shl ebx,16
  3232.         add ebx,ted_rec_w
  3233.  
  3234.         mov ecx,ted_wnd_t ;calc rect -> y0,y1
  3235.         add ecx,ted_rec_t
  3236.         mov edx,ted_cur_y
  3237.         imul edx,ted_rec_h
  3238.         add ecx,edx
  3239.         shl ecx,16
  3240.         add ecx,ted_rec_h
  3241.  
  3242.         mov edx,ted_color_wnd_work
  3243.         call ted_sel_normalize
  3244.  
  3245.         mov esi,ted_scr_w
  3246.         mov eax,[esi+sb_offs_position]
  3247.         sub ted_seln_y0,eax
  3248.         sub ted_seln_y1,eax
  3249.  
  3250.         mov eax,ted_cur_y
  3251.         cmp eax,ted_seln_y0
  3252.         jl .no_cur_sel
  3253.         cmp eax,ted_seln_y1
  3254.         jg .no_cur_sel
  3255.                 mov edx,ted_color_select ;¬¥­ï¥¬ 梥â ä®­  ­  梥⠢뤥«¥­¨ï
  3256.                 mov esi,ted_scr_h
  3257.                 cmp eax,ted_seln_y0
  3258.                 jne @f
  3259.                         mov eax,ted_cur_x
  3260.                         add eax,[esi+sb_offs_position]
  3261.                         cmp eax,ted_seln_x0
  3262.                         jge @f
  3263.                         mov edx,ted_color_wnd_work
  3264.                 @@:
  3265.                 mov eax,ted_cur_y
  3266.                 cmp eax,ted_seln_y1
  3267.                 jne .no_cur_sel
  3268.                         mov eax,ted_cur_x
  3269.                         add eax,[esi+sb_offs_position]
  3270.                         cmp eax,ted_seln_x1
  3271.                         jl .no_cur_sel
  3272.                         mov edx,ted_color_wnd_work
  3273.         .no_cur_sel:
  3274.         mcall SF_DRAW_RECT
  3275.  
  3276.         call ted_get_pos_by_cursor ;¡¥à¥¬ ¯®§¨æ¨î ᨬ¢®« 
  3277.         cmp ted_gp_opt,2
  3278.         jne @f
  3279.                 mov esi,1
  3280.                 ror ecx,16
  3281.                 mov bx,cx
  3282.                 add ebx,0x10001
  3283.                 call ted_get_symb_color
  3284.                 call ted_convert_invis_symb
  3285.                 mcall SF_DRAW_TEXT ;à¨á®¢ ­¨¥ ᨬ¢®« 
  3286.         @@:
  3287. popad
  3288.         ret
  3289. endp
  3290.  
  3291. ;input:
  3292. ; edx -> pointer to text
  3293. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  3294. ;output:
  3295. ; ecx = color
  3296. ; if ted_mode_color=0 then ecx=ted_color_wnd_text
  3297. align 16
  3298. ted_get_symb_color:
  3299.         mov ecx,ted_color_wnd_text ;§ ¤ ¥¬ 梥â ⥪áâ  ¯® 㬮«ç ­¨î
  3300.  
  3301.         push eax edx
  3302.         cmp ted_mode_color,0
  3303.         je .exit
  3304.                 jmp .on_first
  3305.                 @@:
  3306.                         call ted_iterat_perv
  3307.                         cmp edx,ted_tex_1
  3308.                         jle .exit
  3309.                 .on_first:
  3310.                         xor eax,eax
  3311.                         mov al,byte[edx+1]
  3312.                         or al,al ;¥á«¨ al=0 ⮠梥⠭¥ ¬¥­ï¥âáï
  3313.                         jz @b
  3314.  
  3315.                 cmp eax,ted_colors_text_count
  3316.                 jge .exit
  3317.  
  3318.                 shl ax,2 ;㬭®¦ ¥¬ ¨­¤¥ªá æ¢¥â  ­  4 ¡ ©â 
  3319.                 mov ecx,ted_text_colors ;¯à¨¡ ¢«ï¥¬ ᬥ饭¨¥ 1-£® 梥â 
  3320.                 add ecx,eax
  3321.                 mov ecx,[ecx] ;ãáâ ­ ¢«¨¢ ¥¬ ⥪ã騩 梥â ⥪áâ  ¯® ᬥ饭¨î
  3322.         .exit:
  3323.         or ecx,ted_font_size
  3324.         pop edx eax
  3325.         ret
  3326.  
  3327. ;input:
  3328. ; edx = pointer to text
  3329. ; edi = pointer to tedit struct
  3330. ;description:
  3331. ; ”ã­ªæ¨ï ¯à¥®¡à §ã¥â ­¥¢¨¤¨¬ë¥ ᨬ¢®«ë ¢ ¯¥ç â ¥¬ë¥ ­  íªà ­¥
  3332. align 16
  3333. ted_convert_invis_symb:
  3334.         cmp ted_mode_invis,1
  3335.         jne .else
  3336.                 cmp byte[edx],9
  3337.                 jne @f
  3338.                         lea edx,[ted_symbol_tab]
  3339.                         jmp .end_f
  3340. align 4
  3341.                 @@:
  3342.                 cmp byte[edx],13
  3343.                 jne @f
  3344.                         mov edx,edi
  3345.                         add edx,ted_offs_symbol_new_line
  3346.                 @@:
  3347.                 jmp .end_f
  3348. align 4
  3349.         .else:
  3350.                 cmp byte[edx],9
  3351.                 je @f
  3352.                 cmp byte[edx],13
  3353.                 je @f
  3354.                         jmp .end_f
  3355.                 @@:
  3356.                         lea edx,[ted_symbol_space]
  3357.         .end_f:
  3358.         ret
  3359.  
  3360. ;input:
  3361. ; edi = pointer to tedit struct
  3362. align 16
  3363. ted_scroll_set_redraw:
  3364.         push eax
  3365.         mov eax,ted_scr_w
  3366.         mov dword[eax+sb_offs_redraw],1
  3367.         mov eax,ted_scr_h
  3368.         mov dword[eax+sb_offs_redraw],1
  3369.         pop eax
  3370.         ret
  3371.  
  3372. align 16
  3373. proc ted_draw, edit:dword
  3374.         locals
  3375.                 line_num dd ?
  3376.         endl
  3377.         pushad
  3378.         mov edi,[edit]
  3379.  
  3380.         mov eax,SF_DRAW_TEXT
  3381.         mov ecx,ted_text_colors
  3382.         mov ecx,[ecx]
  3383.  
  3384.         mov ebx,ted_wnd_l
  3385.         add ebx,ted_rec_l
  3386.         shl ebx,16
  3387.         add ebx,ted_wnd_t
  3388.         add ebx,ted_rec_t
  3389.         add ebx,0x10001 ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3390.  
  3391.         call ted_sel_normalize ;need before draw select
  3392.         mov esi,ted_scr_w
  3393.         mov esi,[esi+sb_offs_position]
  3394.         mov [line_num],esi
  3395.  
  3396.         stdcall ted_clear_line_before_draw, edi,ebx,1,esi
  3397.         call ted_get_first_visible_pos
  3398.         cmp edx,0
  3399.         je .no_draw_text
  3400.         mov esi,1 ;¤«¨­­  ¢ë¢®¤¨¬®£® ⥪áâ  ¯® 1-¬ã ᨬ¢®«ã
  3401.         @@:
  3402.                 call ted_iterat_next
  3403.                 cmp edx,ted_tex_1
  3404.                 jle .no_draw_text
  3405.  
  3406.                 ; *** 梥⮢ ï à §¬¥âª 
  3407.                 cmp ted_mode_color,0
  3408.                 je .no_col_change
  3409.                 cmp byte[edx+1],0
  3410.                 je .no_col_change
  3411.                         call ted_get_symb_color
  3412.                 .no_col_change:
  3413.  
  3414.                 cmp byte[edx],13
  3415.                 jne .no_13
  3416.                         cmp ted_mode_invis,1
  3417.                         jne .no_invis
  3418.                                 push edx
  3419.                                 mov edx,edi
  3420.                                 add edx,ted_offs_symbol_new_line
  3421.                                 int 0x40
  3422.                                 pop edx
  3423.                         .no_invis:
  3424.                         add ebx,ted_rec_h
  3425.                         ;optimized output \/
  3426.                         mov eax,ted_wnd_h
  3427.                         add eax,ted_wnd_t
  3428.                         cmp bx,ax
  3429.                         jg .no_draw_text
  3430.                         mov eax,SF_DRAW_TEXT
  3431.                         ;optimized output /\        
  3432.                         and ebx,0xffff
  3433.                         ror ebx,16
  3434.                         add ebx,ted_wnd_l
  3435.                         add ebx,ted_rec_l
  3436.                         inc ebx
  3437.                         ror ebx,16
  3438.                         inc dword[line_num] ;increment line number
  3439.                         stdcall ted_clear_line_before_draw,edi,ebx,1,dword[line_num]
  3440.                         call ted_opt_draw_line_left
  3441.                         jmp @b
  3442. align 4
  3443.                 .no_13:
  3444.  
  3445.                 int 0x40
  3446.                 ror ebx,16
  3447.                 add ebx,ted_rec_w
  3448.                 mov esi,ted_wnd_l
  3449.                 add esi,ted_wnd_w
  3450.                 cmp bx,si
  3451.                 jl .no_opt
  3452.                         call ted_opt_draw_line_right
  3453.                 .no_opt:
  3454.                 mov si,1
  3455.                 ror ebx,16
  3456.                 jmp @b
  3457.         .no_draw_text:
  3458.  
  3459.         inc dword[line_num]
  3460.         stdcall ted_clear_line_before_draw,edi,ebx,0,dword[line_num]
  3461.         call ted_draw_line_numbers
  3462.         call ted_draw_main_cursor
  3463.  
  3464. ;---------------------------------------------
  3465. ; set all_redraw flag for draw all ScrollBar
  3466. ; In some cases it is necessity to draw only the area
  3467. ; of moving of a "runner", for acceleration of output -
  3468. ; in this case the flag needs to be reset to 0 (zero).
  3469.         mov eax,ted_scr_h
  3470.         mov esi,ted_scr_w
  3471.         mov dword[eax+sb_offs_all_redraw],1
  3472.         mov dword[esi+sb_offs_all_redraw],1
  3473.  
  3474. ; à¨á®¢ ­¨¥ ¯®«®á ¯à®ªàã⪨
  3475.         stdcall scroll_bar_horizontal.draw,eax ;[scrollbar_hor_draw]
  3476.         stdcall scroll_bar_vertical.draw,esi ;[scrollbar_ver_draw]
  3477. ; reset all_redraw flag
  3478.         mov dword[eax+sb_offs_all_redraw],0
  3479.         mov dword[esi+sb_offs_all_redraw],0
  3480. ;---------------------------------------------
  3481.  
  3482.         ;left-bottom square
  3483.         mov ebx,ted_wnd_l
  3484.         shl ebx,16
  3485.         add ebx,ted_rec_l
  3486.         mov ecx,ted_wnd_t
  3487.         add ecx,ted_wnd_h
  3488.         shl ecx,16
  3489.         mov cx,word[eax+sb_offs_size_y]
  3490.         inc cx
  3491.         mcall SF_DRAW_RECT,,,ted_color_wnd_capt ;[sc.work]
  3492.  
  3493.         ;right-bottom square
  3494.         mov ebx,ted_wnd_l
  3495.         add ebx,ted_wnd_w
  3496.         shl ebx,16
  3497.         mov bx,word[esi+sb_offs_size_x]
  3498.         inc bx
  3499.         int 0x40
  3500.  
  3501.         cmp ted_fun_draw_panel_find,0
  3502.         je @f
  3503.                 call ted_fun_draw_panel_find
  3504.         @@:
  3505.         cmp ted_fun_draw_panel_syntax,0
  3506.         je @f
  3507.                 call ted_fun_draw_panel_syntax
  3508.         @@:
  3509.         popad
  3510.         ret
  3511. endp
  3512.  
  3513. ;input:
  3514. ; edi = pointer to tedit struct
  3515. align 16
  3516. proc ted_draw_main_cursor
  3517. pushad
  3518.  
  3519.         mov eax,SF_DRAW_RECT ;draw cursor
  3520.         mov ecx,ted_wnd_t ;calc rect -> y0,y1
  3521.         add ecx,ted_rec_t
  3522.         mov edx,ted_cur_y
  3523.         imul edx,ted_rec_h
  3524.         add ecx,edx
  3525.  
  3526.         cmp ted_cur_ins,1 ;¯à®¢¥àª  ०¨¬  à ¡®âë ªãàá®à  (®¡ëç­ë© ¨«¨ ¢áâ ¢ª )
  3527.         jne @f
  3528.                 mov edx,ted_rec_h
  3529.                 inc edx   ;1->1, 3->2, 5->3, ...
  3530.                 shr edx,1 ;edx = ¢ëá®â  áâப¨ ¤¥«¥­­ ï ­  2 (ª®£¤  ªãàá®à ­¥ ¯®«­ë©)
  3531.                 add ecx,edx
  3532.         @@:
  3533.         shl ecx,16
  3534.         add ecx,ted_rec_h
  3535.         cmp ted_cur_ins,1
  3536.         jne @f
  3537.                 shr cx,1 ;¤¥«¨¬ ¢ëá®âã ªãàá®à  ­  2
  3538.         @@:
  3539.  
  3540.         mov ebx,ted_wnd_l ;calc rect -> x0,x1
  3541.         add ebx,ted_rec_l
  3542.         mov edx,ted_cur_x
  3543.         imul edx,ted_rec_w
  3544.         add ebx,edx
  3545.         shl ebx,16
  3546.         add ebx,ted_rec_w
  3547.  
  3548.         mov edx,ted_color_cursor
  3549.         int 0x40 ;¢ë¢®¤ ªãàá®à 
  3550.  
  3551.         call ted_get_pos_by_cursor
  3552.         cmp ted_gp_opt,2
  3553.         jne @f
  3554.                 mov esi,1
  3555.                 ror ecx,16
  3556.                 mov bx,cx
  3557.                 add ebx,0x10001
  3558.                 cmp ted_cur_ins,1
  3559.                 jne .no_up_tetx
  3560.                         mov ecx,ted_rec_h
  3561.                         inc cx ; 1->1, 3->2, 5->3, ...
  3562.                         shr cx,1
  3563.                         sub bx,cx
  3564.                 .no_up_tetx:
  3565.                 mov ecx,ted_color_cur_text
  3566.                 or ecx,ted_font_size
  3567.                 call ted_convert_invis_symb
  3568.                 mcall SF_DRAW_TEXT
  3569.         @@:
  3570.  
  3571.         mov ebx,ted_wnd_l
  3572.         add ebx,ted_rec_l
  3573.         shl ebx,16
  3574.         add ebx,ted_wnd_t
  3575.         add ebx,3
  3576.         mov ecx,ted_color_wnd_bord
  3577.         or  ecx,0x80000000
  3578.         lea edx,[txtRow]
  3579.         mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ '‘âப '
  3580.  
  3581.         add ebx,0x500000
  3582.         lea edx,[txtCol]
  3583.         int 0x40 ;¢ë¢®¤ ¯®¤¯¨á¨ '‡­ ª'
  3584.  
  3585.         cmp ted_tim_undo,0
  3586.         je @f
  3587.                 add ebx,0x500000
  3588.                 lea edx,[txtOtm]
  3589.                 int 0x40
  3590.                 sub ebx,0x500000
  3591.         @@:
  3592.  
  3593.         call ted_draw_buffer
  3594.         call ted_draw_help_f1
  3595.  
  3596.         mov eax,47 ;draw cursor coords
  3597.         mov esi,ted_color_wnd_bord
  3598.         or  esi,0x40000000
  3599.  
  3600.         mov edx,ebx
  3601.         ror edx,16
  3602.         sub edx,35
  3603.         ror edx,16
  3604.         ;add edx,3
  3605.         mov ebx,0x40000 ;Row=...
  3606.         mov ecx,ted_scr_w
  3607.         mov ecx,[ecx+sb_offs_position]
  3608.         add ecx,ted_cur_y
  3609.         inc ecx
  3610.  
  3611. push edi
  3612.         mov edi,ted_color_wnd_work
  3613.         int 0x40 ;¢ë¢®¤ ç¨á«  ⥪ã饩 áâப¨
  3614. pop edi
  3615.  
  3616.         ;mov ebx,0x40000 ;Col=...
  3617.         mov ecx,ted_scr_h
  3618.         mov ecx,[ecx+sb_offs_position]
  3619.         add ecx,ted_cur_x
  3620.         inc ecx
  3621.         add edx,0x500000
  3622. push edi
  3623.         mov edi,ted_color_wnd_work
  3624.         int 0x40 ;¢ë¢®¤ ç¨á«  §­ ª®¢
  3625. pop edi
  3626.  
  3627.         cmp ted_tim_undo,0
  3628.         je @f
  3629.                 mov ecx,ted_tim_undo
  3630.                 add edx,0x500000
  3631.                 mov edi,ted_color_wnd_work ;¯®à⨬ ॣ¨áâà edi, ­® ¢ ª®­æ¥ ä㭪樨 í⮠㦥 ­¥ ¢ ¦­®
  3632.                 int 0x40 ;¢ë¢®¤ ç¨á«  ®â¬¥­¥­­ëå ¤¥©á⢨©
  3633.         @@:
  3634.  
  3635. popad
  3636.         ret
  3637. endp
  3638.  
  3639. ;input:
  3640. ; edi = pointer to tedit struct
  3641. align 16
  3642. proc ted_draw_buffer
  3643.         pushad
  3644.  
  3645.         mov eax,ted_buffer
  3646.         cmp dword[eax],1 ;ᬮâਬ à §¬¥à ¡ãä¥à 
  3647.         jl @f
  3648.                 mov ebx,ted_rec_l
  3649.                 add bx,300
  3650.                 cmp ebx,ted_wnd_w ;áà ¢­¨¢ ¥¬ ª®®à¤¨­ âã ¤«ï ¢ë¢®¤ ⥪áâ 
  3651.                 jge @f ;¯®¤¯¨áì ­¥ ¢« §¨â ¢ ®ª­®
  3652.  
  3653.                 add ebx,ted_wnd_l
  3654.                 shl ebx,16
  3655.                 add ebx,ted_wnd_t
  3656.                 add ebx,3
  3657.                 mov ecx,ted_color_wnd_bord
  3658.                 or ecx,0x40000000
  3659.  
  3660.                 mov edx,ted_buffer
  3661.                 add edx,12
  3662.                 mov esi,edx
  3663.                 mov edi,ted_color_wnd_work ;edi - destroy not pointer to tedit
  3664.                 call tl_strlen
  3665.                 ;cmp eax,0 ;¡ãä¥à ¯ãáâ
  3666.                 ;je @f
  3667.                 cmp eax,20
  3668.                 jle .crop_buf
  3669.                         mov eax,20 ;®¡à¥§ª  ¯®¤¯¨á¨ ¤® 20 ᨬ¢®«®¢
  3670.                 .crop_buf:
  3671.                 mov esi,eax
  3672.                 mcall SF_DRAW_TEXT ;¢ë¢®¤ ᮤ¥à¦¨¬®£® ¡ãä¥à 
  3673.  
  3674.                 sub ebx,50 shl 16
  3675.                 lea edx,[txtBuf]
  3676.                 mov esi,edx
  3677.                 call tl_strlen
  3678.                 mov esi,eax
  3679.                 xor ecx,0x40000000 ;㡨ࠥ¬ 梥â ä®­ 
  3680.                 mcall SF_DRAW_TEXT ;¢ë¢®¤ ¯®¤¯¨á¨ ¤«ï ¡ãä¥à 
  3681.         @@:
  3682.         popad
  3683.         ret
  3684. endp
  3685.  
  3686. ;input:
  3687. ; edi = pointer to tedit struct
  3688. align 16
  3689. proc ted_draw_help_f1
  3690.         pushad
  3691.         cmp ted_rec_t,13 ;¬¨­¨¬ «ì­ ï ¢ëá®â  ¤«ï à¨á®¢ ­¨ï á¯à ¢ª¨
  3692.         jle @f
  3693.                 ;clear place before draw help
  3694.                 mov ebx,ted_wnd_l
  3695.                 add ebx,ted_rec_l
  3696.                 shl ebx,16
  3697.                 add ebx,ted_wnd_w
  3698.                 sub ebx,ted_rec_l
  3699.                 mov ecx,ted_wnd_t
  3700.                 add ecx,13
  3701.                 shl ecx,16
  3702.                 add ecx,9 ;9 - ¢ëá®â  0-£® èà¨äâ , áâ ¢¨âì ted_rec_h ¯®ª  ¥é¥ à ­®
  3703.                 mcall SF_DRAW_RECT,,,ted_color_wnd_capt
  3704.  
  3705.         cmp ted_help_id,-1
  3706.         je @f
  3707.                 mov eax,ted_help_id
  3708.                 ColToIndexOffset eax,edx
  3709.  
  3710.                 ;SetCoordinates
  3711.                 mov ebx,ted_wnd_l
  3712.                 add ebx,ted_rec_l
  3713.                 shl ebx,16
  3714.                 add ebx,ted_wnd_t
  3715.                 add ebx,13 ;=3+10
  3716.  
  3717.                 ;SetTextColor
  3718.                 xor eax,eax
  3719.                 mov al,byte[edx+MAX_COLOR_WORD_LEN+7]
  3720.                 shl ax,2
  3721.                 mov ecx,ted_text_colors
  3722.                 add ecx,eax
  3723.                 mov ecx,[ecx]
  3724.                 or      ecx,0xc0000000 ;SetTextStyles
  3725.                 mov esi,edi
  3726.                 mcall SF_DRAW_TEXT,,,,,ted_color_wnd_work
  3727.                 mov edi,esi
  3728.  
  3729.                 mov esi,edx
  3730.                 call tl_strlen
  3731.  
  3732.                 ;*** draw help string ***
  3733.                 mov ecx,ted_color_wnd_bord
  3734.                 or ecx,0x80000000
  3735.                 mov edx,[edx+MAX_COLOR_WORD_LEN]
  3736.                 or edx,edx
  3737.                 jz @f
  3738.                         add edx,ted_help_text_f1
  3739.                         inc eax
  3740.                         imul eax,6 ;è¨à¨­  ᨬ¢®«  ¢ á¨áâ. èà¨äâ¥
  3741.                         shl eax,16                     
  3742.                         add ebx,eax
  3743.                         mcall SF_DRAW_TEXT
  3744.         @@:
  3745.         popad
  3746.         ret
  3747. endp
  3748.  
  3749. ;input:
  3750. ; edi = pointer to tedit struct
  3751. align 16
  3752. proc ted_draw_line_numbers
  3753. pushad
  3754.         ;top panel with caption
  3755.         mov ebx,ted_wnd_l
  3756.         ;add ebx,ted_rec_l
  3757.         shl ebx,16
  3758.         add ebx,ted_wnd_w
  3759.         ;sub ebx,ted_rec_l
  3760.         mov edx,ted_color_wnd_work
  3761.         mov ecx,ted_wnd_t
  3762.         shl ecx,16
  3763.         add ecx,ted_rec_t
  3764.         mov edx,ted_color_wnd_capt
  3765.         mcall SF_DRAW_RECT
  3766.  
  3767.         ;line numbers
  3768.         mov ebx,0x40000 ;format
  3769.         mov ecx,ted_scr_w
  3770.         mov ecx,[ecx+sb_offs_position]
  3771.         inc ecx
  3772.         mov edx,3
  3773.         add edx,ted_wnd_l
  3774.         rol edx,16
  3775.         add edx,ted_wnd_t
  3776.         add edx,ted_rec_t
  3777.         @@:
  3778.  
  3779. push ebx ecx edx
  3780.         ;left panel with numbers
  3781.         mov ebx,ted_wnd_l
  3782.         shl ebx,16
  3783.         add ebx,ted_rec_l
  3784.         mov ecx,ted_rec_h
  3785.         rol ecx,16
  3786.         mov cx,dx
  3787.         rol ecx,16
  3788.         mov edx,ted_color_wnd_capt
  3789.         mcall SF_DRAW_RECT ;à¨á㥬 ¯àאַ㣮«ì­¨ª ¯®¤ ­®¬¥à®¬ áâப¨
  3790. pop edx ecx ebx
  3791.  
  3792.                 mov esi,ted_color_wnd_bord
  3793.                 mcall SF_DRAW_NUMBER ;à¨á㥬 ­®¬¥à áâப¨
  3794.                 inc ecx
  3795.                 add edx,ted_rec_h
  3796.                 sub edx,ted_wnd_t
  3797.                 mov esi,edx
  3798.                 and esi,0xffff
  3799.                 cmp esi,ted_wnd_h
  3800.                 jge @f
  3801.                 add edx,ted_wnd_t
  3802.                 jmp @b
  3803. align 4
  3804.         @@:
  3805. popad
  3806.         ret
  3807. endp
  3808.  
  3809. ;output:
  3810. ; ah = symbol
  3811. align 16
  3812. proc KeyConvertToASCII uses ebx, table:dword
  3813.         mov ebx,[table] ;convert scan to ascii
  3814.         ror ax,8
  3815.         xor ah,ah
  3816.         add bx,ax ;? ebx,eax
  3817.         mov ah,byte[ebx]
  3818.         ret
  3819. endp
  3820.  
  3821. align 16
  3822. proc ted_draw_cur_line, edit:dword
  3823. pushad
  3824.         mov edi,[edit]
  3825.  
  3826.         mov ebx,ted_wnd_l
  3827.         add ebx,ted_rec_l
  3828.         shl ebx,16
  3829.         mov eax,ted_cur_y
  3830.         imul eax,ted_rec_h
  3831.         mov bx,ax
  3832.         add ebx,ted_wnd_t
  3833.         add ebx,ted_rec_t ;ebx - ª®®à¤¨­ âë ¤«ï ¯àאַ㣮«ì­¨ª  ®ç¨á⪨ «¨­¨¨
  3834.         add ebx,0x10001   ;¤®¡ ¢«ï¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3835.  
  3836.         call ted_sel_normalize ;need before draw select
  3837.         mov ecx,ted_cur_y
  3838.         mov eax,ted_scr_w
  3839.         add ecx,[eax+sb_offs_position]
  3840.         stdcall ted_clear_line_before_draw,edi,ebx,1,ecx
  3841.  
  3842.         mov eax,ted_scr_h
  3843.         mov esi,[eax+sb_offs_position]
  3844.         call ted_get_pos_by_coords
  3845.  
  3846.         cmp ted_gp_opt,2
  3847.         jne .no_draw_text
  3848.         call ted_get_symb_color
  3849.         mov esi,1 ;draw 1 symbol
  3850.         @@:
  3851.                 ;call ted_iterat_next
  3852.                 cmp edx,ted_tex_1
  3853.                 jle .no_draw_text
  3854.  
  3855.                 ; *** 梥⮢ ï à §¬¥âª 
  3856.                 cmp ted_mode_color,0
  3857.                 je .no_col_change
  3858.                 cmp byte[edx+1],0
  3859.                 je .no_col_change
  3860.                         call ted_get_symb_color
  3861.                 .no_col_change:
  3862.  
  3863.                 mov eax,SF_DRAW_TEXT
  3864.                 cmp byte [edx],13
  3865.                 jne .no_13
  3866.                         cmp ted_mode_invis,1
  3867.                         jne .no_draw_text
  3868.                         push edx
  3869.                         mov edx,edi
  3870.                         add edx,ted_offs_symbol_new_line
  3871.                         int 0x40
  3872.                         pop edx
  3873.                         jmp .no_draw_text
  3874. align 4
  3875.                 .no_13:
  3876.  
  3877.                 int 0x40
  3878.                 ror ebx,16
  3879.                 add ebx,ted_rec_w
  3880.                 mov eax,ted_wnd_w
  3881.                 add eax,ted_wnd_l ;ax = ®âáâ㯠¯® ®á¨ x
  3882.                 cmp bx,ax
  3883.                 jge .no_draw_text ;Opt
  3884.                 ror ebx,16
  3885.                 call ted_iterat_next
  3886.                 jmp @b
  3887. align 4
  3888.         .no_draw_text:
  3889.  
  3890.         call ted_draw_main_cursor
  3891. popad
  3892.         ret
  3893. endp
  3894.  
  3895. ;input:
  3896. ;  clear_o - ¥á«¨ =1 ®ç¨áâ¨âì ®¤­ã áâபã, =0 ®ç¨áâ¨âì ¢á¥ áâப¨ ®ª­  ¤® ­¨§ã
  3897. align 16
  3898. proc ted_clear_line_before_draw, edit:dword, coords:dword, clear_o:dword, numb_lin:dword
  3899.         pushad
  3900.         mov edi,[edit]
  3901.         mov ebx,[coords] ;ebx = x*2^16+y coords to left up point clear line
  3902.         mov esi,[numb_lin] ;esi - number text line
  3903.  
  3904.         sub ebx,0x10001 ;®â­¨¬ ¥¬ ®âáâã¯ë ¤«ï ¢ëà ¢­¨¢ ­¨ï ¡ãª¢ë ¯® 業âàã
  3905.         cmp dword[clear_o],0
  3906.         jne @f
  3907.                 add ebx,ted_rec_h
  3908.                 ror ebx,16
  3909.                 xor bx,bx
  3910.                 add ebx,ted_wnd_l
  3911.                 add ebx,ted_rec_l ;bx = ted_wnd_l+ted_rec_l
  3912.                 ror ebx,16
  3913.         @@:
  3914.  
  3915.         mov eax,ted_wnd_h
  3916.         add eax,ted_wnd_t
  3917.         cmp ax,bx
  3918.         jl .no_clear
  3919.         sub ax,bx
  3920.  
  3921.         mov cx,bx
  3922.         shl ecx,16
  3923.  
  3924.         xor bx,bx
  3925.         add ebx,ted_wnd_w
  3926.         sub ebx,ted_rec_l
  3927.         xor cx,cx
  3928.         add ecx,ted_rec_h
  3929.         mov edx,ted_color_wnd_work
  3930.  
  3931.         cmp dword[clear_o],0
  3932.         je .pusto
  3933.         cmp ax,cx
  3934.         jge @f
  3935.         .pusto:
  3936.                 mov cx,ax
  3937.                 jmp .no_select ;¥á«¨ ®ç¨á⪠ ®ª­  ¤® ­¨§ã, â® ¢á¥£¤  ä®­®¢ë¬ 梥⮬
  3938.         @@:
  3939.  
  3940.         call ted_is_select
  3941.         or al,al
  3942.         jz .no_select
  3943.         cmp ted_seln_y0,esi
  3944.         jg .no_select
  3945.         cmp ted_seln_y1,esi
  3946.         jl .no_select
  3947.                 mov edx,ted_color_select ;draw selected line
  3948.         .no_select:
  3949.  
  3950.         mcall SF_DRAW_RECT ;§ ªà áª  ¯®«­®© áâப¨ 梥⮬ ä®­  ¨«¨ 梥⮬ ¢ë¤¥«¥­¨ï
  3951.  
  3952.         call ted_is_select
  3953.         or al,al
  3954.         jz .no_clear
  3955.  
  3956.         mov al,SF_DRAW_RECT
  3957.         xor cx,cx
  3958.         add ecx,ted_rec_h
  3959.         cmp ted_seln_y0,esi
  3960.         jne @f
  3961.                 push bx esi
  3962.                 mov edx,ted_seln_x0 ; ¢¥àå­ïï ¯®«®á  (§ â¨à ¥â á«¥¢ )
  3963.                 mov esi,ted_scr_h
  3964.                 cmp edx,[esi+sb_offs_position]
  3965.                 jle .in_wnd
  3966.                         sub edx,[esi+sb_offs_position]
  3967.                         imul edx,ted_rec_w
  3968.                         mov bx,dx
  3969.                         jmp .no_wnd
  3970.                 .in_wnd:
  3971.                 xor bx,bx
  3972.                 .no_wnd:
  3973.                 mov edx,ted_color_wnd_work
  3974.                 int 0x40
  3975.                 pop esi bx
  3976.         @@:
  3977.         cmp ted_seln_y1,esi
  3978.         jne @f
  3979.                 ;push esi
  3980.                 ;¥á«¨ ¢ë¤¥«¥­ ¢¥áì ä ©« âãâ ¬®¦­® ᤥ« âì ¢ë室, ­® ⮣¤  ­ã¦­® ¢ëè¥ ã¡à âì jmp .no_select
  3981.                 mov edx,ted_seln_x1 ; ­¨¦­ïï ¯®«®á  (§ â¨à ¥â á¯à ¢ )
  3982.                 mov esi,ted_scr_h
  3983.                 cmp edx,[esi+sb_offs_position]
  3984.                 jle .in_wnd2
  3985.                         sub edx,[esi+sb_offs_position]
  3986.                         imul edx,ted_rec_w
  3987.                         sub bx,dx
  3988.                         shl edx,16
  3989.                         add ebx,edx
  3990.                 .in_wnd2:
  3991.                 mov edx,ted_color_wnd_work
  3992.                 int 0x40
  3993.                 ;pop esi
  3994.         @@:
  3995.  
  3996.         .no_clear:
  3997.         popad
  3998.         ret
  3999. endp
  4000.  
  4001. ;input:
  4002. ; edi = pointer to tedit struct
  4003. ;output:
  4004. ; ecx = ­®¢ë© 梥â ᨬ¢®« 
  4005. ; edx = pointer to symbol
  4006. ; edx = 0 if text not in screen
  4007. align 16
  4008. ted_get_first_visible_pos:
  4009.         push eax ecx
  4010.         mov eax,ted_scr_w
  4011.         mov edx,ted_tex
  4012.         xor ecx,ecx
  4013.         @@:
  4014.                 cmp ecx,[eax+sb_offs_position]
  4015.                 je @f
  4016.                 call ted_iterat_next
  4017.                 cmp edx,ted_tex_1
  4018.                 jle @f
  4019.                 cmp byte[edx],13
  4020.                 jne @b
  4021.                 inc ecx
  4022.                 jmp @b
  4023. align 4
  4024.         @@:
  4025.  
  4026.         cmp ecx,[eax+sb_offs_position]
  4027.         je @f
  4028.                 xor edx,edx
  4029.         @@:
  4030.         cmp ecx,[eax+sb_offs_max_area]
  4031.         jle @f
  4032.                 mov [eax+sb_offs_max_area],ecx
  4033.         @@:
  4034.         pop ecx eax
  4035.         call ted_opt_draw_line_left
  4036.         ret
  4037.  
  4038. ;input:
  4039. ; edx = pointer to symbol
  4040. ; edi = pointer to tedit struct
  4041. ;output:
  4042. ; ecx = 梥â ᨬ¢®« 
  4043. ; edx = 㪠§ â¥«ì ­  ¯¥à¢ë© «¥¢ë© ᨬ¢®«
  4044. ;description:
  4045. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  4046. align 16
  4047. proc ted_opt_draw_line_left uses ebx
  4048.         mov ebx,ted_scr_h
  4049.         mov ebx,[ebx+sb_offs_position]
  4050.         or ebx,ebx
  4051.         jz .ret_f
  4052.         push eax
  4053.         mov eax,edx
  4054.  
  4055.         cmp edx,ted_tex
  4056.         jne @f
  4057.                 call ted_iterat_next
  4058.                 jmp .beg_cycle
  4059.         @@:
  4060.  
  4061.         or ebx,ebx
  4062.         jz @f
  4063.  
  4064.         cmp byte[edx],13
  4065.         jne @f
  4066.                 call ted_iterat_next
  4067.                 .beg_cycle:
  4068.         @@:
  4069.                 cmp edx,ted_tex_1
  4070.                 jle @f
  4071.                 cmp byte[edx],13
  4072.                 je @f
  4073.                 or ebx,ebx
  4074.                 jz @f
  4075. ;--------------------------------------
  4076. xor eax,eax ;eax ¡ã¤¥â ¬¥­ïâìáï
  4077. mov al,byte[edx+1]
  4078. or al,al
  4079. jz .no_color
  4080. cmp eax,ted_colors_text_count
  4081. jge .no_color
  4082.         xor ecx,ecx
  4083.         mov cl,byte[edx+1]
  4084.         shl cx,2
  4085.         add ecx,ted_text_colors
  4086.         mov ecx,[ecx]
  4087. .no_color:
  4088. ;--------------------------------------
  4089.                 mov eax,edx
  4090.                 call ted_iterat_next
  4091.                 dec ebx
  4092.                 jmp @b
  4093. align 4
  4094.         @@:
  4095.                 mov edx,eax
  4096.         pop eax
  4097.         .ret_f:
  4098.         call ted_get_symb_color
  4099.         ret
  4100. endp
  4101.  
  4102. ;input:
  4103. ; edx = pointer to symbol
  4104. ; edi = pointer to tedit struct
  4105. ;output:
  4106. ; ecx = symbol color
  4107. ; edx = pointer to 13 symbol
  4108. ;description:
  4109. ; äã­ªæ¨ï ­ã¦­  ¤«ï ®¯â¨¬¨§ æ¨¨ ¢ë¢®¤  ⥪áâ 
  4110. align 16
  4111. proc ted_opt_draw_line_right
  4112.         push eax
  4113.         mov eax,edx
  4114.         @@:
  4115.                 cmp edx,ted_tex_1
  4116.                 jle @f
  4117.                 cmp byte[edx],13
  4118.                 je @f
  4119.                 mov eax,edx
  4120.                 call ted_iterat_next
  4121.                 jmp @b
  4122.         @@:
  4123.         mov edx,eax ;perv sumbol
  4124.         call ted_get_symb_color
  4125.  
  4126.         pop eax
  4127.         ret
  4128. endp
  4129.  
  4130. align 16
  4131. proc ted_mouse, edit:dword
  4132.         pushad
  4133.         mov edi,[edit]
  4134.  
  4135.         ;®¡à ¡ â뢠¥¬ áªà®««¨­£¨
  4136.         mov edx,ted_scr_h
  4137.         mov ecx,ted_scr_w
  4138.  
  4139.         cmp word[edx+sb_offs_delta2],0
  4140.         jne .horizontal
  4141.  
  4142.         mov eax,[ecx+sb_offs_max_area]
  4143.         cmp eax,[ecx+sb_offs_cur_area]
  4144.         jbe .horizontal
  4145.         ; mouse event for Vertical ScrollBar
  4146.         stdcall scroll_bar_vertical.mouse,ecx ;[scrollbar_ver_mouse]
  4147.         cmp dword[ecx+sb_offs_redraw],0
  4148.         je @f
  4149.                 mov dword[ecx+sb_offs_redraw],0
  4150.                 stdcall ted_draw,edi
  4151.                 jmp .no_in_wnd
  4152.         @@:
  4153.         cmp word[ecx+sb_offs_delta2],0
  4154.         jne .no_in_wnd
  4155.         .horizontal:
  4156.         mov eax,[edx+sb_offs_max_area]
  4157.         cmp eax,[edx+sb_offs_cur_area]
  4158.         jbe .other
  4159.         ; mouse event for Horizontal ScrollBar
  4160.         stdcall scroll_bar_horizontal.mouse,edx ;[scrollbar_hor_mouse]
  4161.         cmp dword[edx+sb_offs_redraw],0
  4162.         je .other
  4163.                 mov dword[edx+sb_offs_redraw],0
  4164.                 stdcall ted_draw,edi
  4165.                 jmp .no_in_wnd
  4166.         .other:
  4167.         cmp word[ecx+sb_offs_delta2],0
  4168.         jne .no_in_wnd
  4169.         cmp word[edx+sb_offs_delta2],0
  4170.         jne .no_in_wnd
  4171.  
  4172.         ;®¡à ¡ â뢠¥¬ ®ª­® । ªâ®à 
  4173.         mcall SF_MOUSE_GET,SSF_BUTTON
  4174.         cmp al,1
  4175.         jne @f
  4176.                 mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
  4177.                 mov ebx,ted_wnd_t
  4178.                 add ebx,ted_rec_t
  4179.                 cmp ax,bx
  4180.                 jl @f ;y_mouse<y_wnd
  4181.  
  4182.                 sub ebx,ted_rec_t
  4183.                 add ebx,ted_wnd_h
  4184.                 cmp bx,ax
  4185.                 jl @f ;y_mouse>y_wnd
  4186.  
  4187.                 mov ebx,ted_wnd_l
  4188.                 add ebx,ted_rec_l
  4189.                 mov ecx,eax
  4190.                 shr ecx,16
  4191.                 cmp cx,bx
  4192.                 jl @f ;x_mouse<x_wnd
  4193.  
  4194.                 sub ebx,ted_rec_l
  4195.                 add ebx,ted_wnd_w
  4196.                 cmp bx,cx
  4197.                 jl @f ;x_mouse>x_wnd
  4198.  
  4199.                 call ted_draw_cursor_sumb
  4200.                 call ted_wnd_main_click
  4201.                 jmp .no_in_wnd
  4202.         @@:
  4203.         mov edx,ted_el_focus
  4204.         cmp [edx],edi
  4205.         jne @f
  4206.                 call ted_wnd_main_mouse_scroll ;ᬮâਬ ­  ¯à®ªàãâªã ª®«¥á  ¬ëè¨
  4207.         @@:
  4208.         cmp ted_drag_m,0
  4209.         je .no_in_wnd
  4210.                 mov ted_drag_m,0
  4211.                 stdcall ted_draw,edi
  4212.                 cmp ted_fun_draw_panel_buttons,0
  4213.                 je .no_in_wnd
  4214.                         call ted_fun_draw_panel_buttons
  4215.         .no_in_wnd:
  4216.         popad
  4217.         ret
  4218. endp
  4219.  
  4220. ;input:
  4221. ; eax -> (x,y)
  4222. ; edi -> 㪠§ â¥«ì ­  áâàãªâãàã tedit
  4223. ;description:
  4224. ; äã­ªæ¨ï ¢ë§ë¢¥âáï ¯à¨ ­ ¦ â¨¨ ª­®¯ª®© ¬ëè¨ ¨ ¯®¯ ¤¥­¨¨ ªãàá®à®¬ ¢ ®ª­® । ªâ®à 
  4225. align 16
  4226. ted_wnd_main_click:
  4227.         push ebx ecx edx
  4228.         mov ebx,ted_el_focus
  4229.         mov [ebx],edi ;áâ ¢¨¬ 䮪ãá
  4230.  
  4231.         push eax
  4232.                 shr eax,16
  4233.                 sub eax,ted_wnd_l
  4234.                 sub eax,ted_rec_l
  4235.  
  4236.                 xor edx,edx
  4237.                 mov ecx,ted_rec_w
  4238.                 div cx
  4239.                 ;inc eax
  4240.                 mov ebx,ted_scr_h
  4241.                 cmp eax,[ebx+sb_offs_cur_area]
  4242.                 jle @f
  4243.                         mov eax,[ebx+sb_offs_cur_area]
  4244.                 @@:
  4245.                 ;dec eax
  4246.                 mov ted_cur_x,eax
  4247.         pop eax
  4248.  
  4249.         push eax
  4250.                 and eax,0xffff
  4251.                 sub eax,ted_wnd_t
  4252.                 sub eax,ted_rec_t
  4253.  
  4254.                 xor edx,edx
  4255.                 mov ecx,ted_rec_h
  4256.                 div cx
  4257.                 inc eax
  4258.                 mov ebx,ted_scr_w
  4259.                 cmp eax,[ebx+sb_offs_cur_area]
  4260.                 jle @f
  4261.                         mov eax,[ebx+sb_offs_cur_area]
  4262.                 @@:
  4263.                 dec eax
  4264.                 mov ted_cur_y,eax
  4265.         pop eax
  4266.  
  4267.         cmp ted_drag_m,0
  4268.         je @f
  4269.                 call ted_sel_move
  4270.                 jmp .sel_move
  4271.         @@:
  4272.                 mov ted_drag_m,1
  4273.                 call ted_sel_start
  4274.         .sel_move:
  4275.         pop edx ecx ebx
  4276.         ret
  4277.  
  4278. ;input:
  4279. ; edi = pointer to tedit struct
  4280. align 16
  4281. ted_wnd_main_mouse_scroll:
  4282.         push eax ebx ecx
  4283.         mcall SF_MOUSE_GET,SSF_SCROLL_DATA
  4284.         or ax,ax
  4285.         jz .no_scroll
  4286.                 mov ecx,ted_scr_w
  4287.                 mov ebx,[ecx+sb_offs_position] ;copy old scroll position
  4288.                 and eax,0xffff
  4289.                 btr ax,15
  4290.                 jae @f
  4291.                         or eax,0xffff8000
  4292.                 @@:
  4293.                 add [ecx+sb_offs_position],eax
  4294.  
  4295.                 mov eax,[ecx+sb_offs_position]
  4296.                 cmp eax,[ecx+sb_offs_max_area]
  4297.                 jb @f
  4298.                         mov [ecx+sb_offs_position],ebx ;if scroll position out of range
  4299.                         jmp .no_scroll
  4300.                 @@:
  4301.                 stdcall ted_draw,edi
  4302.         .no_scroll:
  4303.         pop ecx ebx eax
  4304.         ret
  4305.  
  4306. align 16
  4307. proc ted_save_file, edit:dword, file:dword, f_name:dword
  4308. pushad
  4309.         mov edi,[edit]
  4310.  
  4311.         stdcall ted_can_save,edi
  4312.         ;or al,al
  4313.         ;jz .no_save
  4314.  
  4315.         mov ecx,ted_max_chars
  4316.         invoke mem.alloc,ecx
  4317.         push eax ;§ ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4318.  
  4319.         mov edx,ted_tex
  4320.         xor ecx,ecx
  4321.         @@:
  4322.                 call ted_iterat_next
  4323.                 cmp edx,ted_tex_1
  4324.                 jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
  4325.                 mov bl,[edx]
  4326.                 mov byte[eax],bl
  4327.                 inc eax
  4328.                 inc ecx
  4329.                 jmp @b
  4330. align 4
  4331.         @@:
  4332.  
  4333.         or ecx,ecx
  4334.         jz @f
  4335.                 mov ebx,[file]
  4336.                 pop eax ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4337.                 mov [ebx+16],eax
  4338.                 push eax ;®¡à â­® § ¯®¬¨­ ¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4339.                 mov dword[ebx], SSF_CREATE_FILE
  4340.                 mov dword[ebx+4], 0
  4341.                 mov dword[ebx+8], 0
  4342.                 mov [ebx+12], ecx
  4343.                 mov  byte[ebx+20], 0
  4344.                 push dword[f_name]
  4345.                 pop dword[ebx+21]
  4346.                 mcall SF_FILE
  4347.  
  4348.                 mov ted_err_save,al
  4349.  
  4350.                 or eax,eax
  4351.                 jz .no_msg
  4352.                 ;cmp eax,6
  4353.                 ;je @f
  4354.                 cmp ax,10
  4355.                 jl .zifra_0_9
  4356.                         mov al,'?'
  4357.                         sub ax,48
  4358.                 .zifra_0_9:
  4359.                 add ax,48
  4360.                 cmp ted_fun_save_err,0
  4361.                 je @f
  4362.                 call ted_fun_save_err
  4363.                 jmp @f
  4364.                 .no_msg:
  4365.                 m2m ted_tim_ls,ted_tim_ch
  4366.         @@:
  4367.  
  4368.         pop ecx ;§ ¯¨á뢠¥¬ 㪠§ â¥«ì ­  ¢ë¤¥«¥­­ãî ¯ ¬ïâì
  4369.         invoke mem.free,ecx
  4370.         .no_save:
  4371. popad
  4372.         ret
  4373. endp
  4374.