Subversion Repositories Kolibri OS

Rev

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

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