Subversion Repositories Kolibri OS

Rev

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