Subversion Repositories Kolibri OS

Rev

Rev 7579 | Rev 7877 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; ¬ ªà®á ¤«ï á¨á⥬­®© ¡¨¡«¨®â¥ª¨ box_lib.obj
  2. ; í«¥¬¥­â TextEditor ¤«ï Kolibri OS
  3. ; ä ©« ¯®á«¥¤­¨© à § ¨§¬¥­ï«áï 29.01.2019 IgorA
  4. ; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
  5.  
  6. ;input:
  7. ; edi = pointer to tedit struct
  8. ; reg = index
  9. ;output:
  10. ; reg = pointer to 'tex' struct
  11. macro ConvertIndexToPointer reg {
  12.         imul reg,sizeof.symbol
  13.         add reg,ted_tex
  14. }
  15.  
  16. ;--- out_reg = ted_key_words_data[ind_reg].Text[0] ---
  17. macro ColToIndexOffset ind_reg,out_reg {
  18.         mov out_reg,ind_reg
  19.         imul out_reg,sizeof.TexColViv
  20.         add out_reg,ted_key_words_data
  21. }
  22.  
  23. TED_LINES_IN_NEW_FILE equ 30 ;ç¨á«® áâப ¢ ­®¢®¬ ä ©«¥
  24. MAX_COLOR_WORD_LEN equ 40
  25. ;------------------------------------------------------------------------------
  26. struct TexSelect
  27.         x0 dd ?
  28.         y0 dd ?
  29.         x1 dd ?
  30.         y1 dd ?
  31. ends
  32.  
  33. struct TexColViv
  34.         Text  rb MAX_COLOR_WORD_LEN ; á«®¢® ¤«ï ¯®¤á¢¥âª¨
  35.         f1    dd 0 ; á¯à ¢ª  ¯® á«®¢ã
  36.         flags db ? ; f1+4 ä« £¨ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ¢ë¤¥«¥­¨¨
  37.         endc  db ? ; f1+5 ᨬ¢®« ª®­æ  ¢ë¤¥«¥­¨ï (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
  38.         escc  db ? ; f1+6 íªà ­¨àãî騩 ᨬ¢®« (¨á¯®«ì§ã¥âáï ¯à¨ flags&4)
  39.         color db ? ; f1+7 ­®¬¥à 梥â 
  40. ends
  41.  
  42. struct symbol
  43.         c db ?    ;  +0 ᨬ¢®«
  44.         col db ?  ;  +1 梥â
  45.         perv dd ? ;  +2
  46.         next dd ? ;  +6 㪠§ â¥«¨
  47.         tc dd ?   ; +10 ¢à¥¬. á®§¤ ­¨ï
  48.         td dd ?   ; +14 ¢à¥¬. 㤠«¥­¨ï
  49. ends
  50. ;------------------------------------------------------------------------------
  51.  
  52. ted_symbol_space db 32 ;ascii ª®¤ ¯à®¡¥« , ¨­®£¤  ¡ë¢ ¥â ­ã¦¥­ ¢ ª®¤¥
  53. ted_symbol_tab db 26 ;ascii ª®¤ áâ५ª¨ ¢¯à ¢®, ¨á¯®«ì§ã¥âáï ¤«ï à¨á®¢ ­¨ï â ¡ã«ï樨 ¢ ०¨¬¥ ¯®ª §  ­¥¢¨¤¨¬ëå ᨬ¢®«®¢
  54.  
  55. if lang eq ru
  56.  
  57. txtRow db '‘âப ',0
  58. txtCol db '‡­ ª',0
  59. txtOtm db 'Žâ¬¥­ë',0
  60. txtBuf db 'ãä¥à:',0
  61.  
  62. else
  63.  
  64. txtRow db 'Rows',0
  65. txtCol db 'Cols',0
  66. txtOtm db 'Undo',0
  67. txtBuf db 'Buffer:',0
  68.  
  69. end if
  70.  
  71. ;EvChar - â ¡«¨æ  ¤«ï 䨫ìâ஢ ­¨ï ¤®¡ ¢«ï¥¬ëå ᨬ¢®«®¢, çâ®-¡ë ­¥ ¯®¯ «¨ «¨è­¨¥ §­ ª¨
  72. align 16
  73. EvChar db 0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0
  74.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  75.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  76.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  77.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  78.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  79.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  80.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
  81.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  82.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  83.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  84.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  85.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  86.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  87.     db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  88.     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  89.  
  90. KM_SHIFT equ 0x00010000
  91. KM_CTRL equ 0x00020000
  92. KM_ALT equ 0x00040000
  93. KM_NUMLOCK equ 0x00080000
  94.  
  95. ; KEY CODES
  96. KEY_F1 equ 0x0000003B
  97. KEY_F2 equ 0x0000003C
  98. KEY_F3 equ 0x0000003D
  99.  
  100.  
  101.  
  102. align 16
  103. proc ted_init uses eax ecx edi, edit:dword
  104.         mov edi,[edit]
  105.  
  106.         mov ecx,sizeof.symbol
  107.         imul ecx,ted_max_chars
  108.         invoke mem.alloc,ecx ;¢ë¤¥«ï¥¬ ¯ ¬ïâì
  109.         mov ted_tex,eax
  110.         mov ted_tex_1,eax
  111.         add ted_tex_1,sizeof.symbol
  112.         add eax,ecx
  113.         mov ted_tex_end,eax
  114.  
  115.         stdcall ted_clear, edi,1
  116.  
  117. ;-------------------------------------------------
  118.         mov ecx,1024 ;1024 - ¤«ï ¬ áᨢ  ted_arr_key_pos
  119.         add ecx,ted_syntax_file_size
  120.         invoke mem.alloc,ecx
  121.         mov ted_arr_key_pos,eax
  122.         add eax,1024
  123.         mov ted_syntax_file,eax
  124.  
  125.         stdcall ted_init_scroll_bars,edi,3
  126.         ret
  127. endp
  128.  
  129. MIN_W_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï ¢¥àâ. áªà®««¨­£ 
  130. MIN_H_SCRL_ARE equ 3 ;¬¨­¨¬ «ì­ ï ®â®¡à ¦ ¥¬ ï ®¡« áâì ¤«ï £®à¨§. áªà®««¨­£ 
  131. ;input:
  132. ; opt = 1 - ¬¥­ïâì æ¢¥â áªà®««¨­£®¢, 2 - ¨§¬¥­¨«¨áì à §¬¥àë ®ª­ ,
  133. ;  4 - ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â 
  134. align 16
  135. proc ted_init_scroll_bars, edit:dword, opt:dword
  136.         pushad
  137.         mov edi,[edit]
  138.         mov esi,ted_scr_w
  139.         mov ebx,ted_scr_h
  140.         bt dword[opt],0
  141.         jae @f
  142.                 mov ecx,ted_color_wnd_work
  143.                 mov dword[esi+sb_offs_bckg_col],ecx
  144.                 mov dword[ebx+sb_offs_bckg_col],ecx
  145.                 mov ecx,ted_color_wnd_capt
  146.                 mov dword[esi+sb_offs_frnt_col],ecx
  147.                 mov dword[ebx+sb_offs_frnt_col],ecx
  148.                 mov ecx,ted_color_wnd_bord
  149.                 mov dword[esi+sb_offs_line_col],ecx
  150.                 mov dword[ebx+sb_offs_line_col],ecx
  151.         @@:
  152.         bt dword[opt],2 ; ¨§¬¥­¨«¨áì à §¬¥àë ¤®ªã¬¥­â  ?
  153.         jae .doc_resize
  154.                 call ted_get_num_lines
  155.                 cmp eax,TED_LINES_IN_NEW_FILE
  156.                 jge @f
  157.                         mov eax,TED_LINES_IN_NEW_FILE
  158.                 @@:
  159.                 mov dword[esi+sb_offs_max_area],eax
  160.         .doc_resize:
  161.         bt dword[opt],1 ; ¨§¬¥­¨«¨áì à §¬¥àë ®ª­  ?
  162.         jae .no_size
  163.                         mov edx,ted_wnd_l
  164.                         add edx,ted_rec_l
  165.                         mov word[ebx+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠£®à¨§. áªà®««¨­£ 
  166.                         mov eax,ted_wnd_h ;calculate lines in page
  167.                         mov edx,ted_wnd_t
  168.                         add edx,eax
  169.                         mov word[ebx+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠£®à¨§. áªà®««¨­£ 
  170.                 sub eax,ted_rec_t
  171.                 xor edx,edx
  172.                 mov ecx,ted_rec_h
  173.                 div ecx
  174.                 cmp eax,MIN_W_SCRL_ARE
  175.                 jg @f
  176.                         mov eax,MIN_W_SCRL_ARE
  177.                 @@:
  178.                 mov dword[esi+sb_offs_cur_area],eax
  179.  
  180.                 mov eax,ted_wnd_w ;calculate cols in page
  181.                         mov edx,ted_wnd_l ;«¥¢ë© ®âáâ㯠®ª­ 
  182.                         add edx,eax ;¤®¡ ¢«ï¥¬ è¨à¨­ã ®ª­ 
  183.                         mov word[esi+sb_offs_start_x],dx ;¢ëáâ ¢«ï¥¬ «¥¢ë© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
  184.                         mov edx,ted_wnd_t
  185.                         mov word[esi+sb_offs_start_y],dx ;¢ëáâ ¢«ï¥¬ ¢¥àå­¨© ®âáâ㯠¢¥àâ. áªà®««¨­£ 
  186.                         mov edx,ted_wnd_h
  187.                         mov word[esi+sb_offs_size_y],dx ;¢ëáâ ¢«ï¥¬ ¢ëá®âã ¢¥àâ. áªà®««¨­£ 
  188.                 sub eax,ted_rec_l
  189.                         mov word[ebx+sb_offs_size_x],ax ;¢ëáâ ¢«ï¥¬ è¨à¨­ã £®à¨§. áªà®««¨­£ 
  190.                 xor edx,edx
  191.                 mov ecx,ted_rec_w
  192.                 div ecx
  193.                 cmp eax,MIN_H_SCRL_ARE
  194.                 jg @f
  195.                         mov eax,MIN_H_SCRL_ARE
  196.                 @@:
  197.                 dec eax
  198.                 mov dword[ebx+sb_offs_cur_area],eax ;ãáâ ­ ¢«¨¢ ¥¬ ç¨á«® ᨬ¢®«®¢, ª®â®àë¥ ¢« §ïâ ¢ íªà ­ ¤«ï £®à¨§. áªà®««¨­£ 
  199.         .no_size:
  200.         popad
  201.         ret
  202. endp
  203.  
  204. align 16
  205. proc ted_delete uses edi, edit:dword
  206.         mov edi,[edit]
  207.         invoke mem.free,ted_tex
  208.         invoke mem.free,ted_arr_key_pos ;ted_syntax_file
  209.         ret
  210. endp
  211.  
  212.  
  213. ;input:
  214. ; eax = key kodes
  215. align 16
  216. proc ted_key, edit:dword, table:dword, control:dword
  217.         pushad
  218.         mov edi,[edit]
  219.         mov esi,ted_el_focus
  220.         cmp dword[esi],edi
  221.         jne .end_key_fun ;í«¥¬¥­â ­¥ ¢ 䮪ãᥠ¢ë室¨¬ ¨§ ä㭪樨
  222.         mov esi,dword[control]
  223.  
  224.         cmp ah,KEY_F1 ;[F1]
  225.         jne @f
  226.                 stdcall ted_show_help_f1,edi
  227.                 jmp .end_key_fun
  228.         @@:
  229.         cmp ah,KEY_F3 ;[F3]
  230.         jne @f
  231.                 stdcall ted_but_find,edi,0
  232.                 jmp .end_key_fun
  233.         @@:
  234.  
  235.         test esi,KM_CTRL ;Ctrl+...
  236.         jz .key_Ctrl
  237.                 ; *** ¢ë§®¢ ¢­¥è­¨å ä㭪権 ª®â®àë¥ âॡãîâ ®ª­  ®âªàëâ¨ï/á®åà ­¥­¨ï/¯®¨áª /...
  238.                 cmp ted_fun_on_key_ctrl_all,0
  239.                 je .end0
  240.                 xor al,al
  241.                 cmp ah,24 ;Ctrl+O
  242.                 jne @f
  243.                         mov al,'O'
  244.                 @@:
  245.                 cmp ah,31 ;Ctrl+S
  246.                 jne @f
  247.                         mov al,'S'
  248.                 @@:
  249.                 cmp ah,33 ;Ctrl+F
  250.                 jne @f
  251.                         mov al,'F'
  252.                 @@:
  253.                 cmp ah,34 ;Ctrl+G
  254.                 jne @f
  255.                         mov al,'G'
  256.                 @@:
  257.                 cmp ah,35 ;Ctrl+H
  258.                 jne @f
  259.                         mov al,'H'
  260.                 @@:
  261.                 cmp ah,49 ;Ctrl+N
  262.                 jne @f
  263.                         mov al,'N'
  264.                 @@:
  265.                 or al,al
  266.                 jz .end0
  267.                         and eax,0xff
  268.                         test esi,KM_SHIFT
  269.                         jz @f
  270.                                 or eax,0x100
  271.                         @@:
  272.                         stdcall ted_fun_on_key_ctrl_all, eax
  273.                         jmp .end_key_fun
  274.                 .end0:
  275.  
  276.                 ; *** ¢ë§®¢ ¢­ãâ७­¨å ä㭪権
  277.                 cmp ah,30 ;Ctrl+A
  278.                 jne @f
  279.                         call ted_sel_all
  280.                 @@:
  281.                 cmp ah,44 ;Ctrl+Z
  282.                 jne @f
  283.                         stdcall ted_but_undo,edi
  284.                 @@:
  285.                 cmp ah,45 ;Ctrl+X
  286.                 jne @f
  287.                         stdcall ted_but_cut,edi
  288.                 @@:
  289.                 cmp ah,46 ;Ctrl+C
  290.                 jne @f
  291.                         stdcall ted_but_copy,edi
  292.                 @@:
  293.                 cmp ah,47 ;Ctrl+V
  294.                 jne @f
  295.                         stdcall ted_but_paste,edi
  296.                 @@:
  297.                 cmp ah,199 ;Ctrl+Home
  298.                 jne @f
  299.                         call ted_key_ctrl_home
  300.                 @@:
  301.                 cmp ah,207 ;Ctrl+End
  302.                 jne @f
  303.                         call ted_key_ctrl_end
  304.                 @@:
  305.                 jmp .end_key_fun
  306.         .key_Ctrl:
  307.  
  308.         test esi,KM_SHIFT ;Shift+...
  309.         jz .key_Shift
  310.                 cmp ah,72 ;Shift+Up
  311.                 jne @f
  312.                         call ted_sel_key_up
  313.                 @@:
  314.                 cmp ah,75 ;Shift+Left
  315.                 jne @f
  316.                         call ted_sel_key_left
  317.                 @@:
  318.                 cmp ah,77 ;Shift+Right
  319.                 jne @f
  320.                         call ted_sel_key_right
  321.                 @@:
  322.                 cmp ah,80 ;Shift+Down
  323.                 jne @f
  324.                         call ted_sel_key_down
  325.                 @@:
  326.                 ;mov ted_drag_k,1 ;­ ç¨­ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  327.                 jmp .key_MoveCur
  328.         .key_Shift:
  329. ;-------------------------------------------------
  330.         cmp ah,72 ;178 ;Up
  331.         jne @f
  332.                 call ted_draw_cursor_sumb
  333.                 call ted_cur_move_up
  334.                 cmp dl,8
  335.                 jne .no_red_0
  336.                         call ted_scroll_set_redraw
  337.                         stdcall ted_draw,edi
  338.                         jmp @f
  339.                 .no_red_0:
  340.                 call ted_draw_main_cursor
  341.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  342.         @@:
  343.         cmp ah,80 ;177 ;Down
  344.         jne @f
  345.                 call ted_draw_cursor_sumb
  346.                 call ted_cur_move_down
  347.                 cmp dl,8
  348.                 jne .no_red_1
  349.                         call ted_scroll_set_redraw
  350.                         stdcall ted_draw,edi
  351.                         jmp @f
  352.                 .no_red_1:
  353.                 call ted_draw_main_cursor
  354.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  355.         @@:
  356.         cmp ah,75 ;176 ;Left
  357.         jne @f
  358.                 call ted_draw_cursor_sumb
  359.                 call ted_cur_move_left
  360.                 cmp dl,8
  361.                 jne .no_red_2
  362.                         call ted_scroll_set_redraw
  363.                         stdcall ted_draw,edi
  364.                         jmp @f
  365.                 .no_red_2:
  366.                 call ted_draw_main_cursor
  367.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  368.         @@:
  369.         cmp ah,77 ;179 ;Right
  370.         jne @f
  371.                 call ted_draw_cursor_sumb
  372.                 call ted_cur_move_right
  373.                 cmp dl,8
  374.                 jne .no_red_3
  375.                         call ted_scroll_set_redraw
  376.                         stdcall ted_draw,edi
  377.                         jmp @f
  378.                 .no_red_3:
  379.                 call ted_draw_main_cursor
  380.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  381.         @@:
  382.         cmp ah,71 ;180 ;Home
  383.         jne @f
  384.                 call ted_draw_cursor_sumb
  385.                 call ted_cur_move_x_first_char
  386.                 cmp dl,8
  387.                 jne .no_red_4
  388.                         call ted_scroll_set_redraw
  389.                         stdcall ted_draw,edi
  390.                         jmp @f
  391.                 .no_red_4:
  392.                 call ted_draw_main_cursor
  393.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  394.         @@:
  395.         cmp ah,79 ;181 ;End
  396.         jne @f
  397.                 call ted_draw_cursor_sumb
  398.                 call ted_cur_move_x_last_char
  399.                 cmp dl,8
  400.                 jne .no_red_5
  401.                         call ted_scroll_set_redraw
  402.                         stdcall ted_draw,edi
  403.                         jmp @f
  404.                 .no_red_5:
  405.                 call ted_draw_main_cursor
  406.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  407.         @@:
  408.         cmp ah,73 ;184 ;PageUp
  409.         jne @f
  410.                 call ted_cur_move_page_up
  411.                 cmp dl,0
  412.                 je @f
  413.                 call ted_scroll_set_redraw
  414.                 stdcall ted_draw,edi
  415.         @@:
  416.         cmp ah,81 ;183 ;PageDown
  417.         jne @f
  418.                 call ted_cur_move_page_down
  419.                 cmp dl,0
  420.                 je @f
  421.                 call ted_scroll_set_redraw
  422.                 stdcall ted_draw,edi
  423.                 mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  424.         @@:
  425. ;-------------------------------------------------
  426.         .key_MoveCur:
  427.  
  428.         ;­¨¦¥ ¯à®¯ã᪠îâáï á«ã¦¥¡­ë¥ ª« ¢¨è¨, ª®â®àë¥ ¬®£ãâ ¤ ¢ âì ¬ãá®à­ë¥ ᨬ¢®«ë ¢ ®ª­®
  429.         cmp ah,42 ;[L Shift] ª®£¤  ­ ¦ â ¡¥§ ¤àã£¨å ª­®¯®ª
  430.         je .end_key_fun
  431.         cmp ah,54 ;[R Shift] ª®£¤  ­ ¦ â ¡¥§ ¤àã£¨å ª­®¯®ª
  432.         je .end_key_fun
  433.         cmp ah,58 ;[Caps Lock]
  434.         je .end_key_fun
  435.         cmp ah,69 ;[Pause Break]
  436.         je .end_key_fun
  437.         cmp ah,120 ;[Fn]
  438.         je .end_key_fun
  439.         cmp ah,0x80 ;if key up
  440.         ja .end_key_fun
  441.  
  442.         cmp dword[table],0
  443.         je @f
  444.                 stdcall KeyConvertToASCII, [table]
  445.         @@:
  446.  
  447.         ;mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  448.  
  449.         lea edx,[EvChar] ;¡¥à¥¬  ¤à¥á â ¡«¨æë á ¤®¯ãá⨬묨 ᨬ¢®« ¬¨
  450.         add dl,ah
  451.         jae @f
  452.                 add edx,0x100 ;¥á«¨ ¡ë«® ¯¥à¥¯®«­¥­¨¥ ¯à¨ ¤®¡ ¢«¥­¨¨ ª®¤  ᨬ¢®« 
  453.         @@:
  454.         cmp byte[edx],1
  455.         jne @f
  456.                 mov ted_key_new,ah
  457.                 call ted_set_undo
  458.                 mov edx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  459.                 stdcall ted_sel_text_del,edx
  460.                 cmp al,1
  461.                 jne .del
  462.                         mov edx,ted_opt_ed_move_cursor
  463.                 .del:
  464.                 cmp ted_cur_ins,1
  465.                 je .no_ins_mod
  466.                         stdcall ted_text_del,edi,ted_opt_ed_change_time
  467.                         mov edx,ted_opt_ed_move_cursor
  468.                 .no_ins_mod:
  469.                 mov ecx,edi
  470.                 add ecx,ted_offs_key_new
  471.                 stdcall ted_text_add,edi,ecx,1,edx ;¤®¡ ¢«ï¥¬ ᨬ¢®« ¢¢¥¤¥­­ë© á ª« ¢¨ âãàë
  472.                 cmp ted_key_new,13
  473.                 jne .dr_m_win
  474.                         ;¥á«¨ ¢áâ ¢¨«¨ ᨬ¢®« ­®¢®© áâப¨
  475.                         mov ecx,ted_scr_w
  476.                         inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
  477.                         mov edx,ted_cur_y
  478.                         cmp edx,[ecx+sb_offs_cur_area]
  479.                         jl .no_change
  480.                                 dec ted_cur_y ;ªãàá®à ®áâ ¢«ï¥¬ ­  ¬¥áâ¥
  481.                                 inc dword[ecx+sb_offs_position] ;ᤢ¨£ ¥¬ ¯®«§ã­®ª
  482.                         .no_change:
  483.                         stdcall ted_draw,edi
  484.                         jmp .dr_cur_l
  485.                 .dr_m_win:
  486.                         stdcall ted_draw_cur_line,edi
  487.                 .dr_cur_l:
  488.                 cmp ted_fun_draw_panel_buttons,0
  489.                 je @f
  490.                         call ted_fun_draw_panel_buttons
  491.         @@:
  492.  
  493.         cmp ah,8 ;[<-]
  494.         jne @f
  495.                 call ted_set_undo
  496.                 stdcall ted_sel_text_del,ted_opt_ed_change_time
  497.                 cmp al,1
  498.                 je .del_one_b
  499.                         stdcall ted_text_del,edi,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  500.                 .del_one_b:
  501.                 stdcall ted_draw,edi
  502.                 cmp ted_fun_draw_panel_buttons,0
  503.                 je .end_key_fun
  504.                         call ted_fun_draw_panel_buttons
  505.                 jmp .end_key_fun
  506. align 4
  507.         @@:
  508.  
  509.         cmp ah,182 ;Delete
  510.         jne @f
  511.                 call ted_set_undo
  512.                 stdcall ted_sel_text_del,ted_opt_ed_change_time
  513.                 cmp al,1
  514.                 je .del_one_d
  515.                         stdcall ted_text_del,edi,ted_opt_ed_change_time
  516.                 .del_one_d:
  517.                 stdcall ted_draw,edi
  518.                 cmp ted_fun_draw_panel_buttons,0
  519.                 je .end_key_fun
  520.                         call ted_fun_draw_panel_buttons
  521.                 jmp .end_key_fun
  522.         @@:
  523.  
  524.         cmp ah,185 ;Ins
  525.         jne @f
  526.                 call ted_draw_cursor_sumb
  527.                 xor ted_cur_ins,1
  528.                 call ted_draw_main_cursor
  529.         @@:
  530.  
  531.         .end_key_fun:
  532.         popad
  533.         ret
  534. endp
  535.  
  536. ;output:
  537. ; al = 1 - can save
  538. align 16
  539. proc ted_can_save uses ecx edi, edit:dword
  540.         mov edi,[edit]
  541.  
  542.         mov ecx,ted_tim_ch
  543.         sub ecx,ted_tim_undo
  544.         mov al,1
  545.         cmp ted_tim_ls,ecx
  546.         jne @f
  547.                 dec al
  548.         @@:
  549.         ret
  550. endp
  551.  
  552. ;input:
  553. ; edi = pointer to tedit struct
  554. ;output:
  555. ; al = 1 - selected
  556. align 16
  557. proc ted_is_select uses ebx
  558.         xor al,al
  559.         cmp ted_drag_m,1
  560.         je @f
  561.                 inc al
  562.                 mov ebx,ted_sel_x0
  563.                 cmp ebx,ted_sel_x1
  564.                 jne @f
  565.                 mov ebx,ted_sel_y0
  566.                 cmp ebx,ted_sel_y1
  567.                 jne @f
  568.                 xor al,al
  569.         @@:
  570.         ret
  571. endp
  572.  
  573. ;input:
  574. ; edi = pointer to tedit struct
  575. align 16
  576. proc ted_sel_normalize uses ecx esi
  577.         push edi
  578.                 mov esi,edi
  579.                 add esi,ted_offs_sel
  580.                 add edi,ted_offs_seln
  581.                 mov ecx,sizeof.TexSelect/4
  582.                 rep movsd
  583.         pop edi
  584.  
  585.         jmp @f
  586.                 .swp_f:
  587.                 mov ecx,ted_seln_x0
  588.                 m2m ted_seln_x0,ted_seln_x1
  589.                 mov ted_seln_x1,ecx
  590.  
  591.                 mov ecx,ted_seln_y0
  592.                 cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
  593.                 jle .end_f
  594.                 m2m ted_seln_y0,ted_seln_y1
  595.                 mov ted_seln_y1,ecx
  596.  
  597.                 jmp .end_f
  598. align 4
  599.         @@:
  600.  
  601.         mov ecx,ted_seln_y0
  602.         cmp ecx,ted_seln_y1 ;(sel_y0>sel_y1)
  603.         jg .swp_f
  604.  
  605.         cmp ecx,ted_seln_y1 ;(sel_y0==sel_y1)
  606.         jne .end_f
  607.                 mov ecx,ted_seln_x0
  608.                 cmp ecx,ted_seln_x1 ;(sel_x0>sel_x1)
  609.                 jg .swp_f
  610.  
  611.         .end_f:
  612.         ret
  613. endp
  614.  
  615. ;input:
  616. ; edi = pointer to tedit struct
  617. ;description:
  618. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ­ ç «¥ ¢ë¤¥«¥­¨ï
  619. align 16
  620. proc ted_sel_start uses eax ecx
  621.         mov eax,ted_scr_h
  622.         mov ecx,ted_cur_x
  623.         add ecx,[eax+sb_offs_position]
  624.         mov ted_sel_x0,ecx
  625.         mov ted_sel_x1,ecx
  626.  
  627.         mov eax,ted_scr_w
  628.         mov ecx,ted_cur_y
  629.         add ecx,[eax+sb_offs_position]
  630.         mov ted_sel_y0,ecx
  631.         mov ted_sel_y1,ecx
  632.         ret
  633. endp
  634.  
  635. ;input:
  636. ; edi = pointer to tedit struct
  637. ;description:
  638. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¯¥à¥¬¥é¥­¨¨ ¢ë¤¥«¥­¨ï
  639. align 16
  640. proc ted_sel_move
  641.         push eax ecx
  642.                 mov ecx,ted_cur_x
  643.                 mov eax,ted_scr_h
  644.                 add ecx,[eax+sb_offs_position]
  645.                 mov ted_sel_x1,ecx
  646.  
  647.                 mov eax,ted_scr_w
  648.                 mov ecx,ted_cur_y
  649.                 add ecx,[eax+sb_offs_position]
  650.                 mov ted_sel_y1,ecx
  651.         pop ecx eax
  652.         cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
  653.         je @f
  654.                 call ted_fun_draw_panel_buttons
  655.         @@:
  656.         ret
  657. endp
  658.  
  659. ;input:
  660. ; edi = pointer to tedit struct
  661. ;description:
  662. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥¬ ï ¯à¨ ¢ë¤¥«¥­¨¨ ¢á¥£® ¤®ªã¬¥­â 
  663. align 16
  664. proc ted_sel_all
  665.         push eax
  666.                 xor eax,eax
  667.                 mov ted_sel_x0,eax
  668.                 mov ted_sel_y0,eax
  669.  
  670.                 mov ted_sel_x1,eax ;???
  671.                 call ted_get_num_lines
  672.                 mov ted_sel_y1,eax
  673.         pop eax
  674.         stdcall ted_draw,edi
  675.         cmp ted_fun_draw_panel_buttons,0 ;redraw toolbar (need to button Copy)
  676.         je @f
  677.                 call ted_fun_draw_panel_buttons
  678.         @@:
  679.         ret
  680. endp
  681.  
  682. ;input:
  683. ; cl_al_mem = 1 - clear all memory
  684. align 16
  685. proc ted_clear uses ecx edi, edit:dword, cl_al_mem:dword
  686.         mov edi,[edit]
  687.  
  688.         mov ted_cur_x,0
  689.         mov ted_cur_y,0
  690.         mov ted_tim_ch,0
  691.         mov ted_tim_ls,0
  692.         mov ted_tim_co,0
  693.         mov ted_tim_undo,0
  694.         mov ted_help_id,-1
  695.         mov ecx,sizeof.symbol
  696.         shl ecx,1
  697.         add ecx,ted_tex
  698.         mov ted_ptr_free_symb,ecx
  699.  
  700.         mov ecx,ted_scr_w
  701.         mov dword[ecx+sb_offs_position],0
  702.         mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® áâப ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
  703.         mov dword[ecx+sb_offs_redraw],1
  704.         mov ecx,ted_scr_h
  705.         mov dword[ecx+sb_offs_position],0
  706.         mov dword[ecx+sb_offs_max_area],100 ;ç¨á«® ᨬ¢®«®¢ ¢¨¤¨¬ëå ¢ ­®¢®¬ ¤®ªã¬¥­â¥
  707.  
  708.         mov ted_sel_x0,0
  709.         mov ted_sel_y0,0
  710.         mov ted_sel_x1,0
  711.         mov ted_sel_y1,0
  712.  
  713.         cmp dword[cl_al_mem],0
  714.         je .exit
  715.  
  716.         push edx
  717.         mov ecx,sizeof.symbol
  718.         imul ecx,ted_max_chars
  719.         mov edx,ted_tex
  720.         @@:
  721.                 mov byte [edx],0
  722.                 inc edx
  723.         loop @b
  724.         mov edx,ted_tex
  725.         mov dword [edx+symbol.next],1
  726.         pop edx
  727.  
  728.         .exit:
  729.         ret
  730. endp
  731.  
  732.  
  733. align 16
  734. proc ted_init_syntax_file, edit:dword
  735.         pushad
  736.         mov edi,[edit]
  737.  
  738.         mov ecx,0x100
  739.         mov edx,ted_arr_key_pos
  740.         @@:
  741.                 mov dword[edx],-1
  742.                 add edx,4
  743.         loop @b
  744.  
  745.         ;init: ted_colors_text_count, ted_key_words_count, ...
  746.         mov ted_colors_text_count,1
  747.         mov ted_key_words_count,0
  748.         mov ted_help_text_f1,0
  749.         mov ted_help_id,-1 ;¨¤¥­â¨ä¨ª â®à á«®¢  ¤«ï á¯à ¢ª¨
  750.  
  751.         mov eax,edi ;á®å࠭塞 §­ ç¥­¨¥ edi
  752.         mov esi,ted_syntax_file
  753.         add edi,ted_offs_count_colors
  754.         mov ecx,9
  755.         rep movsd
  756.         mov edi,eax ;¢®áâ ­ ¢«¨¢ ¥¬ §­ ç¥­¨¥ edi
  757.  
  758.         mov eax,ted_syntax_file
  759.         add eax,32
  760.         mov ted_text_colors,eax
  761.  
  762.         mov eax,ted_colors_text_count ;init: count_colors_text (offset to key words)
  763.         lea eax,[4*eax+32]
  764.         add eax,ted_syntax_file
  765.         mov ted_key_words_data,eax
  766.  
  767.         mov ecx,ted_key_words_count ;init: ted_arr_key_pos (first key positions)
  768.         xor eax,eax
  769.         @@:
  770.                 ColToIndexOffset eax,edx
  771.                 movzx ebx,byte[edx]
  772.                 mov esi,ted_arr_key_pos
  773.                 lea esi,[esi+4*ebx]
  774.                 cmp dword[esi],-1
  775.                 jne .no_ch_key
  776.                         mov [esi],eax
  777.                 .no_ch_key:
  778.                 inc eax
  779.         loop @b
  780.  
  781.         ;init: ted_help_text_f1
  782.         mov ecx,ted_key_words_count ;ª®«¨ç¥á⢮ ª«î祢ëå á«®¢
  783.         imul ecx,sizeof.TexColViv   ;à §¬¥à áâàãªâãàë á 1-¬ ª«. á«.
  784.         add ecx,ted_key_words_data  ;­ ç «® ä ©«  á ª«. á«.
  785.         mov ted_help_text_f1,ecx    ;¬¥âª  ¢ ¯ ¬ïâ¨, £¤¥ ­ ç¨­¥âáï ⥪áâ á® á¯à ¢ª®©
  786.  
  787.         stdcall ted_init_scroll_bars,edi,1 ;¬¥­ï¥¬ æ¢¥â  áªà®««¨­£®¢
  788.         .no_colors:
  789.         popad
  790.         ret
  791. endp
  792.  
  793. ;input:
  794. ; ebx = file size
  795. ; edi = pointer to tedit struct
  796. ;description:
  797. ; ”ã­ªæ¨ï ¢ë§ë¢ ¥âáï ¯à¨ ®âªàë⨨ ä ©« 
  798. align 16
  799. proc ted_on_open_file
  800.         push eax ;destination
  801.         push ecx ;for cycle
  802.         push edx ;source
  803.         push esi
  804.  
  805.         stdcall ted_clear,edi,0 ;ç¨á⨬ ­¥ ¢áî ¯ ¬ïâì, ¯®â®¬ã çâ® ­¨¦¥ ¡ã¤¥¬ ¥¥ § ¯®«­ïâì ­®¢ë¬¨ ¤ ­ë¬¨
  806.  
  807.         ;ª®£¤  ᨬ¢®« § ¢¥à襭¨ï áâப¨ ⮫쪮 10 (¡¥§ 13)
  808.         mov edx,ted_tex
  809.         mov ecx,ebx
  810.         @@:
  811.                 cmp byte[edx],13
  812.                 je .no_10 ;¥á«¨ ­ ©¤¥­ ᨬ¢®« 13, â® 10-¥ ¨£­®à¨à㥬
  813.                 inc edx
  814.                 loop @b
  815.         mov edx,ted_tex
  816.         mov ecx,ebx
  817.         .s_10:
  818.                 cmp byte[edx],10
  819.                 jne @f
  820.                         mov byte[edx],13 ;¬¥­ï¥¬ 10-© ᨬ¢®« ª®­æ  áâப¨
  821.                 @@:
  822.                 inc edx
  823.                 loop .s_10
  824.         .no_10:
  825.  
  826.         ;¯¥à¥¢®¤¨¬ ®âªàëâë© ä ©« ¢­ãâàì í«¥¬¥­â  t_edit
  827.         mov eax,ebx
  828.         mov ecx,ebx
  829.         add eax,2
  830.         ConvertIndexToPointer eax
  831.         mov edx,ted_tex
  832.         add edx,ebx
  833.         push ebx
  834.         @@:
  835.                 mov ebx,[edx]
  836.                 mov byte[eax],bl
  837.                 mov dword[eax+symbol.perv],ecx
  838.                 inc dword[eax+symbol.perv]
  839.                 mov dword[eax+symbol.next],ecx
  840.                 add dword[eax+symbol.next],3
  841.                 ;mov byte[eax+1],0 ;col=0
  842.                 mov dword[eax+symbol.tc],-1
  843.                 mov dword[eax+symbol.td],0
  844.  
  845.                 cmp ecx,0
  846.                 je @f
  847.                 dec ecx
  848.                 dec edx
  849.                 sub eax,sizeof.symbol
  850.                 jmp @b
  851.         @@:
  852.         pop ebx
  853.         mov dword[eax+symbol.perv],0 ; first sumbol 'perv=0'
  854.  
  855.         mov edx,ted_tex ; ­ áâனª¨ ­ ç «ì­®£® á«ã¦¥¡­®£® ᨬ¢®« 
  856.         ; begining sumbol 'perv=0' 'next=2'
  857.         mov dword[edx+symbol.perv],0
  858.         mov dword[edx+symbol.next],2
  859.  
  860.         add edx,sizeof.symbol ; ­ áâனª¨ ª®­¥ç­®£® á«ã¦¥¡­®£® ᨬ¢®« 
  861.         mov dword[edx+symbol.next],0 ; last sumbol 'next=0'
  862.         mov dword[edx+symbol.perv],ebx ; last sumbol 'perv=last'
  863.         inc dword[edx+symbol.perv]
  864.         mov dword[edx+symbol.tc],0 ; áâ ¢¨¬ ¢à¥¬ï á®§¤ ­¨ï à ¢­®¥ 0, çâ® ¡ë ᨬ¢®« ¯à ¢¨«ì­® ®¡à ¡ â뢠«áï ¯à¨ ®âªàë⨨ ä ©«®¢ ¡®«ìè¨å 28 ¡ ©â
  865.  
  866.         mov edx,ebx
  867.         inc edx ;2 = rezerv sumbols
  868.         imul edx,sizeof.symbol
  869.         add edx,ted_tex
  870.         mov dword[edx+symbol.next],1 ; last sumbol 'next=1'
  871.  
  872.         @@: ;clear memory, need if before was open big file
  873.                 add edx,sizeof.symbol
  874.                 cmp edx,ted_tex_end
  875.                 jge @f
  876.                         mov dword[edx+symbol.tc],0
  877.                         mov dword[edx+symbol.td],0
  878.                 jmp @b
  879.         @@:
  880.  
  881.         call ted_get_num_lines
  882.         cmp eax,TED_LINES_IN_NEW_FILE
  883.         jge @f
  884.                 mov eax,TED_LINES_IN_NEW_FILE
  885.         @@:
  886.         mov esi,ted_scr_w
  887.         mov dword[esi+sb_offs_max_area],eax
  888.         pop esi edx ecx eax
  889.  
  890.         call ted_text_colored
  891.         stdcall ted_draw,edi
  892.         cmp ted_fun_draw_panel_buttons,0
  893.         je @f
  894.                 call ted_fun_draw_panel_buttons
  895.         @@:
  896.         ret
  897. endp
  898.  
  899. ;input:
  900. ; edx = pointer to symbol struct
  901. ; edi = pointer to tedit struct
  902. ;output:
  903. ; edx = pointer to 'perv' visible symbol struct
  904. align 16
  905. ted_iterat_perv:
  906.         cmp ted_tim_undo,0
  907.         je .else
  908.         push ebx
  909.         @@:
  910.                 mov edx,[edx+symbol.perv]
  911.                 or edx,edx
  912.                 jz @f
  913.                 imul edx,sizeof.symbol
  914.                 add edx,ted_tex
  915.                 call ted_symbol_not_vis
  916.                 cmp bl,1
  917.                 je @b
  918.                 cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  919.                 je @b
  920.         pop ebx
  921.         ret
  922.         @@:
  923.         mov edx,ted_tex ;­ ç «® ä ©« 
  924.         pop ebx
  925.         ret
  926.         .else:
  927.                 mov edx,[edx+symbol.perv]
  928.                 or edx,edx
  929.                 jz @f
  930.                 imul edx,sizeof.symbol
  931.                 add edx,ted_tex
  932.                 cmp dword[edx+symbol.td],0
  933.                 jne .else
  934.                 cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  935.                 je .else
  936.         ret
  937.         @@:
  938.         mov edx,ted_tex ;­ ç «® ä ©« 
  939.         ret
  940.  
  941.  
  942. ;input:
  943. ; edx = pointer to symbol struct
  944. ; edi = pointer to tedit struct
  945. ;output:
  946. ; edx = pointer to 'next' visible symbol struct
  947. align 16
  948. ted_iterat_next:
  949.         cmp ted_tim_undo,0
  950.         je .else
  951.         push ebx
  952.         @@:
  953.                 mov edx,[edx+symbol.next]
  954.                 cmp edx,1
  955.                 jle @f
  956.                 imul edx,sizeof.symbol
  957.                 add edx,ted_tex
  958.  
  959.                 call ted_symbol_not_vis
  960.                 cmp bl,1
  961.                 je @b
  962.                 cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  963.                 je @b
  964.         pop ebx
  965.         ret
  966.         @@:
  967.         mov edx,ted_tex_1 ;ª®­¥æ ä ©« 
  968.         pop ebx
  969.         ret
  970.         .else:
  971.                 mov edx,[edx+symbol.next]
  972.                 cmp edx,1
  973.                 jle @f
  974.                 imul edx,sizeof.symbol
  975.                 add edx,ted_tex
  976.  
  977.                 cmp dword[edx+symbol.td],0
  978.                 jne .else
  979.                 cmp byte[edx],10 ;¯à®¯ã᪠ᨬ¢®«  á ª®¤®¬ 10
  980.                 je .else
  981.         ret
  982.         @@:
  983.         mov edx,ted_tex_1 ;ª®­¥æ ä ©« 
  984.         ret
  985.  
  986. ;input:
  987. ; bl = symbol end of select
  988. ; bh = íªà ­¨àãî騩 ᨬ¢®« (= 0 ¥á«¨ ­¥â ¯à®¢¥àª¨ ­  ­¨å)
  989. ; edx = pointer to symbol struct
  990. ; edi = pointer to tedit struct
  991. ;description:
  992. ; ­ ©â¨ á«¥¤ãîéãî ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
  993. align 16
  994. ted_iterat_next_pos_char:
  995.         push ax
  996.         mov al,1 ;¯à¥¤ë¤ã騩 ᨬ¢®«, á«ã¦¨â ¤«ï áà ¢­¥­¨ï á ᨬ¢®«®¬ bh
  997.         @@:
  998.                 cmp bl,byte[edx]
  999.                 je .found
  1000.                 .no_found:
  1001.                 cmp edx,ted_tex_1
  1002.                 jle @f
  1003.                         mov al,byte[edx]
  1004.                         call ted_iterat_next
  1005.                         jmp @b
  1006.         .found:
  1007.                 cmp bh,al
  1008.                 je .no_found
  1009.         @@:
  1010.         call ted_iterat_next
  1011.         pop ax
  1012.         ret
  1013.  
  1014. ;input:
  1015. ; edx = pointer to symbol struct
  1016. ; edi = pointer to tedit struct
  1017. align 16
  1018. ted_iterat_perv_color_tag:
  1019.         @@:
  1020.                 cmp byte[edx+1],0
  1021.                 jne @f
  1022.                 call ted_iterat_perv
  1023.                 cmp edx,ted_tex_1
  1024.                 jle @f
  1025.                 jmp @b
  1026. align 4
  1027.         @@:
  1028.         ret
  1029.  
  1030. ;input:
  1031. ; edx = pointer to symbol struct
  1032. ; edi = pointer to tedit struct
  1033. align 16
  1034. ted_iterat_next_color_tag:
  1035.         @@:
  1036.                 call ted_iterat_next
  1037.                 cmp byte[edx+1],0
  1038.                 jne @f
  1039.                 cmp edx,ted_tex_1
  1040.                 jle @f
  1041.                 jmp @b
  1042. align 4
  1043.         @@:
  1044.         ret
  1045.  
  1046. ;input:
  1047. ; edx = pointer to symbol struct
  1048. ; edi = pointer to tedit struct
  1049. ;output:
  1050. ; bl = 1 if sumbol not visible
  1051. ; (tex[i].td+ted_tim_undo<=ted_tim_ch && tex[i].td) || (tex[i].tc>ted_tim_ch-ted_tim_undo)
  1052. align 16
  1053. ted_symbol_not_vis:
  1054.         push eax
  1055.  
  1056.         xor bl,bl
  1057.         cmp dword[edx+symbol.td],0
  1058.         je @f
  1059.         mov eax,[edx+symbol.td] ;eax=tex[i].td
  1060.         add eax,ted_tim_undo
  1061.         cmp eax,ted_tim_ch
  1062.         jg @f
  1063.                 mov bl,1
  1064.                 pop eax
  1065.                 ret
  1066.         @@:
  1067.  
  1068.         mov eax,ted_tim_ch
  1069.         sub eax,ted_tim_undo
  1070.         cmp [edx+symbol.tc],eax
  1071.         jle @f
  1072.                 or bl,1
  1073.         @@:
  1074.  
  1075.         pop eax
  1076.         ret
  1077.  
  1078. ;input:
  1079. ; text - pointer to text string
  1080. ; add_opt - options
  1081. align 16
  1082. proc ted_text_add, edit:dword, text:dword, t_len:dword, add_opt:dword
  1083.         locals
  1084.                 new_spc dd ? ;count new spaces
  1085.                 new_lin dd ? ;count new lines
  1086.         endl
  1087. ;¨á¯®«ì§®¢ ­¨¥ ॣ¨áâ஢ ¢­ãâਠä㭪樨:
  1088. ;eax - ¯®§¨æ¨ï ¤«ï ¢áâ ¢ª¨ ⥪áâ 
  1089. ;ebx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤, ¤«¨­­  ¢áâ ¢«ï¥¬®£® ⥪áâ 
  1090. ;ecx - ¤«ï ¢à¥¬¥­­ëå ­ã¦¤
  1091. ;edx - 㪠§ â¥«ì ­  áâàãªâãàã ᨬ¢®« 
  1092.         pushad
  1093.         cmp dword[t_len],1 ;¯à®¢¥à塞 ¤«¨­­ã ¤®¡¢«ï¥¬®£® ⥪áâ 
  1094.         jl .no_add ;ª®£¤  ¤«¨­­  <1 ¯à룠¥¬ ­  ª®­¥æ ä㭪樨, ¢® ¨§¡¥¦ ­¨¥ £«îª®¢
  1095.  
  1096.         mov edi,[edit]
  1097.         mov esi,[text]
  1098.  
  1099.         call ted_get_pos_by_cursor
  1100.         call ted_get_text_perv_pos
  1101.         call ted_get_text_arr_index ;eax=po_t
  1102.  
  1103.         mov dword[new_spc],0
  1104.         cmp ted_gp_opt,2
  1105.         je @f
  1106.                 push eax ;c_sp=cur[cn].x+Scroller->XPos-StrLen(cur[cn].y+Scroller->YPos);
  1107.                         mov eax,ted_scr_h
  1108.                         mov eax,[eax+sb_offs_position]
  1109.                         add eax,ted_cur_x ;eax - ­®¬¥à ᨬ¢®« 
  1110.                         mov [new_spc],eax
  1111.  
  1112.                         mov eax,ted_scr_w
  1113.                         mov eax,[eax+sb_offs_position]
  1114.                         add eax,ted_cur_y ;eax - ­®¬¥à áâப¨
  1115.                         call ted_strlen ;ebx = line len
  1116.                         sub [new_spc],ebx ;®â ¯®§¨æ¨¨ ªãàá®à  ®â­¨¬ ¥¬ ¤«¨­­ã áâப¨, ã§­ ¥¬ ª®««¨ç¥á⢮ ¤®¡ ¢«ï¥¬ëå ¯à®¡¥«®¢
  1117.                 pop eax
  1118.         @@:
  1119.  
  1120.         mov ebx,[t_len]
  1121.  
  1122.         mov dword[new_lin],0
  1123.         cmp ted_gp_opt,0
  1124.         jne @f
  1125.                 push eax
  1126.                         mov eax,ted_scr_w
  1127.                         mov eax,[eax+sb_offs_position]
  1128.                         add eax,ted_cur_y
  1129.                         inc eax
  1130.                         mov [new_lin],eax
  1131.  
  1132.                         call ted_get_num_lines
  1133.                         sub [new_lin],eax
  1134.                         ;㢥«¨ç¨¢ ¥¬ «¨­¨¨ ¢ áªà®««¨­£¥ ­  ç¨á«® ¤®¡ ¢«¥­­ëå ¤®¯®«­¨â¥«ì­ëå áâப
  1135.                         mov ecx,ted_scr_w
  1136.                         add [ecx+sb_offs_max_area],eax ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
  1137.                 pop eax
  1138.         @@:
  1139.  
  1140.         mov edx,ted_ptr_free_symb
  1141.         .beg_cycle: ;for(i=...;i<ted_max_chars;i++)
  1142.                 cmp dword[edx+symbol.tc],0 ;if(!tex[i].tc && !tex[i].td)
  1143.                 jne .u1f
  1144.                 cmp dword[edx+symbol.td],0
  1145.                 jne .u1f
  1146.                         test dword[add_opt],ted_opt_ed_change_time ;if(n_tim) ted_tim_ch++;
  1147.                         jz .no_tim
  1148.                                 inc ted_tim_ch
  1149.                         .no_tim:
  1150.                         test dword[add_opt],ted_opt_ed_move_cursor
  1151.                         jz .no_cur_mov
  1152.                         cmp dword[new_lin],0 ;¥á«¨ ¥áâì ¤®¡ ¢®ç­ë¥ áâப¨, â® ªãàá®à ¥é¥ ­¥ ¤¢¨£ ¥¬
  1153.                         jg .no_cur_mov
  1154.                         cmp dword[new_spc],0 ;¥á«¨ ­¥â ¤®¡ ¢®ç­ëå ¯à®¡¥«®¢, â® ªãàá®à ⮦¥ ­¥ ¤¢¨£ ¥¬
  1155.                         jg .no_cur_mov
  1156.                                 inc ted_cur_x ;move cursor
  1157.                                 ;call ted_go_to_pos
  1158.                                 cmp byte[esi],13
  1159.                                 jne .no_cur_mov
  1160.                                         mov ted_cur_x,0
  1161.                                         inc ted_cur_y
  1162.                                         ;㢥«¨ç¨¢ ¥¬ «¨­¨¨ ¢ áªà®««¨­£¥ ­  ç¨á«® ¤®¡ ¢«¥­­ëå ¢ ⥪á⥠áâப
  1163.                                         mov ecx,ted_scr_w
  1164.                                         inc dword[ecx+sb_offs_max_area] ;㢥«¨ç¨¢ ¥¬ à §¬¥à ¢¥à⨪ «ì­®£® áªà®««¨­£ 
  1165.                         .no_cur_mov:
  1166.  
  1167.                         ; *** ¢áâ ¢ª  ⥪ã饣® ᨬ¢®«  ¨§ áâப¨ ***
  1168.                         mov ecx,ted_opt_ed_change_time
  1169.                         not ecx
  1170.                         and [add_opt],ecx ;n_tim=false;
  1171.  
  1172.                         mov cl,byte[esi] ;tex[i].c=ta[ns];
  1173.                         mov byte[edx],cl
  1174.                         m2m dword[edx+symbol.tc],ted_tim_ch ;tex[i].tc=ted_tim_ch;
  1175.                         mov [edx+symbol.perv],eax ;tex[i].perv=po_t;
  1176.  
  1177.                         mov ecx,eax
  1178.                         imul ecx,sizeof.symbol
  1179.                         add ecx,ted_tex ; *** ecx = tex[po_t] ***
  1180.                         add ecx,symbol.next ; *** ecx = tex[po_t].next ***
  1181.                         m2m dword[edx+symbol.next],dword[ecx] ;tex[i].next=tex[po_t].next;
  1182.  
  1183.                         call ted_get_text_arr_index ;*** eax = i ***
  1184.                         mov [ecx],eax ;tex[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
  1185.                         mov ecx,[edx+symbol.next] ; *** ecx = tex[i].next ***
  1186.                         imul ecx,sizeof.symbol
  1187.                         add ecx,ted_tex ; *** ecx = tex[tex[i].next] ***
  1188.                         mov [ecx+symbol.perv],eax ;tex[tex[i].next].perv=i;
  1189.  
  1190.                         ; *** ¢áâ ¢ª  ¤®¯®«­¨â¥«ì­ëå áâப ¨ ¯à®¡¥«®¢
  1191.                         ; ¥á«¨ ªãàá®à ¢® ¢à¥¬ï ¢áâ ¢ª¨ ­ å®¤¨«áï §  ⥪á⮬ ***
  1192.                         cmp dword[new_lin],0 ;add lines or text
  1193.                         jle .spc_add
  1194.                                 dec dword[new_lin]
  1195.                                 mov byte [edx],13
  1196.                                 jmp .u1f
  1197.                         .spc_add:
  1198.                         cmp dword[new_spc],0 ;add spaces or text
  1199.                         jle .tex_add
  1200.                                 dec dword[new_spc]
  1201.                                 mov byte [edx],' '
  1202.                                 jmp .u1f
  1203.                         .tex_add:
  1204.                         inc esi ; ¯¥à¥å®¤ ª á«¥¤ãî饬㠢áâ ¢«ï¥¬®¬ã ᨬ¢®«ã
  1205.                         dec ebx
  1206.                 .u1f:
  1207.                 add edx,sizeof.symbol
  1208.                 cmp edx,ted_tex_end
  1209.                 jge @f ;out of memory
  1210.                 cmp ebx,0
  1211.                 jne .beg_cycle
  1212.                 mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
  1213.                 jmp .add_all
  1214.         @@:
  1215.         cmp ted_increase_size,0
  1216.         je .add_all
  1217.                 call ted_memory_increase
  1218.                 cmp ebx,0
  1219.                 jne .beg_cycle
  1220.         .add_all: ;¢á¥ ᨬ¢®«ë ¤®¡ ¢«¥­ë
  1221.  
  1222.         call ted_text_colored
  1223.         .no_add:
  1224.         popad
  1225.         ret
  1226. endp
  1227.  
  1228. ;input:
  1229. ;  edx = pointer to sumbol, when insert
  1230. ;  edi = pointer to tedit struct
  1231. ;output:
  1232. ;  edx = new pointer to sumbol, when insert
  1233. align 16
  1234. proc ted_memory_increase
  1235.         cmp ted_increase_size,0
  1236.         je @f
  1237.                 push eax ebx ecx
  1238.                 mov ecx,ted_increase_size
  1239.                 add ecx,ted_max_chars
  1240.                 mov ted_max_chars,ecx
  1241.                 imul ecx,sizeof.symbol
  1242.                 invoke mem.realloc, ted_tex,ecx
  1243.                 mov ebx,ted_tex
  1244.                 mov ted_tex,eax
  1245.                 mov ted_tex_1,eax
  1246.                 add ted_tex_1,sizeof.symbol
  1247.                         sub edx,ebx
  1248.                         add edx,eax
  1249.                         mov ted_ptr_free_symb,edx
  1250.                 add eax,ecx
  1251.                 mov ted_tex_end,eax
  1252.                 pop ecx ebx eax
  1253.         @@:
  1254.         ret
  1255. endp
  1256.  
  1257. ;input:
  1258. ;  ecx = position to free insert cell
  1259. ;  edx = pointer to sumbol, when insert
  1260. ;  esi = added symbol
  1261. ;  edi = pointer to tedit struct
  1262. ;output:
  1263. ;  ecx = position to inserted cell
  1264. align 16
  1265. ted_char_add:
  1266.         .loop_b:
  1267.                 cmp ecx,ted_tex_end
  1268.                 jge .end_f
  1269.                 cmp dword[ecx+symbol.tc],0
  1270.                 jne @f
  1271.                         cmp dword[ecx+symbol.td],0
  1272.                         je .loop_e
  1273.                 @@:
  1274.                 add ecx,sizeof.symbol
  1275.                 jmp .loop_b
  1276. align 4
  1277.         .loop_e:
  1278.  
  1279.         push eax ebx
  1280.         mov eax,ted_tim_ch
  1281.         mov [ecx+symbol.tc],eax
  1282.         mov ax,si
  1283.         mov byte[ecx],al
  1284.  
  1285.         call ted_get_text_arr_index ; *** eax=pos ***
  1286.         mov [ecx+symbol.perv],eax ;tex[i].perv=pos;
  1287.         m2m dword[ecx+symbol.next],dword[edx+symbol.next] ;tex[i].next=tex[pos].next;
  1288.  
  1289.         push edx
  1290.                 mov edx,ecx
  1291.                 call ted_get_text_arr_index ; *** eax=i ***
  1292.         pop edx
  1293.  
  1294.         mov [edx+symbol.next],eax ;tex[pos].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
  1295.         mov ebx,[ecx+symbol.next]
  1296.         ConvertIndexToPointer ebx
  1297.         mov [ebx+symbol.perv],eax ;tex[tex[i].next].perv=i; // ...
  1298.         pop ebx eax
  1299.  
  1300.         .end_f:
  1301.         call ted_text_colored
  1302.         ret
  1303.  
  1304. ;description:
  1305. ; äã­ªæ¨ï ¤«ï ᬥ­ë ª®¤¨à®¢®ª
  1306. ;input:
  1307. ; table - â ¡«¨æ  ¤«ï ¯¥à¥ª®¤¨à®¢ª¨
  1308. align 16
  1309. proc ted_but_convert_by_table uses eax edx edi esi, edit:dword, table:dword
  1310.         mov edi,[edit]
  1311.         mov esi,[table]
  1312.         mov edx,ted_tex
  1313.         .cycle:
  1314.                 ;¯¥à¥å®¤¨¬ ­  á«¥¤ãî騩 ᨬ¢®«
  1315.                 mov edx,[edx+symbol.next]
  1316.                 cmp edx,1
  1317.                 jle .end_text
  1318.                 imul edx,sizeof.symbol
  1319.                 add edx,ted_tex
  1320.  
  1321.                 movzx eax,byte[edx]
  1322.                 add eax,esi
  1323.                 mov al,byte[eax]
  1324.                 cmp al,0
  1325.                 je @f
  1326.                         mov byte[edx],al ;¬¥­ï¥¬ ª®¤¨à®¢ªã ᨬ¢®« 
  1327.                 @@:
  1328.                 jmp .cycle
  1329.         .end_text:
  1330.         ;cmp esi,0
  1331.         ;je @f
  1332.                 stdcall ted_draw,edi ;®¡­®¢«ï¥¬ ®ª­®
  1333.         ;@@:
  1334.         ret
  1335. endp
  1336.  
  1337. ;input:
  1338. ; edi = pointer to tedit struct
  1339. ;output:
  1340. ; esi = count converted symbols
  1341. ;description:
  1342. ; ”ã­ªæ¨ï ¨á¯®«ì§ã¥âáï ¤«ï ᬥ­ë ॣ¨áâà  ¢ë¡à ­­ëå ᨬ¢®«®¢
  1343. align 16
  1344. proc ted_convert_sel_text, conv_fun:dword
  1345.         locals
  1346.                 conv_cou dd ?
  1347.         endl
  1348.         mov dword[conv_cou],0
  1349.         pushad
  1350.  
  1351.         call ted_is_select
  1352.         or al,al
  1353.         jz .end_f
  1354.                 call ted_set_undo
  1355.                 call ted_sel_normalize
  1356.  
  1357.                 mov esi,ted_seln_x0
  1358.                 mov ecx,ted_seln_y0
  1359.                 call ted_get_pos_by_coords
  1360.                 mov eax,edx
  1361.                 mov esi,ted_seln_x1
  1362.                 mov ecx,ted_seln_y1
  1363.                 call ted_get_pos_by_coords
  1364.                 ;call ted_get_text_perv_pos
  1365.                 mov ebx,edx
  1366.  
  1367.                 cmp eax,ebx
  1368.                 je .end_f
  1369.  
  1370.                 inc ted_tim_ch
  1371.                 mov edx,eax ;i=p0;
  1372.                 mov ecx,ted_ptr_free_symb
  1373.                 @@:
  1374.                 push eax
  1375.                 mov al,byte[edx]
  1376.                 call dword[conv_fun] ;¯à¥®¡à §®¢ ­¨¥ ᨬ¢®« 
  1377.                 mov esi,eax
  1378.                 cmp byte[edx],al
  1379.                 pop eax
  1380.                 je .no_change
  1381.                         m2m dword[edx+symbol.td],ted_tim_ch
  1382.                         call ted_char_add ;b_pos=ted_char_add(tex[i].c^32,i,false,b_pos);
  1383.                         call ted_get_text_next_pos ;go to added symbol
  1384.                         inc dword[conv_cou]
  1385.                 .no_change:
  1386.  
  1387.                 call ted_iterat_next
  1388.                 cmp edx,ted_tex
  1389.                 je @f
  1390.                 cmp edx,ebx
  1391.                 jne @b
  1392.                 @@:
  1393.                 cmp dword[conv_cou],0
  1394.                 jne @f
  1395.                         dec ted_tim_ch
  1396.                 @@:
  1397.         .end_f:
  1398.         popad
  1399.         mov esi,dword[conv_cou]
  1400.         ret
  1401. endp
  1402.  
  1403. ;output:
  1404. ; bl = 0 - no delete
  1405. ; bl = 1 - delete
  1406. align 16
  1407. proc ted_text_del uses ecx edx edi, edit:dword, del_opt:dword
  1408.         mov edi,[edit]
  1409.         mov ebx,[del_opt]
  1410.  
  1411.         xor cl,cl
  1412.         test ebx,ted_opt_ed_move_cursor
  1413.         jz @f
  1414.                 call ted_cur_move_left
  1415.                 cmp dl,0
  1416.                 je .no_del
  1417.         @@:
  1418.         call ted_get_pos_by_cursor
  1419.         cmp ted_gp_opt,1
  1420.         je .no_del
  1421.                 test ebx,ted_opt_ed_change_time
  1422.                 jz @f
  1423.                         inc ted_tim_ch
  1424.                 @@:
  1425.                 m2m dword[edx+symbol.td], ted_tim_ch
  1426.                 mov cl,1
  1427.         .no_del:
  1428.         mov bl,cl
  1429.         ret
  1430. endp
  1431.  
  1432. ;input:
  1433. ; edi = pointer to tedit struct
  1434. ;output:
  1435. ; al = 1 if delete
  1436. ;description:
  1437. ; ”ã­ªæ¨ï 㤠«ï¥â ¢ë¤¥«¥­­ë© ⥪áâ
  1438. align 16
  1439. proc ted_sel_text_del uses ebx ecx edx esi, del_opt:dword
  1440.         call ted_is_select
  1441.         or al,al
  1442.         jz .end_f
  1443.                 call ted_sel_normalize
  1444.  
  1445.                 mov esi,ted_seln_x1
  1446.                 mov ecx,ted_seln_y1
  1447.                 call ted_get_pos_by_coords
  1448.                 mov ebx,edx
  1449.  
  1450.                 mov esi,ted_seln_x0
  1451.                 mov ecx,ted_seln_y0
  1452.                 call ted_get_pos_by_coords
  1453.  
  1454.                 test dword[del_opt],ted_opt_ed_change_time
  1455.                 jz @f
  1456.                         inc ted_tim_ch
  1457.                 @@:
  1458.                 cmp edx,ted_tex
  1459.                 je @f
  1460.                 cmp edx,ebx ;if(i==te)break;
  1461.                 je @f
  1462.                         m2m dword[edx+symbol.td],ted_tim_ch
  1463.                         mov esi,ted_opt_ed_change_time
  1464.                         not esi
  1465.                         and dword[del_opt],esi ;n_tim=false;
  1466.                         call ted_iterat_next
  1467.                         jmp @b
  1468. align 4
  1469.                 @@:
  1470.                 test dword[del_opt],ted_opt_ed_change_time
  1471.                 jz @f
  1472.                         dec ted_tim_ch
  1473.                         xor al,al
  1474.                 @@:
  1475.                 test dword[del_opt],ted_opt_ed_change_time
  1476.                 jnz @f
  1477.                         mov ecx,ted_seln_x0
  1478.                         mov edx,ted_seln_y0
  1479.                         call ted_go_to_pos
  1480.                         mov ted_sel_x0,0
  1481.                         mov ted_sel_y0,0
  1482.                         mov ted_sel_x1,0
  1483.                         mov ted_sel_y1,0
  1484.                 @@:
  1485.         .end_f:
  1486.         ret
  1487. endp
  1488.  
  1489.  
  1490. ;input:
  1491. ; eax = pointer to begin select
  1492. ; ebx = pointer to end select
  1493. ; edi = pointer to tedit struct
  1494. align 16
  1495. ted_revers:
  1496.         cmp eax,ebx
  1497.         jne @f
  1498.                 ret
  1499.         @@:
  1500.  
  1501.         push ecx edx
  1502.  
  1503.         mov edx,ted_tex_1
  1504.         cmp edx,ebx ;if(p1==1)p1=tex[1].perv;
  1505.         jne @f
  1506.                 call ted_get_text_perv_pos
  1507.                 mov ebx,edx
  1508.         @@:
  1509.  
  1510.         push esi
  1511.                 mov edx,[eax+symbol.perv] ; *** edx = tex[p0].perv ***
  1512.                 ConvertIndexToPointer edx
  1513.                 add edx,symbol.next
  1514.                 mov ecx,[edx] ;ecx = tex[tex[p0].perv].next
  1515.  
  1516.                 mov esi,[ebx+symbol.next] ; *** esi = tex[p1].next ***
  1517.                 ConvertIndexToPointer esi
  1518.                 add esi,symbol.perv
  1519.                 m2m dword[edx],dword[esi] ;tex[tex[p0].perv].next = tex[tex[p1].next].perv
  1520.  
  1521.                 mov [esi],ecx ;tex[tex[p1].next].perv = ecx
  1522.         pop esi
  1523.  
  1524.         mov ecx,[eax+symbol.perv] ;ecx = tex[p0].perv
  1525.         m2m dword[eax+symbol.perv],dword[ebx+symbol.next] ;tex[p0].perv = tex[p1].next
  1526.         mov [ebx+symbol.next],ecx ;tex[p1].next = ecx
  1527.  
  1528.         mov edx,eax ;i=p0;
  1529.         @@:
  1530.                 mov ecx,[edx+symbol.next] ;ecx = tex[i].next
  1531.                 m2m dword[edx+symbol.next],dword[edx+symbol.perv] ;tex[i].next = tex[i].perv
  1532.                 mov [edx+symbol.perv],ecx ;tex[i].perv = ecx
  1533.                 cmp edx,ebx ;if(i==p1)break;
  1534.                 je @f
  1535. ; ---
  1536. ;cmp edx,ted_tex
  1537. ;je @f
  1538. ; ---
  1539.                 mov edx,ecx ;i = ecx
  1540.                 ConvertIndexToPointer edx
  1541.                 jmp @b
  1542.         @@:
  1543.         pop edx ecx
  1544.         call ted_text_colored
  1545.         ret
  1546.  
  1547.  
  1548. ;input:
  1549. ; edi = pointer to tedit struct
  1550. ;output:
  1551. ; dl = 0 not move
  1552. ; dl = 2 if move up
  1553. ; dl = 8 if scroll move up
  1554. align 16
  1555. ted_cur_move_up:
  1556.   cmp ted_cur_y,0
  1557.   je @f
  1558.     dec ted_cur_y
  1559.     mov dl,2
  1560.     ret
  1561.   @@:
  1562.   push eax
  1563.   mov eax,ted_scr_w
  1564.   cmp dword[eax+sb_offs_position],0
  1565.   je @f
  1566.     dec dword[eax+sb_offs_position]
  1567.     mov dl,8
  1568.     jmp .ret_f
  1569.   @@:
  1570.   mov dl,0
  1571.   .ret_f:
  1572.   pop eax
  1573.   ret
  1574.  
  1575. ;input:
  1576. ; edi = pointer to tedit struct
  1577. ;output:
  1578. ; dl = 0 not move
  1579. ; dl = 2 if move down
  1580. ; dl = 8 if scroll move down
  1581. align 16
  1582. ted_cur_move_down:
  1583.   push eax ebx
  1584.   mov ebx,ted_scr_w
  1585.   xor dl,dl
  1586.   mov eax,[ebx+sb_offs_cur_area]
  1587.   dec eax
  1588.   cmp ted_cur_y,eax
  1589.   jge @f
  1590.     inc ted_cur_y
  1591.     mov dl,2
  1592.     jmp .ret_f
  1593.   @@:
  1594.   mov eax,ted_cur_y
  1595.   add eax,[ebx+sb_offs_position]
  1596.   inc eax
  1597.   cmp [ebx+sb_offs_max_area],eax
  1598.   jle @f
  1599.     inc dword[ebx+sb_offs_position]
  1600.     mov dl,8
  1601.   @@:
  1602.   .ret_f:
  1603.   pop ebx eax
  1604.   ret
  1605.  
  1606.  
  1607. ;input:
  1608. ; edi = pointer to tedit struct
  1609. ;output:
  1610. ; dl = 0 not move
  1611. ; dl = 1 if move up
  1612. align 16
  1613. ted_cur_move_page_up:
  1614.         push eax ebx
  1615.         mov ebx,ted_scr_w
  1616.         mov eax,[ebx+sb_offs_cur_area]
  1617.         xor dl,dl
  1618.         cmp eax,[ebx+sb_offs_position]
  1619.         jg @f
  1620.                 sub [ebx+sb_offs_position],eax
  1621.                 mov dl,1
  1622.         @@:
  1623.         cmp dword[ebx+sb_offs_position],0
  1624.         je @f
  1625.         cmp dl,1
  1626.         je @f
  1627.                 mov dword[ebx+sb_offs_position],0
  1628.                 mov dl,1
  1629.         @@:
  1630.         pop ebx eax
  1631.         ret
  1632.  
  1633. ;input:
  1634. ; edi = pointer to tedit struct
  1635. align 16
  1636. ted_cur_move_page_down:
  1637.         push eax ebx ecx
  1638.         mov ecx,ted_scr_w
  1639.  
  1640.         xor dl,dl
  1641.         mov eax,[ecx+sb_offs_max_area]
  1642.         sub eax,[ecx+sb_offs_cur_area]
  1643.         cmp [ecx+sb_offs_position],eax
  1644.         jge @f
  1645.                 mov ebx,[ecx+sb_offs_cur_area]
  1646.                 add [ecx+sb_offs_position],ebx
  1647.                 mov dl,1
  1648.                 mov dword[ecx+sb_offs_redraw],1
  1649.                 cmp [ecx+sb_offs_position],eax
  1650.                 jle @f
  1651.                         mov [ecx+sb_offs_position],eax
  1652.         @@:
  1653.         pop ecx ebx eax
  1654.         ret
  1655.  
  1656. ;input:
  1657. ; edi = pointer to tedit struct
  1658. ;output:
  1659. ; dl = 0 not move
  1660. ; dl = 1 if move left
  1661. ; dl = 3 if move left and up
  1662. ; dl = 8 if scroll move up
  1663. align 16
  1664. ted_cur_move_left:
  1665.         cmp ted_cur_x,0
  1666.         je @f
  1667.                 dec ted_cur_x
  1668.                 mov dl,1
  1669.                 ret
  1670.         @@:
  1671.         push eax
  1672.         mov eax,ted_scr_h
  1673.         cmp dword[eax+sb_offs_position],0
  1674.         je @f
  1675.                 dec dword[eax+sb_offs_position]
  1676.                 mov dl,8
  1677.                 jmp .ret_f
  1678.         @@:
  1679.         cmp ted_cur_y,0
  1680.         jne @f
  1681.                 mov eax,ted_scr_w
  1682.                 mov dl,0
  1683.                 cmp dword[eax+sb_offs_position],0
  1684.                 je .ret_f
  1685.                         dec dword[eax+sb_offs_position]
  1686.                         call ted_scroll_set_redraw
  1687.                         call ted_cur_move_x_last_char
  1688.                         mov dl,8
  1689.                         jmp .ret_f
  1690.         @@:
  1691.         cmp ted_cur_y,0
  1692.         je @f
  1693.                 dec ted_cur_y
  1694.                 call ted_cur_move_x_last_char
  1695.                 cmp dl,8
  1696.                 je .ret_f
  1697.                 mov dl,3
  1698.                 jmp .ret_f
  1699.         @@:
  1700.         mov dl,0
  1701.         .ret_f:
  1702.         pop eax
  1703.         ret
  1704.  
  1705. ;input:
  1706. ; edi = pointer to tedit struct
  1707. align 16
  1708. ted_cur_move_right:
  1709.         push eax ebx
  1710.         mov eax,ted_scr_h
  1711.         xor dl,dl
  1712.         mov ebx,[eax+sb_offs_cur_area]
  1713.         cmp ted_cur_x,ebx
  1714.         jge @f
  1715.                 inc ted_cur_x
  1716.                 mov dl,1
  1717.                 jmp .ret_f
  1718.         @@:
  1719.                 inc dword[eax+sb_offs_position]
  1720.                 mov dl,8
  1721.         .ret_f:
  1722.         pop ebx eax
  1723.         ret
  1724.  
  1725. ;input:
  1726. ; edi = pointer to tedit struct
  1727. align 16
  1728. ted_cur_move_x_last_char:
  1729. ;[hScr.position]
  1730. ;[hScr.cur_area]
  1731. ;dl-???
  1732.   push eax ebx ecx
  1733.   mov eax,ted_cur_y
  1734.   mov ecx,ted_scr_w
  1735.   add eax,[ecx+sb_offs_position]
  1736.   call ted_strlen
  1737.   xor dl,dl
  1738.  
  1739.   mov ecx,ted_scr_h
  1740.   cmp ebx,[ecx+sb_offs_position]
  1741.   jge @f
  1742.     mov dl,8
  1743.     mov [ecx+sb_offs_position],ebx
  1744.   @@:
  1745.   sub ebx,[ecx+sb_offs_position]
  1746.  
  1747.   cmp ebx,[ecx+sb_offs_cur_area]
  1748.   jle @f ; b---[---]---e
  1749.     add [ecx+sb_offs_position],ebx
  1750.     mov ebx,[ecx+sb_offs_cur_area]
  1751.     sub [ecx+sb_offs_position],ebx
  1752.     mov dl,8
  1753.   @@:
  1754.   mov ted_cur_x,ebx
  1755.   pop ecx ebx eax
  1756.   ret
  1757.  
  1758. ;input:
  1759. ; edi = pointer to tedit struct
  1760. ;output:
  1761. ; dl = 0 not move
  1762. ; dl = 1 move cursor
  1763. ; dl = 8 move cursor and scroll
  1764. align 16
  1765. ted_cur_move_x_first_char:
  1766.         xor dl,dl
  1767.         cmp ted_cur_x,0
  1768.         je @f
  1769.                 mov ted_cur_x,0
  1770.                 mov dl,1
  1771.         @@:
  1772.         push eax
  1773.         mov eax,ted_scr_h
  1774.         cmp dword[eax+sb_offs_position],0
  1775.         je @f
  1776.                 mov dword[eax+sb_offs_position],0
  1777.                 mov dl,8
  1778.         @@:
  1779.         pop eax
  1780.         ret
  1781.  
  1782. ;input:
  1783. ; edx = pointer to symbol struct
  1784. ; edi = pointer to tedit struct
  1785. ;output:
  1786. ; eax = array index
  1787. align 16
  1788. ted_get_text_arr_index:
  1789.         push ecx edx
  1790.                 mov eax,edx
  1791.                 sub eax,ted_tex
  1792.                 xor edx,edx
  1793.                 mov ecx,sizeof.symbol
  1794.                 div ecx
  1795.         pop edx ecx
  1796.         ret
  1797.  
  1798. ;input:
  1799. ; edx = pointer to symbol struct
  1800. ; edi = pointer to tedit struct
  1801. ;output:
  1802. ; edx = pointer to 'perv' struct
  1803. align 16
  1804. ted_get_text_perv_pos:
  1805.         mov edx,[edx+symbol.perv]
  1806.         imul edx,sizeof.symbol
  1807.         add edx,ted_tex
  1808.         ret
  1809.  
  1810. ;input:
  1811. ; edx = pointer to symbol struct
  1812. ;output:
  1813. ; edx = pointer to 'next' symbol struct
  1814. align 16
  1815. ted_get_text_next_pos:
  1816.         mov edx,[edx+symbol.next]
  1817.         imul edx,sizeof.symbol
  1818.         add edx,ted_tex
  1819.         ret
  1820.  
  1821. ;input:
  1822. ; edi = pointer to tedit struct
  1823. ;output:
  1824. ; edx = symbol under cursor
  1825. ; ted_gp_opt = 1,2
  1826. ; edx = tex[1].perv if error
  1827. ; ted_gp_opt = 0
  1828. align 16
  1829. ted_get_pos_by_cursor:
  1830.         push eax ecx esi
  1831.                 mov esi,ted_cur_x
  1832.                 mov eax,ted_scr_h
  1833.                 add esi,[eax+sb_offs_position]
  1834.                 mov ecx,ted_cur_y
  1835.                 mov eax,ted_scr_w
  1836.                 add ecx,[eax+sb_offs_position]
  1837.                 call ted_get_pos_by_coords
  1838.         pop esi ecx eax
  1839.         ret
  1840.  
  1841. ;input:
  1842. ; esi = XPos
  1843. ; ecx = YPos
  1844. ; edi = pointer to tedit struct
  1845. ;output:
  1846. ; edx = symbol under cursor
  1847. ; ted_gp_opt = 1 if found text line
  1848. ; ted_gp_opt = 2 if found text line and column
  1849. ; edx = tex[1] if error
  1850. ; ted_gp_opt = 0 if text no found
  1851. align 16
  1852. proc ted_get_pos_by_coords uses eax ebx
  1853.         xor eax,eax ;Row
  1854.         xor ebx,ebx ;Col
  1855.   mov ted_gp_opt,0
  1856.   mov edx,ted_tex
  1857.   @@:
  1858.     call ted_iterat_next
  1859.     cmp edx,ted_tex_1
  1860.     jle @f
  1861.     cmp ebx,esi
  1862.     jne .u1_0 ;Col <> ted_cur_x
  1863.       mov ted_gp_opt,1
  1864.       cmp eax,ecx
  1865.       jge @f ; Row >= ted_cur_y
  1866.     .u1_0:
  1867.     mov ted_gp_opt,0
  1868.     inc ebx
  1869.     cmp byte [edx],13
  1870.     jne @b
  1871.     cmp eax,ecx
  1872.     jge @f ; Row >= ted_cur_y
  1873.     inc eax
  1874.     xor ebx,ebx
  1875.     jmp @b
  1876.   @@:
  1877.   cmp eax,ecx
  1878.   jne @f ; Row = ted_cur_y
  1879.     inc ted_gp_opt
  1880.   @@:
  1881.   cmp ted_gp_opt,0
  1882.   jne @f
  1883.     mov edx,ted_tex_1
  1884.     ;call ted_get_text_perv_pos
  1885.   @@:
  1886.   ret
  1887. endp
  1888.  
  1889. ;input:
  1890. ; eax = Row
  1891. ; edi = pointer to tedit struct
  1892. ;output:
  1893. ; ebx = str len
  1894. align 16
  1895. ted_strlen:
  1896.   push edx ecx
  1897.   ;ecx = Row, from cycle
  1898.  
  1899.   xor ebx,ebx
  1900.   xor ecx,ecx
  1901.   mov edx,ted_tex
  1902.   @@:
  1903.     call ted_iterat_next
  1904.     cmp edx,ted_tex_1
  1905.     jle @f
  1906.     inc ebx
  1907.     cmp byte [edx],13
  1908.     jne @b
  1909.     dec ebx ;lenght minus 1 sumbol to paragraph
  1910.     cmp eax,ecx
  1911.     je @f
  1912.     xor ebx,ebx
  1913.     inc ecx
  1914.     jmp @b
  1915.   @@:
  1916.  
  1917.   cmp eax,ecx
  1918.   je @f
  1919.     xor ebx,ebx
  1920.   @@:
  1921.  
  1922.   pop ecx edx
  1923.   ret
  1924.  
  1925.  
  1926. ;input:
  1927. ; edx = symbol position
  1928. ; edi = pointer to tedit struct
  1929. ;output:
  1930. ; eax = number of line
  1931. ; ebx = symbol position in line
  1932. align 16
  1933. ted_get_text_coords:
  1934.   push edx
  1935.   xor eax,eax
  1936.   xor ebx,ebx
  1937.   @@:
  1938.     call ted_iterat_perv
  1939.  
  1940.     cmp eax,0
  1941.     jne .no_col_mov
  1942.     inc ebx
  1943.     .no_col_mov:
  1944.  
  1945.     cmp edx,ted_tex_1
  1946.     jle @f
  1947.     cmp byte [edx],13
  1948.     jne @b
  1949.     inc eax
  1950.     jmp @b
  1951.   @@:
  1952.   dec ebx
  1953.   pop edx
  1954.   ret
  1955.  
  1956. ;input:
  1957. ; edi = pointer to tedit struct
  1958. ;output:
  1959. ; eax = num lines
  1960. align 16
  1961. ted_get_num_lines:
  1962.         push edx
  1963.         mov eax,1
  1964.         mov edx,ted_tex
  1965.         @@:
  1966.                 call ted_iterat_next
  1967.                 cmp edx,ted_tex_1
  1968.                 jle @f
  1969.                 cmp byte[edx],13
  1970.                 jne @b
  1971.                 inc eax
  1972.                 jmp @b
  1973.         @@:
  1974. ;...
  1975. ;dec eax
  1976.         pop edx
  1977.         ret
  1978.  
  1979.  
  1980. ;input:
  1981. ; edi = pointer to tedit struct
  1982. ;description:
  1983. ; ®â¬¥­ï¥â ®â¬¥­¥­­ë¥ ¤¥©á⢨ï, ¯¥à¥¤ ¨§¬¥­¥­¨¥¬ ¤®ªã¬¥­â 
  1984. align 16
  1985. proc ted_set_undo
  1986.         mov ted_drag_k,0 ;§ ª ­ç¨¢ ¥¬ ¢ë¤¥«¥­¨¥ ®â ª« ¢¨ âãàë
  1987.         cmp ted_tim_undo,1
  1988.         jl .no_work
  1989.  
  1990.         push eax ebx edx
  1991.         mov edx,ted_tex
  1992.         call ted_get_text_next_pos ;long i=tex[0].next;
  1993.         mov eax,ted_tim_undo
  1994.         sub ted_tim_ch,eax ;ted_tim_ch-=ted_tim_undo;
  1995.         mov eax,ted_tim_ch
  1996.         cmp ted_tim_ls,eax ;if(ted_tim_ls>ted_tim_ch)
  1997.         jle @f
  1998.                 mov ted_tim_ls,0
  1999.         @@:
  2000.                 cmp edx,ted_tex_1
  2001.                 jle @f
  2002.  
  2003.                 ;if(tex[i].tc>ted_tim_ch){ // ¥á«¨ á®§¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  2004.                 cmp [edx+symbol.tc],eax
  2005.                 jle .no_u1
  2006.                         mov dword[edx+symbol.tc],0
  2007.                         mov dword[edx+symbol.td],0
  2008.  
  2009.                         mov ebx,[edx+symbol.perv]
  2010.                         imul ebx,sizeof.symbol
  2011.                         add ebx,ted_tex ;ebx=tex[i].perv
  2012.                         m2m dword [ebx+symbol.next],dword [edx+symbol.next] ;tex[tex[i].perv].next=tex[i].next;
  2013.  
  2014.                         mov ebx,[edx+symbol.next]
  2015.                         imul ebx,sizeof.symbol
  2016.                         add ebx,ted_tex ;ebx=tex[i].next
  2017.                         m2m dword [ebx+symbol.perv],dword [edx+symbol.perv] ;tex[tex[i].next].perv=tex[i].perv;
  2018.  
  2019.                         cmp ted_ptr_free_symb,edx
  2020.                         jle .no_cor_free
  2021.                                 mov ted_ptr_free_symb,edx ;¬¥­ï¥¬ 㪠§ â¥«ì ­  ᢮¡®¤­ë© ᨬ¢®«, ¤«ï ¡®«¥¥ ¡ëáâண® ¯®¨áª  ¯ ¬ïâ¨
  2022.                         .no_cor_free:
  2023.                         mov edx,ebx ;®¯â¨¬¨§¨à㥬 ¯® ᪮à®á⨠(edx ¯®á«¥ ¢ë§®¢  ted_get_text_next_pos ¡ã¤¥â à ¢¥­ ebx)
  2024.                         jmp @b
  2025.                 .no_u1:
  2026.  
  2027.                 ;else if(tex[i].td>ted_tim_ch) tex[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  2028.                 cmp [edx+symbol.td],eax
  2029.                 jle .no_u2
  2030.                         mov dword[edx+symbol.td],0
  2031.                 .no_u2:
  2032.  
  2033.                 call ted_get_text_next_pos
  2034.                 jmp @b
  2035.         @@:
  2036.         mov ted_tim_undo,0
  2037.         mov eax,ted_tim_co
  2038.         cmp ted_tim_ch,eax
  2039.         jge @f
  2040.                 mov ted_tim_co,0
  2041.         @@:
  2042.         pop edx ebx eax
  2043.         .no_work:
  2044.         ret
  2045. endp
  2046.  
  2047. ;description:
  2048. ; ¯¥à¥å®¤ ­  㪠§ ­­ãî ¯®§¨æ¨î
  2049. ;input:
  2050. ; row = ­®¬¥à áâப¨
  2051. ; col = ᨬ¢®«
  2052. align 16
  2053. proc ted_go_to_position uses ecx edx edi, edit:dword, row:dword, col:dword
  2054.         mov edi,[edit]
  2055.         ; ¯®¤£®â®¢ª  áâப¨
  2056.         mov edx,[row]
  2057.         call ted_get_num_lines
  2058.         cmp edx,eax
  2059.         jle @f
  2060.                 mov edx,eax ;®£à ­¨ç¥­¨¥ ¯® áâப¥ max
  2061.         @@:
  2062.         dec edx
  2063.         cmp edx,0
  2064.         jge @f
  2065.                 xor edx,edx ;®£à ­¨ç¥­¨¥ ¯® áâப¥ min
  2066.         @@:
  2067.         ; ¯®¤£®â®¢ª  ᨬ¢®« 
  2068.         mov ecx,[col]
  2069.         dec ecx
  2070.         cmp ecx,0
  2071.         jge @f
  2072.                 xor ecx,ecx
  2073.         @@:
  2074.         call ted_go_to_pos
  2075.         stdcall ted_draw,edi
  2076.         ret
  2077. endp
  2078.  
  2079. ;input:
  2080. ; ecx = Col
  2081. ; edx = Row
  2082. ; edi = pointer to tedit struct
  2083. ;output:
  2084. ; ecx = cursor x
  2085. ; edx = cursor y
  2086. align 16
  2087. ted_go_to_pos:
  2088.         push eax ebx
  2089.         mov eax,ted_scr_h
  2090.         sub ecx,[eax+sb_offs_position]
  2091.         cmp ecx,0 ;ted_cur_x < 0
  2092.         jge @f
  2093.                 add [eax+sb_offs_position],ecx ;¯à®ªàã⪠ áªà®««¨­£  ¢«¥¢®
  2094.                 xor ecx,ecx
  2095.         @@:
  2096.         mov ebx,5 ;5 - ¦¥« ¥¬ë© ®âáâ㯠᫥¢ 
  2097.         cmp ecx,ebx
  2098.         jge .end0
  2099.                 sub ebx,ecx ;ebx - ­  ᪮«ìª® ᨬ¢®«®¢ ­ã¦­® ᤢ¨­ãâì ªãàá®à
  2100.                 cmp [eax+sb_offs_position],ebx
  2101.                 jge @f
  2102.                         add ecx,[eax+sb_offs_position]
  2103.                         mov dword[eax+sb_offs_position],0
  2104.                         jmp .end0
  2105.                 @@:
  2106.                         sub [eax+sb_offs_position],ebx
  2107.                         add ecx,ebx
  2108.         .end0:
  2109.         cmp ecx,[eax+sb_offs_cur_area] ;ted_cur_x > [.cur_area]
  2110.         jl .end1
  2111.                 mov ebx,ecx
  2112.                 sub ebx,[eax+sb_offs_cur_area]
  2113.                 inc ebx
  2114.                 add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢¯à ¢®
  2115.                 sub ecx,ebx
  2116.         .end1:
  2117.         mov ted_cur_x,ecx
  2118.  
  2119.         mov eax,ted_scr_w
  2120.         sub edx,[eax+sb_offs_position]
  2121.         cmp edx,0 ;ted_cur_y < 0
  2122.         jge @f
  2123.                 add [eax+sb_offs_position],edx ;¯à®ªàã⪠ áªà®««¨­£  ¢¢¥àå
  2124.                 xor edx,edx
  2125.                 jmp .end2
  2126.         @@:
  2127.         cmp edx,[eax+sb_offs_cur_area] ;ted_cur_y > [.cur_area]
  2128.         jl .end2
  2129.                 mov ebx,edx
  2130.                 sub ebx,[eax+sb_offs_cur_area]
  2131.                 inc ebx
  2132.                 add [eax+sb_offs_position],ebx ;¯à®ªàã⪠ áªà®««¨­£  ¢­¨§
  2133.                 sub edx,ebx
  2134.         .end2:
  2135.         mov ted_cur_y,edx
  2136.         pop ebx eax
  2137.         ret
  2138.  
  2139. ;input:
  2140. ; edi = pointer to tedit struct
  2141. align 16
  2142. ted_text_colored:
  2143.   push eax edx
  2144.   mov eax,ted_tim_ch
  2145.   sub eax,ted_tim_undo
  2146.   mov ted_tim_co,eax
  2147.   mov edx,ted_tex
  2148.   @@:
  2149.     call ted_iterat_next
  2150.     cmp edx,ted_tex_1
  2151.     jle @f
  2152.     mov byte[edx+1],0
  2153.     jmp @b
  2154.   @@:
  2155.  
  2156.   cmp ted_key_words_count,1
  2157.   jl .no_colors
  2158.   mov edx,ted_tex
  2159.   @@:
  2160.     call ted_text_find_sel_color
  2161.     cmp edx,ted_tex_1
  2162.     jle .no_colors
  2163.     jmp @b
  2164.   .no_colors:
  2165.   pop edx eax
  2166.   ret
  2167.  
  2168.  
  2169. ;input:
  2170. ; edx = pointer to start symbol
  2171. ; edi = pointer to tedit struct
  2172. ;output:
  2173. ; edx = pointer to next symbol
  2174. ;description:
  2175. ; ”ã­ªæ¨ï ¤«ï ¯®¨áª  ¨ ¢ë¤¥«¥­¨ï ¯®¤á¢¥ç¥­ëå á«®¢
  2176. align 16
  2177. proc ted_text_find_sel_color uses eax ebx ecx esi
  2178. locals
  2179.         begPos dd ? ;­ ç «ì­ ï ¯®§¨æ¨ï
  2180.         endPos dd ? ;ª®­¥ç­ ï ¯®§¨æ¨ï
  2181.         find db ? ;­ ©¤¥­® / ­¥ ­ ©¤¥­®
  2182.         f_color db ? ;¨­¤¥ªá æ¢¥â  ­ ©¤¥­®£® á«®¢ 
  2183. endl
  2184. ;eax = word_n ⥪ã騩 ­®¬¥à (¯®§¨æ¨ï) ¯à®¢¥à塞®£® á«®¢  ¢ ᯨ᪥
  2185. ;ebx = ¤«ï à §­ëå æ¥«¥©
  2186. ;ecx = l_pos ¯®á«¥¤­¨© ­®¬¥à (¯®§¨æ¨ï) ¯®¤å®¤ï饣® á«®¢  ¢ ᯨ᪥
  2187. ;esi = ¤«ï à §­ëå æ¥«¥©, ­®¬¥à ¯à®¢¥à塞®£® ᨬ¢®«  ¢ á«®¢¥
  2188.         mov dword[begPos],1
  2189.         mov dword[endPos],1
  2190.         mov byte[find],0
  2191.         mov byte[f_color],1
  2192.         @@:
  2193.                 call ted_iterat_next
  2194.                 cmp edx,ted_tex_1
  2195.                 jle @f
  2196.  
  2197.                 xor eax,eax
  2198.                 mov al,byte[edx]
  2199.                 shl ax,2 ;eax*=4
  2200.                 add eax,ted_arr_key_pos
  2201.                 mov eax,[eax]
  2202.                 cmp eax,0
  2203.                 jl @b ;if( (word_n=ted_arr_key_pos[(unsigned char)tex[i].c])>-1 ){
  2204.  
  2205.                 mov ecx,eax
  2206.                 ;while(l_pos<ted_key_words_count && Col[l_pos].Text[0]==Col[word_n].Text[0])
  2207.                 .wh_1b:
  2208.                         cmp ecx,ted_key_words_count
  2209.                         jge .wh_1e
  2210.                         ColToIndexOffset ecx,esi
  2211.                         mov bl,byte[esi]
  2212.                         ColToIndexOffset eax,esi
  2213.                         cmp bl,byte[esi]
  2214.                         jne .wh_1e
  2215.                                 inc ecx
  2216.                         jmp .wh_1b
  2217.                 .wh_1e:
  2218.  
  2219.                 mov [begPos],edx ;bP=i;
  2220.                 mov esi,1
  2221. align 4
  2222.                 .wh_2b: ;while(1){
  2223.                 call ted_iterat_next
  2224.  
  2225.                 ;while(l_pos>word_n && Col[l_pos-1].Text[pos]!=tex[i].c)
  2226.                 .wh_3b:
  2227.                         cmp ecx,eax
  2228.                         jle .wh_3e
  2229.                         dec ecx
  2230.                         ColToIndexOffset ecx,ebx
  2231.                         inc ecx
  2232.                         ;cmp byte[ebx+esi],byte[edx]
  2233.                         mov bl,byte[ebx+esi]
  2234.                         cmp bl,byte[edx]
  2235.                         je .wh_3e
  2236.                                 dec ecx
  2237.                         jmp .wh_3b
  2238.                 .wh_3e:
  2239.  
  2240.                 ColToIndexOffset eax,ebx
  2241.                 cmp byte[ebx+esi],0
  2242.                 jne .if_0 ;if(Col[word_n].Text[pos]==0){
  2243.                 mov [endPos],edx ;eP=i;
  2244.                 ColToIndexOffset eax,ebx
  2245.                 mov bl,[ebx+MAX_COLOR_WORD_LEN+7]
  2246.                 mov [f_color],bl ;f_color=Col[word_n].color;
  2247.  
  2248.                 mov byte[find],1
  2249.                 ColToIndexOffset eax,ebx ;... ebx = Col[word_n]
  2250.                 mov bl,[ebx+MAX_COLOR_WORD_LEN+4]
  2251.                 cmp bl,0 ;if(Col[word_n].wwo)
  2252.                 je .if_2n
  2253.                         push edx
  2254.                         mov edx,[begPos]
  2255.                         call ted_iterat_perv
  2256.  
  2257.                         btr bx,0 ;1-1
  2258.                         jae .if_3e ;if(Col[word_n].wwo&1)
  2259.                                 ;u1= !(isalnum(cont_s)||cont_s=='_')
  2260.                                 call isalnum
  2261.                                 jae .if_3e
  2262.                                         mov byte[find],0
  2263.                                         jmp .if_4e
  2264.                         .if_3e:
  2265.  
  2266.                         btr bx,3 ;4-1
  2267.                         jae .if_4e ;if(Col[word_n].wwo&8)
  2268.                                 ;u1= !isalpha(cont_s);
  2269.                                 call isalpha
  2270.                                 jae .if_4e
  2271.                                         mov byte[find],0
  2272.                         .if_4e:
  2273.  
  2274.                         mov edx,[endPos]
  2275.                         ;call ted_iterat_next
  2276.  
  2277.                         btr bx,1 ;2-1
  2278.                         jae .if_5e ;if(Col[word_n].wwo&2)
  2279.                                 ;u1= !(isalnum(cont_s)||cont_s=='_')
  2280.                                 call isalnum
  2281.                                 jae .if_5e
  2282.                                         mov byte[find],0
  2283.                                         jmp .if_6e
  2284.                         .if_5e:
  2285.  
  2286.                         btr bx,4 ;5-1
  2287.                         jae .if_6e ;if(Col[word_n].wwo&16)
  2288.                                 ;u1= !isalpha(cont_s);
  2289.                                 call isalpha
  2290.                                 jae .if_6e
  2291.                                         mov byte[find],0
  2292.                         .if_6e:
  2293.  
  2294.                         btr bx,2 ;3-1
  2295.                         jae .if_7e ;if(Col[word_n].wwo&4)
  2296.                                 ColToIndexOffset eax,ebx
  2297.                                 mov bx,word[ebx+MAX_COLOR_WORD_LEN+5]
  2298.                                 call ted_iterat_next_pos_char
  2299.                                 cmp edx,ted_tex_1
  2300.                                 jle .if_7e
  2301.                                         mov dword[endPos],edx
  2302.                         .if_7e:
  2303.  
  2304.                         pop edx
  2305.                 .if_2n:
  2306. ;if(i!=1){ // ­¥ ª®­¥æ ¤®ªã¬¥­â 
  2307. ;  cont_s=tex[eP].c;
  2308. ;  if(Col[word_n].wwo&2) u2= !(isalnum(cont_s)||cont_s=='_');  // ­¥ ¡ãª¢.-ç¨á«. ᨬ¢®«
  2309. ;  if(u2 && Col[word_n].wwo&16) u2= !isalpha(cont_s); // ­¥ ç¨á«. ᨬ¢®«
  2310. ;  if(Col[word_n].wwo&4) eP=ted_iterat_next_pos_char(eP,Col[word_n].endc);
  2311.  
  2312.                         cmp eax,ecx
  2313.                         je .wh_2e ;if(word_n==l_pos) break; // do double - ¥á«¨ á«®¢® â®ç­® ¯®á«¥¤­¥¥
  2314.                 .if_0:
  2315.  
  2316.                 cmp edx,ted_tex_1
  2317.                 jle .wh_2e ;if(i==1) break;
  2318.  
  2319.                 ;while(l_pos>word_n && Col[word_n].Text[pos]!=tex[i].c)
  2320.                 .wh_4b:
  2321.                 cmp ecx,eax
  2322.                 jle .wh_4e
  2323.                         ColToIndexOffset eax,ebx
  2324.                         ;cmp byte[ebx+esi],byte[edx]
  2325.                         mov bl,byte[ebx+esi]
  2326.                         cmp bl,byte[edx]
  2327.                         je .wh_4e
  2328.                                 inc eax
  2329.                         jmp .wh_4b
  2330.                 .wh_4e:
  2331.  
  2332.                 cmp eax,ecx
  2333.                 je .wh_2e;if(word_n==l_pos) break;
  2334.                         inc esi ;pos++;
  2335.                         jmp .wh_2b
  2336.                 .wh_2e:
  2337.  
  2338.                 cmp byte[find],1 ;if(fnd)break;
  2339.                 je @f
  2340.                         mov edx,[begPos];i=bP;
  2341.                 jmp @b
  2342.         @@:
  2343.  
  2344.         cmp byte[find],1
  2345.         jne .if_1e ;if(fnd){ // ¢ë¤¥«¥­¨¥ ­ ©¤¥­®£® ⥪áâ 
  2346.                 ;if(!mode_sf1 || (mode_sf1 && strlen(Col[word_n].f1->c_str())>0)){
  2347.                 mov eax,[begPos]
  2348.                 mov bl,[f_color]
  2349.                 mov [eax+1],bl ;tex[bP].col=f_color;
  2350.                 mov eax,[endPos]
  2351.                 mov byte[eax+1],0xff ;tex[eP].col=255;
  2352.                 ;return ItPoPerv(eP); // ¢®§¢à é ¥¬ ¯®§¨æ¨î ª®­æ  ¢å®¦¤¥­¨ï
  2353.                 mov edx,[endPos]
  2354.                 call ted_get_text_perv_pos
  2355.                 jmp @f
  2356.         .if_1e:
  2357.                 mov edx,ted_tex
  2358.         @@:
  2359.  
  2360.         ret
  2361. endp
  2362.  
  2363. ;input:
  2364. ; edx = pointer to char (byte)
  2365. ;output:
  2366. ; cf=1 if symbol is...
  2367. align 16
  2368. tab_all_num db 0,0,0,0,0,0,0xff,11b,11111110b,0xff,0xff,10000111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0;,0,0,0,0,0,0,0,0 - tab_alpha_0,0,0,0,0,0,0,0
  2369. tab_alpha db 0,0,0,0,0,0,0,0,11111110b,0xff,0xff,10000111b,11111110b,0xff,0xff,111b,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2370.  
  2371. ;output:
  2372. ; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢ , æ¨äà  ¨«¨ '_'
  2373. align 16
  2374. isalnum:
  2375.         push eax ebx
  2376.         movzx eax,byte[edx] ;al=offset
  2377.         shr eax,3
  2378.         lea ebx,[tab_all_num]
  2379.         add ebx,eax
  2380.         movzx ax,byte[edx] ;al=bit
  2381.         and ax,111b
  2382.         bt word[ebx],ax
  2383.         pop ebx eax
  2384.         ret
  2385.  
  2386. ;output:
  2387. ; cf=1 ¥á«¨ ¢ [edx] ¡ãª¢  ¨«¨ '_'
  2388. align 16
  2389. isalpha:
  2390.         push eax ebx
  2391.         movzx eax,byte[edx] ;al=offset
  2392.         shr eax,3
  2393.         lea ebx,[tab_alpha]
  2394.         add ebx,eax
  2395.         movzx ax,byte[edx] ;al=bit
  2396.         and ax,111b
  2397.         bt word[ebx],ax
  2398.         pop ebx eax
  2399.         ret
  2400.  
  2401. align 16
  2402. proc ted_show_help_f1 uses eax edx edi, edit:dword
  2403.         mov edi,[edit]
  2404.  
  2405.         call ted_get_pos_by_cursor
  2406.         push edx
  2407.                 call ted_iterat_next_color_tag
  2408.                 mov eax,edx
  2409.         pop edx
  2410.         call ted_iterat_perv_color_tag
  2411.  
  2412.         cmp eax,ted_tex
  2413.         jle @f
  2414.         cmp edx,ted_tex_1
  2415.         jle @f
  2416.                 stdcall ted_find_help_id,eax
  2417.         @@:
  2418.         ;call ted_draw_main_cursor
  2419.         call ted_draw_help_f1
  2420.         ret
  2421. endp
  2422.  
  2423. ;input:
  2424. ; edx = position begin 'symbol' struct
  2425. ; edi = pointer to tedit struct
  2426. ; end_pos = position end 'symbol' struct
  2427. align 16
  2428. proc ted_find_help_id, end_pos:dword
  2429. ; ecx = word_n
  2430. ; ebx = l_pos
  2431.   mov ted_help_id,-1
  2432.  
  2433.   push ebx ecx
  2434.     xor ebx,ebx
  2435.     mov bl,[edx]
  2436.     shl bx,2 ;ebx*=4
  2437.     add ebx,ted_arr_key_pos
  2438.     mov ecx,[ebx]
  2439.     cmp ecx,0
  2440.     jl .if_0e ;if( (word_n=ted_arr_key_pos[(unsigned char)tf[0]])>-1 ){
  2441.       push esi eax
  2442.       mov ebx,ecx ;l_pos=word_n;
  2443.       ColToIndexOffset ecx,esi
  2444.       push cx
  2445.       mov cl,[esi]
  2446.       @@:
  2447.         cmp ebx,ted_key_words_count ;while(l_pos<ted_key_words_count)
  2448.         jge @f
  2449.         ;ColToIndexOffset ecx,esi
  2450.         ColToIndexOffset ebx,eax
  2451.         cmp cl,[eax] ;&& Col[l_pos].Text[0]==Col[word_n].Text[0])
  2452.         jne @f
  2453.           inc ebx ;l_pos++;
  2454.           jmp @b
  2455.       @@:
  2456.       pop cx
  2457.       call ted_iterat_next ;pos=1;
  2458.       mov esi,1
  2459.       @@:
  2460.         push dx
  2461.         push word[edx]
  2462.         pop dx
  2463.           .wh_0b:
  2464.             cmp ebx,ecx ;while(l_pos>word_n
  2465.             jle .wh_0e
  2466.             dec ebx
  2467.             ColToIndexOffset ebx,eax
  2468.             inc ebx
  2469.             cmp byte[eax+esi],dl ;&& Col[l_pos-1].Text[pos]!=tf[i])
  2470.             je .wh_0e
  2471.               dec ebx ;l_pos--;
  2472.             jmp .wh_0b
  2473.           .wh_0e:
  2474.  
  2475.           .wh_1b:
  2476.             cmp ebx,ecx ;while(l_pos>word_n
  2477.             jle .wh_1e
  2478.             ColToIndexOffset ecx,eax
  2479.             cmp byte[eax+esi],dl
  2480.             je .wh_1e
  2481.               inc ecx ;word_n++;
  2482.             jmp .wh_1b
  2483.           .wh_1e:
  2484.         pop dx
  2485.  
  2486.         cmp ecx,ebx ;if(word_n==l_pos) break;
  2487.         je @f
  2488.         call ted_iterat_next ;pos++;
  2489.         cmp edx,[end_pos] ;for(...;i<strlen;...)
  2490.         je @f ;jge
  2491.         inc esi
  2492.         jmp @b
  2493.       @@:
  2494.       pop eax esi
  2495.  
  2496.       mov ted_help_id,ecx
  2497.       ;return word_n;
  2498.  
  2499.     .if_0e:
  2500.   pop ecx ebx
  2501.   ret
  2502. endp
  2503.  
  2504. ;output:
  2505. ; eax = ª®¤ ®è¨¡ª¨
  2506. ; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
  2507. align 16
  2508. proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
  2509.         mov edi,[edit]
  2510.  
  2511.         ; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ ***
  2512.         ;¯à®¡ã¥¬ ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ä ©«¥
  2513.         mov ebx,[file]
  2514.         mov dword[ebx], SSF_GET_INFO
  2515.         mov dword[ebx+4], 0
  2516.         mov dword[ebx+8], 0
  2517.         mov dword[ebx+12], 0
  2518.         m2m dword[ebx+16], ted_tex
  2519.         mov  byte[ebx+20], 0
  2520.         push dword[f_name]
  2521.         pop dword[ebx+21]
  2522.         mcall SF_FILE
  2523.         or eax,eax
  2524.         jz .end_0
  2525.                 mov edx,ted_max_chars
  2526.                 cmp eax,2 ;äã­ªæ¨ï ­¥ ¯®¤¤¥à¦¨¢ ¥âáï ¤«ï ¤ ­­®© ä ©«®¢®© á¨á⥬ë
  2527.                 je @f
  2528.                 jmp .ret_f
  2529. align 4
  2530.         .end_0:
  2531.         ;¯à®¢¥à塞 墠â¨â «¨ ¯ ¬ï⨠¤«ï § £à㧪¨ ä ©« 
  2532.         mov ecx,ted_max_chars
  2533.         sub ecx,2 ;ecx = ¬ ªá¨¬ «ì­®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë«  ¢ë¤¥«¥­  ¯ ¬ïâì
  2534.         mov edx,ted_tex
  2535.         mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å
  2536.         cmp edx,ecx
  2537.         jl @f
  2538.                 ;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫®
  2539.                 mov ecx,edx ;¯ ¬ïâì ­¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©« 
  2540.                 add ecx,2  ;¯ ¬ïâì ¤«ï á«ã¦¥¡­ëå ­ ç «ì­®£® ¨ ª®­¥ç­®£® ᨬ¢®«®¢
  2541.                 add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
  2542.                 mov ted_max_chars,ecx
  2543.                 imul ecx,sizeof.symbol
  2544.                 invoke mem.realloc, ted_tex,ecx
  2545.                 mov ted_tex,eax
  2546.                 mov ted_tex_1,eax
  2547.                 add ted_tex_1,sizeof.symbol
  2548.                 add eax,ecx
  2549.                 mov ted_tex_end,eax
  2550.                 mov ecx,ted_tex_1
  2551.                 add ecx,sizeof.symbol
  2552.                 mov ted_ptr_free_symb,ecx
  2553.         @@:
  2554.  
  2555.         ; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
  2556.         mov ebx,[file]
  2557.         mov dword[ebx], SSF_READ_FILE
  2558.         mov dword[ebx+4], 0
  2559.         mov dword[ebx+8], 0
  2560.         m2m dword[ebx+12], edx ;ç¨á«® ¡ ©â, ª®â®àë¥ ¬®£ãâ ¡ëâì áç¨â ­ë á ä ©«  (­¥ ¡®«ìè¥ ç¥¬ ted_max_chars)
  2561.         m2m dword[ebx+16], ted_tex
  2562.         mov  byte[ebx+20], 0
  2563.         push dword[f_name]
  2564.         pop dword[ebx+21]
  2565.         mcall SF_FILE
  2566.  
  2567.         or eax,eax
  2568.         jz @f
  2569.         cmp eax,6
  2570.         je @f
  2571.                 jmp .ret_f
  2572.         @@:
  2573.         cmp ebx,-1
  2574.         je .ret_f
  2575.                 ;if open file
  2576.                 call ted_on_open_file
  2577.         .ret_f:
  2578.         ret
  2579. endp
  2580.  
  2581. align 16
  2582. proc ted_but_select_word, edit:dword
  2583.         pushad
  2584.         mov edi,[edit]
  2585.  
  2586.         call ted_get_pos_by_cursor
  2587.         push edx
  2588.                 call ted_iterat_perv_color_tag
  2589.                 cmp edx,ted_tex_1
  2590.                 jle @f
  2591.                         call ted_get_text_coords
  2592.                         mov ted_sel_x0,ebx
  2593.                         mov ted_sel_y0,eax
  2594.                 @@:
  2595.         pop edx
  2596.         call ted_iterat_next_color_tag
  2597.         cmp edx,ted_tex_1
  2598.         jle @f
  2599.                 call ted_get_text_coords
  2600.                 mov ted_sel_x1,ebx
  2601.                 mov ted_sel_y1,eax
  2602.         @@:
  2603.  
  2604.         cmp ted_fun_draw_panel_buttons,0
  2605.         je @f
  2606.                 call ted_fun_draw_panel_buttons
  2607.         @@:
  2608.         stdcall ted_draw,edi
  2609.         popad
  2610.         ret
  2611. endp
  2612.  
  2613. ;output:
  2614. ; al = 1 if delete
  2615. align 16
  2616. proc ted_but_cut uses edi, edit:dword
  2617.         mov edi,[edit]
  2618.  
  2619.         stdcall ted_but_copy,edi
  2620.         call ted_set_undo
  2621.         stdcall ted_sel_text_del,ted_opt_ed_change_time
  2622.  
  2623.         cmp al,1
  2624.         jne @f
  2625.                 stdcall ted_draw,edi
  2626.                 cmp ted_fun_draw_panel_buttons,0
  2627.                 je @f
  2628.                         call ted_fun_draw_panel_buttons
  2629.         @@:
  2630.         ret
  2631. endp
  2632.  
  2633. align 16
  2634. proc ted_but_copy, edit:dword
  2635.         pushad
  2636.         mov edi,[edit]
  2637.  
  2638.         call ted_is_select
  2639.         or al,al
  2640.         jz .end_f ;if not selected text
  2641.         call ted_sel_normalize
  2642.  
  2643.         mov esi,ted_seln_x1
  2644.         mov ecx,ted_seln_y1
  2645.         call ted_get_pos_by_coords
  2646.         mov ebx,edx
  2647.         mov esi,ted_seln_x0
  2648.         mov ecx,ted_seln_y0
  2649.         call ted_get_pos_by_coords
  2650.         mov esi,ebx
  2651.  
  2652.         mov ecx,12 ;system buffer header size
  2653.         mov ebx,ted_buffer
  2654.         mov dword[ebx+4],0 ;text data
  2655.         mov dword[ebx+8],1 ;code 866
  2656.         add ebx,ecx
  2657.         @@:
  2658.                 cmp edx,ted_tex_1 ;end of file
  2659.                 jle @f
  2660.                 cmp edx,esi ;end of select
  2661.                 je @f
  2662.                 inc ecx
  2663.                 cmp ecx,ted_buffer_size ;owerflow bufer
  2664.                 je @f
  2665.  
  2666.                 mov al,byte[edx]
  2667.                 mov byte[ebx],al
  2668.                 inc ebx
  2669.                 cmp al,13
  2670.                 jne .no_13
  2671.                         mov byte[ebx],10 ;¤¥« ¥¬ ª®­¥æ áâப¨ ¢ ¡ãä¥à¥ 13,10 ¤«ï ᮢ¬¥á⨬®áâ¨ á ¤à㣨¬¨ ¯à®£à ¬¬ ¬¨
  2672.                         inc ebx
  2673.                         inc ecx
  2674.                 .no_13:
  2675.                
  2676.                 call ted_iterat_next
  2677.                 jmp @b
  2678.         @@:
  2679.         mov byte[ebx],0
  2680.  
  2681.         cmp ecx,12
  2682.         je .end_f
  2683.                 mov ebx,ted_buffer
  2684.                 mov [ebx],ecx
  2685.                 mcall SF_CLIPBOARD,SSF_WRITE_CB,ecx,ted_buffer
  2686.                 call ted_draw_buffer
  2687.                 cmp ted_fun_draw_panel_buttons,0
  2688.                 je .end_f
  2689.                         call ted_fun_draw_panel_buttons
  2690.         .end_f:
  2691.         popad
  2692.         ret
  2693. endp
  2694.  
  2695.  
  2696. align 16
  2697. proc ted_but_paste, edit:dword
  2698.         pushad
  2699.         mov edi,[edit]
  2700.  
  2701.         mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
  2702.         cmp eax,1
  2703.         jl .no_buf_r
  2704.  
  2705.         mov esi,eax
  2706.         .cycle: ;®¡à â­ë© 横« ¯® ᫮⠬
  2707.         dec esi ;­®¬¥à ⥪ã饣®, ¯à®¢¥à塞®£® á«®â 
  2708.         mcall SF_CLIPBOARD,SSF_READ_CB,esi
  2709.         cmp eax,1
  2710.         je .no_buf_r
  2711.         cmp eax,-1
  2712.         je .no_buf_r
  2713.                 mov ecx,[eax]
  2714.                 cmp ecx,1 ;size
  2715.                 jl .no_buf_r
  2716.                 cmp dword[eax+4],0 ;text
  2717.                 je @f
  2718.                         cmp esi,1
  2719.                         jge .cycle ;¥á«¨ ¢ ¡ãä¥à¥ ­¥ ⥪áâ,   ᫮⮢ ¢ ¡ãä¥à¥ ­¥áª®