Subversion Repositories Kolibri OS

Rev

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