Subversion Repositories Kolibri OS

Rev

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

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