Subversion Repositories Kolibri OS

Rev

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

  1. key:
  2.         mov     ecx,1
  3.         mcall   66,3
  4.         xor     ebx,ebx
  5.         test    al,0x03
  6.         jz      @f
  7.         or      ebx,KM_SHIFT
  8.     @@: test    al,0x0C
  9.         jz      @f
  10.         or      ebx,KM_CTRL
  11.     @@: test    al,0x30
  12.         jz      @f
  13.         or      ebx,KM_ALT
  14.     @@: mov     [shi],ebx
  15.         test    al,0x03
  16.         jz      @f
  17.         inc     cl
  18.     @@: mcall   26,2,,key1
  19.  
  20.         mcall   2
  21.         cmp     al,0
  22.         jne     still.skip_write
  23.         shr     eax,8
  24.         cmp     al,224
  25.         jne     @f
  26.         mov     [ext],0x01
  27.         jmp     still.skip_write
  28.     @@: cmp     al,225
  29.         jne     @f
  30.         mov     [ext],0x02
  31.         jmp     still.skip_write
  32.     @@:
  33.         mov     ah,[ext]
  34.         mov     [ext],0
  35.         or      eax,[shi]
  36.  
  37.         test    al,0x80
  38.         jnz     still.skip_write
  39.         mov     [chr],al
  40.  
  41.         cmp     [bot_mode],0
  42.         je      @f
  43.         mov     ebx,eax
  44.         mov     al,2
  45.         call    [bot_dlg_handler]
  46.         jmp     still
  47.     @@:
  48.  
  49.         mov     esi,accel_table_main
  50.   .acc: cmp     eax,[esi]
  51.         jne     @f
  52.         test    [options],OPTS_SECURESEL
  53.         jz      .lp1
  54.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  55.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  56.   .lp1: mov     [s_status],0
  57.         call    dword[esi+4]
  58.         jmp     still
  59.     @@: add     esi,8
  60.         cmp     byte[esi],0
  61.         jne     .acc
  62.  
  63.         test    dword[shi],KM_CTRLALT
  64.         jnz     still.skip_write
  65.  
  66.         mov     [s_status],0
  67.  
  68.         movzx   eax,[chr]
  69.         movzx   eax,[eax+key0]
  70.         or      al,al
  71.         jz      still.skip_write
  72.         movzx   eax,[eax+key1]
  73.         push    eax
  74.  
  75.         test    [options],OPTS_SECURESEL
  76.         jz      .lp2
  77.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  78.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  79.         jmp     .put
  80.   .lp2: call    delete_selection
  81.  
  82.         test    [options],OPTS_AUTOBRACES
  83.         jz      .put
  84.         cmp     al,'['
  85.         jne     @f
  86.         mov     al,']'
  87.         call    .lp3
  88.         dec     [cur_editor.Caret.X] ;! [pos.x]
  89.         jmp     .put
  90.     @@: cmp     al,'('
  91.         jne     @f
  92.         mov     al,')'
  93.         call    .lp3
  94.         dec     [cur_editor.Caret.X] ;! [pos.x]
  95.         jmp     .put
  96.     @@: cmp     al,'{'
  97.         jne     .put
  98.         mov     al,'}'
  99.         call    .lp3
  100.         dec     [cur_editor.Caret.X] ;! [pos.x]
  101.  
  102.   .put: pop     eax
  103.         push    still
  104.         inc     [cur_editor.SelStart.X] ;! [sel.x]
  105.   .lp3: push    [cur_editor.Caret.X] eax ;! [pos.x] eax
  106.         inc     dword[esp+4]
  107.         mov     eax,1
  108.         jmp     key.tab.direct
  109.  
  110. ;-----------------------------------------------------------------------------
  111. func key.ctrl_a ;///// SELECT ALL DOCUMENT ///////////////////////////////////
  112. ;-----------------------------------------------------------------------------
  113.         xor     eax,eax
  114.         mov     [cur_editor.SelStart.X],eax ;! [sel.x],eax
  115.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  116.         mov     ecx,[cur_editor.Lines.Count] ;! ecx,[lines]
  117.         dec     ecx
  118.         mov     [cur_editor.Caret.Y],ecx ;! [pos.y],ecx
  119.         call    get_line_offset
  120.         call    get_real_length
  121.         mov     [cur_editor.Caret.X],eax ;! [pos.x],eax
  122.         call    draw_file
  123.         ret
  124. endf
  125.  
  126. ;-----------------------------------------------------------------------------
  127. func key.ctrl_o ;///// ENTER OPEN FILENAME ///////////////////////////////////
  128. ;-----------------------------------------------------------------------------
  129.         mov     [bot_dlg_mode2],0
  130.  
  131.   .direct:
  132.         mov     [s_status],s_enter_filename
  133.  
  134.         mov     [bot_mode],1
  135.         mov     [bot_dlg_height],16*2+4*2-1
  136.         mov     [bot_dlg_handler],osdlg_handler
  137.         mov     [focused_tb],tb_opensave
  138.  
  139.         mov     ecx,[f_info.length]
  140.         mov     [tb_opensave.length],cl
  141.         jecxz   @f
  142.         mov     esi,f_info.path
  143.         mov     edi,tb_opensave.text
  144.         cld
  145.         rep     movsb
  146.  
  147.     @@: mov     al,[tb_opensave.length]
  148.         mov     [tb_opensave.pos.x],al
  149.         mov     [tb_opensave.sel.x],0
  150.         mov     [tb_casesen],0;1
  151.         call    drawwindow
  152.         ret
  153. endf
  154.  
  155. ;-----------------------------------------------------------------------------
  156. func key.ctrl_s ;///// ENTER SAVE FILENAME ///////////////////////////////////
  157. ;-----------------------------------------------------------------------------
  158.         cmp     [cur_editor.FilePath],'/'
  159.         jne     key.shift_ctrl_s
  160.         cmp     [cur_editor.Modified],0 ;! [modified],0
  161.         je      .exit
  162.         ;cmp     [f_info.length],0
  163.         ;je      key.shift_ctrl_s
  164.         call    save_file
  165.         call    drawwindow
  166.   .exit:
  167.         ret
  168.  
  169.     key.shift_ctrl_s:
  170.         mov     [bot_dlg_mode2],1
  171.         jmp     key.ctrl_o.direct
  172. endf
  173.  
  174. ;-----------------------------------------------------------------------------
  175. func key.ctrl_n ;///// CREATE NEW FILE (TAB) /////////////////////////////////
  176. ;-----------------------------------------------------------------------------
  177.         call    create_tab
  178.         ret
  179. endf
  180.  
  181. ;-----------------------------------------------------------------------------
  182. func key.ctrl_f ;///// ENTER KEYWORD TO FIND /////////////////////////////////
  183. ;-----------------------------------------------------------------------------
  184.         mov     [bot_dlg_mode2],0
  185.         mov     [bot_dlg_height],16*2+4*2-1
  186.  
  187.         mov     [s_status],s_enter_text_to_find
  188.  
  189.   .direct:
  190.         mov     [bot_mode],1
  191.         mov     [bot_dlg_handler],finddlg_handler
  192.         mov     [focused_tb],tb_find
  193.  
  194.         mov     ecx,[s_search.size]
  195.         mov     [tb_find.length],cl
  196.         jecxz   @f
  197.         mov     esi,s_search
  198.         mov     edi,tb_find.text
  199.         cld
  200.         rep     movsb
  201.  
  202.     @@: mov     al,[tb_find.length]
  203.         mov     [tb_find.pos.x],al
  204.         mov     [tb_find.sel.x],0
  205.         mov     [tb_casesen],0
  206.         call    drawwindow
  207.         ret
  208. endf
  209.  
  210. func key.ctrl_h
  211.         mov     [bot_dlg_mode2],1
  212.         mov     [bot_dlg_height],16*3+4*2+1
  213.  
  214.         mov     [s_status],s_enter_text_to_replace
  215.  
  216.         jmp     key.ctrl_f.direct
  217. endf
  218.  
  219. func key.ctrl_g
  220.         ret
  221. macro comment {
  222.         mov     [bot_dlg_mode2],0
  223.         mov     [bot_dlg_height],16*2+4*2-1
  224.  
  225.         mov     [bot_mode],1
  226.         mov     [bot_dlg_handler],gotodlg_handler
  227.         mov     [focused_tb],tb_gotorow
  228.  
  229.         mov     al,[tb_gotorow.length]
  230.         mov     [tb_gotorow.pos.x],al
  231.         mov     [tb_gotorow.sel.x],0
  232.         mov     [tb_casesen],0
  233.         call    drawwindow
  234.         ret
  235. }
  236. endf
  237.  
  238. ; CHANGE_LANG_LAYOUT { ; Ctrl + F8
  239. ; 3 times english -> russian
  240. ; 2 times russian -> english
  241. ;        call    layout
  242. ;        jmp     still
  243. ; CHANGE_LANG_LAYOUT }
  244.  
  245. ;-----------------------------------------------------------------------------
  246. func key.ctrl_left ;///// GO TO PREVIOUS WORD ////////////////////////////////
  247. ;-----------------------------------------------------------------------------
  248.         call    clear_selection
  249.  
  250. ;-----------------------------------------------------------------------------
  251.      key.shift_ctrl_left: ;///// GO TO PREVIOUS WORD, WITH SELECTION /////////
  252. ;-----------------------------------------------------------------------------
  253.         mov     ebx,[cur_editor.Caret.Y] ;! ebx,[pos.y]
  254.         mov     edx,[cur_editor.Caret.X] ;! edx,[pos.x]
  255.         cld
  256.         mov     ecx,ebx
  257.         call    get_line_offset
  258.   .lp1: cmp     dx,[esi]
  259.         jle     @f
  260.         movzx   edx,word[esi]
  261.     @@: dec     edx
  262.         jl      .nx1
  263.         add     esi,4
  264.         add     esi,edx
  265.         mov     ecx,edx
  266.     @@: push    ecx
  267.         mov     edi,symbols_ex
  268.         mov     ecx,symbols_ex.size+symbols.size
  269.         mov     al,[esi]
  270.         dec     esi
  271.         repne   scasb
  272.         pop     ecx
  273.         jne     @f
  274.         dec     edx
  275.         dec     ecx
  276.         jnz     @b
  277.   .nx1: dec     ebx
  278.         js      .exit.2
  279.         mov     ecx,ebx
  280.         call    get_line_offset
  281.         movzx   edx,word[esi]
  282.         dec     edx
  283.         jmp     .lp1
  284.     @@:
  285.         mov     ecx,ebx
  286.         call    get_line_offset
  287.   .lp2: cmp     dx,[esi]
  288.         jle     @f
  289.         movzx   edx,word[esi]
  290.     @@: or      edx,edx
  291.         jl      .nx2
  292.         add     esi,4
  293.         add     esi,edx
  294.     @@: mov     edi,symbols_ex
  295.         mov     ecx,symbols_ex.size+symbols.size
  296.         mov     al,[esi]
  297.         dec     esi
  298.         repne   scasb
  299.         je      @f
  300.         dec     edx
  301.         jns     @b
  302.         jmp     @f
  303.   .nx2: dec     ebx
  304.         js      .exit.2
  305.         mov     ecx,ebx
  306.         call    get_line_offset
  307.         movzx   edx,word[esi]
  308.         dec     edx
  309.         jmp     .lp2
  310.     @@:
  311.         inc     edx
  312.         mov     [cur_editor.Caret.Y],ebx ;! [pos.y],ebx
  313.         mov     [cur_editor.Caret.X],edx ;! [pos.x],edx
  314.         test    byte[shi+2],0x01
  315.         jnz     @f
  316.         mov     [cur_editor.SelStart.Y],ebx ;! [sel.y],ebx
  317.         mov     [cur_editor.SelStart.X],edx ;! [sel.x],edx
  318.     @@: sub     ebx,[cur_editor.TopLeft.Y] ;! ebx,[top_line]
  319.         jge     @f
  320.         add     [cur_editor.TopLeft.Y],ebx ;! [top_line],ebx
  321.     @@: mov     eax,edx
  322.         sub     eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
  323.         cmp     eax,[columns.scr]
  324.         jl      @f
  325.         sub     eax,[columns.scr]
  326.         inc     eax
  327.         add     [cur_editor.TopLeft.X],eax ;! [left_col],eax
  328.         jmp     .exit
  329.     @@: cmp     edx,[cur_editor.TopLeft.X] ;! edx,[left_col]
  330.         jge     .exit
  331.         mov     [cur_editor.TopLeft.X],edx ;! [left_col],edx
  332.   .exit:
  333.         call    draw_file
  334.   .exit.2:
  335.         ret
  336. endf
  337.  
  338. ;-----------------------------------------------------------------------------
  339. func key.ctrl_right ;///// GO TO NEXT WORD ///////////////////////////////////
  340. ;-----------------------------------------------------------------------------
  341.         call    clear_selection
  342.  
  343. ;-----------------------------------------------------------------------------
  344.      key.shift_ctrl_right: ;///// GO TO NEXT WORD, WITH SELECTION ////////////
  345. ;-----------------------------------------------------------------------------
  346.         mov     ebx,[cur_editor.Caret.Y] ;! ebx,[pos.y]
  347.         mov     edx,[cur_editor.Caret.X] ;! edx,[pos.x]
  348.         cld
  349.   .lp1: mov     ecx,ebx
  350.         call    get_line_offset
  351.         movzx   ecx,word[esi]
  352.         cmp     edx,ecx
  353.         jge     .nx1
  354.         add     esi,4
  355.         add     esi,edx
  356.         sub     ecx,edx
  357.     @@: push    ecx
  358.         mov     edi,symbols_ex
  359.         mov     ecx,symbols_ex.size+symbols.size
  360.         lodsb
  361.         repne   scasb
  362.         pop     ecx
  363.         je      @f
  364.         inc     edx
  365.         dec     ecx
  366.         jnz     @b
  367.   .nx1: inc     ebx
  368.         cmp     ebx,[cur_editor.Lines.Count] ;! ebx,[lines]
  369.         jge     .exit.2
  370.         xor     edx,edx
  371.         jmp     .lp1
  372.     @@:
  373.  
  374.   .lp2: mov     ecx,ebx
  375.         call    get_line_offset
  376.         movzx   ecx,word[esi]
  377.         cmp     edx,ecx
  378.         jge     .nx2
  379.         add     esi,4
  380.         add     esi,edx
  381.         sub     ecx,edx
  382.     @@: push    ecx
  383.         mov     edi,symbols_ex
  384.         mov     ecx,symbols_ex.size+symbols.size
  385.         lodsb
  386.         repne   scasb
  387.         pop     ecx
  388.         jne     @f
  389.         inc     edx
  390.         dec     ecx
  391.         jnz     @b
  392.   .nx2: inc     ebx
  393.         cmp     ebx,[cur_editor.Lines.Count] ;! ebx,[lines]
  394.         jge     .exit.2
  395.         xor     edx,edx
  396.         jmp     .lp2
  397.     @@:
  398.         mov     [cur_editor.Caret.Y],ebx ;! [pos.y],ebx
  399.         mov     [cur_editor.Caret.X],edx ;! [pos.x],edx
  400.         test    byte[shi+2],0x01
  401.         jnz     @f
  402.         mov     [cur_editor.SelStart.Y],ebx ;! [sel.y],ebx
  403.         mov     [cur_editor.SelStart.X],edx ;! [sel.x],edx
  404.     @@: sub     ebx,[cur_editor.TopLeft.Y] ;! ebx,[top_line]
  405.         cmp     ebx,[lines.scr]
  406.         jl      @f
  407.         sub     ebx,[lines.scr]
  408.         inc     ebx
  409.         add     [cur_editor.TopLeft.Y],ebx ;! [top_line],ebx
  410.     @@: mov     eax,edx
  411.         sub     eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
  412.         cmp     eax,[columns.scr]
  413.         jl      @f
  414.         sub     eax,[columns.scr]
  415.         inc     eax
  416.         add     [cur_editor.TopLeft.X],eax ;! [left_col],eax
  417.         jmp     .exit
  418.     @@: cmp     edx,[cur_editor.TopLeft.X] ;! edx,[left_col]
  419.         jge     .exit
  420.         mov     [cur_editor.TopLeft.X],edx ;! [left_col],edx
  421.   .exit:
  422.         call    draw_file
  423.   .exit.2:
  424.         ret
  425. endf
  426.  
  427. ;-----------------------------------------------------------------------------
  428. func key.ctrl_x
  429.         cmp     [sel.selected],0
  430.         je      @f
  431.         call    key.ctrl_c
  432.         call    key.del
  433.         mov     [cur_editor.Modified],1 ;! [modified],1
  434.     @@: ret
  435. endf
  436.  
  437. ;-----------------------------------------------------------------------------
  438. func key.ctrl_c
  439.         mov     [copy_size],0
  440.         cmp     [sel.selected],0
  441.         je      .exit
  442.  
  443.         call    get_selection_size
  444.         mov     ebx,eax
  445.         mov     eax,[copy_buf]
  446.         call    mem.ReAlloc
  447.         mov     [copy_buf],eax
  448.  
  449.         cld
  450.         mov     eax,[sel.begin.y]
  451.         cmp     eax,[sel.end.y]
  452.         je      .single_line
  453.         mov     ecx,[sel.begin.y]
  454.         call    get_line_offset
  455.         inc     ecx
  456.         push    ecx
  457.         mov     edi,[copy_buf] ;! AREA_CBUF
  458.         call    get_real_length
  459.         sub     eax,[sel.begin.x]
  460.         jge     @f
  461.         xor     eax,eax
  462.     @@: add     esi,[sel.begin.x]
  463.         add     esi,4
  464.         stosd
  465.         mov     ecx,eax
  466.         jecxz   @f
  467.         rep     movsb
  468.     @@: mov     ecx,[sel.end.y]
  469.         call    get_line_offset
  470.         pop     ecx
  471.         cmp     ecx,[sel.end.y]
  472.         je      @f
  473.         mov     eax,esi
  474.         call    get_line_offset
  475.         sub     eax,esi
  476.         mov     ecx,eax
  477.         rep     movsb
  478.         mov     ecx,[sel.end.y]
  479.     @@: call    get_line_offset
  480.         movzx   eax,word[esi]
  481.         add     esi,4
  482. ;       lodsd
  483.         cmp     eax,[sel.end.x]
  484.         jle     @f
  485.         mov     eax,[sel.end.x]
  486.     @@: mov     ebx,edi
  487.         stosd
  488. ;       add     esi,eax
  489.         mov     ecx,eax
  490.         jecxz   @f
  491.         rep     movsb
  492.         sub     eax,[sel.end.x]
  493.         jz      @f
  494.         neg     eax
  495.         mov     ecx,eax
  496.         add     [ebx],eax
  497.         mov     al,' '
  498.         rep     stosb
  499.     @@: sub     edi,[copy_buf] ;! AREA_CBUF
  500.         mov     [copy_size],edi
  501.         mov     eax,[sel.end.y]
  502.         sub     eax,[sel.begin.y]
  503.         inc     eax
  504.         mov     [copy_count],eax
  505.   .exit:
  506.         ret
  507.  
  508.   .single_line:
  509.         mov     eax,[sel.end.x]
  510.         sub     eax,[sel.begin.x]
  511.         mov     edi,[copy_buf] ;! AREA_CBUF
  512.         stosd
  513.         mov     ecx,[sel.begin.y]
  514.         call    get_line_offset
  515.         mov     ebx,[sel.begin.x]
  516.         mov     ecx,[sel.end.x]
  517.         cmp     ebx,[esi]
  518.         jge     .add_spaces
  519.         cmp     ecx,[esi]
  520.         jle     .lp1
  521.         mov     ecx,[esi]
  522.   .lp1: sub     ecx,[sel.begin.x]
  523.         sub     eax,ecx
  524.         lea     esi,[esi+ebx+4]
  525.         rep     movsb
  526.  
  527.   .add_spaces:
  528.         mov     ecx,eax
  529.         mov     al,' '
  530.         jecxz   @b
  531.         rep     stosb
  532.         jmp     @b
  533. endf
  534.  
  535. ;-----------------------------------------------------------------------------
  536. func key.ctrl_v
  537.         cmp     [copy_size],0
  538.         je      .exit
  539.  
  540.         call    delete_selection
  541.  
  542.         mov     eax,[copy_size]
  543.         call    editor_realloc_lines
  544.  
  545.         mov     eax,[cur_editor.Lines]
  546.         mov     ebx,[cur_editor.Lines.Size]
  547.         add     ebx,[copy_size]
  548.         mov     [cur_editor.Lines.Size],ebx
  549.         call    mem.ReAlloc
  550.         mov     [cur_editor.Lines],eax
  551.  
  552.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  553.         call    get_line_offset
  554.         pushd   [esi] esi
  555.         mov     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  556.         call    line_add_spaces
  557.         add     [esp],eax                ;!!!
  558.         add     esi,eax                  ;!!!
  559.         mov     ecx,[copy_size]
  560.         sub     ecx,4
  561.         mov     edi,[cur_editor.Lines] ;! AREA_TEMP2
  562.         add     edi,[edi-4]
  563.         dec     edi
  564.         mov     eax,esi
  565.         mov     esi,edi
  566.         sub     esi,ecx
  567.         lea     ecx,[eax+4]
  568.         add     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  569.         neg     ecx
  570.         lea     ecx,[esi+ecx+1]
  571.         std
  572.         rep     movsb
  573.  
  574.         mov     ecx,[copy_count]
  575.         dec     ecx
  576.         jz      .single_line
  577.  
  578.         cld
  579.         pop     edi
  580.         add     edi,4
  581.         mov     esi,[copy_buf] ;! AREA_CBUF
  582.         lodsd
  583.  
  584.         mov     ebx,[cur_editor.Caret.X] ;! ebx,[pos.x]
  585.         add     eax,ebx
  586.         mov     [edi-4],ax
  587.         mov     byte[edi-4+2],0x0001
  588.         sub     eax,ebx
  589.         call    .check_columns
  590.         add     edi,ebx
  591.     @@: push    ecx
  592.         mov     ecx,eax
  593.         rep     movsb
  594.         lodsd
  595.         and     eax,0x0000FFFF
  596.         stosd
  597.         mov     byte[edi-4+2],0x0001
  598.         pop     ecx
  599.         loop    @b
  600.  
  601.         pop     ecx
  602.         sub     ecx,ebx
  603.         add     [edi-4],cx
  604.         call    .check_columns
  605.         mov     ecx,eax
  606.         rep     movsb
  607.  
  608.         mov     [cur_editor.Caret.X],eax ;! [pos.x],eax
  609.         mov     [cur_editor.SelStart.X],eax ;! [sel.x],eax
  610.         mov     eax,[copy_count]
  611.         dec     eax
  612.         add     [cur_editor.Caret.Y],eax ;! [pos.y],eax
  613.         add     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  614.         add     [cur_editor.Lines.Count],eax ;! [lines],eax
  615.  
  616.         call    check_inv_all
  617.         mov     [cur_editor.Modified],1 ;! [modified],1
  618.         jmp     .exit
  619.  
  620.   .single_line:
  621.         cld
  622.         pop     edi
  623.         add     edi,4
  624.         mov     esi,[copy_buf] ;! AREA_CBUF
  625.         lodsd
  626.         add     [edi-4],ax
  627.         and     dword[edi-4],not 0x00020000
  628.         or      dword[edi-4],0x00010000
  629.         call    .check_columns
  630.         add     edi,[cur_editor.Caret.X] ;! edi,[pos.x]
  631.         add     esp,4
  632.         mov     ecx,eax
  633.         rep     movsb
  634.  
  635.         add     [cur_editor.Caret.X],eax ;! [pos.x],eax
  636.         add     [cur_editor.SelStart.X],eax ;! [sel.x],eax
  637.  
  638.         call    check_inv_all
  639.         mov     [cur_editor.Modified],1 ;! [modified],1
  640.  
  641.   .exit:
  642.         ret
  643.  
  644.   .check_columns:
  645.         push    eax
  646.         movzx   eax,word[edi-4]
  647.         cmp     eax,[cur_editor.Columns.Count] ;! eax,[columns]
  648.         jbe     @f
  649.         mov     [cur_editor.Columns.Count],eax ;! [columns],eax
  650.     @@: pop     eax
  651.         ret
  652. ;        push    eax ebx esi
  653. ;        add     esi,eax
  654. ;        xor     ebx,ebx
  655. ;        neg     eax
  656. ;        jz      .lp1
  657. ;    @@: cmp     byte[esi+ebx-1],' '
  658. ;        jne     .lp1
  659. ;        dec     ebx
  660. ;        cmp     ebx,eax
  661. ;        jg      @b
  662. ;  .lp1: add     ebx,[edi-4]
  663. ;        cmp     [columns],ebx
  664. ;        jae     @f
  665. ;        mov     [columns],ebx
  666. ;    @@: pop     esi ebx eax
  667. ;        ret
  668.  
  669. endf
  670.  
  671. ;-----------------------------------------------------------------------------
  672. func key.ctrl_d ;///// INSERT SEPARATOR //////////////////////////////////////
  673. ;-----------------------------------------------------------------------------
  674.         mov     eax,94
  675.         call    editor_realloc_lines
  676.  
  677.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  678.         call    get_line_offset
  679.         mov     ebx,esi
  680.  
  681.         mov     ecx,[cur_editor.Lines.Count] ;! ecx,[lines]
  682.         call    get_line_offset
  683.         lea     edi,[esi+90+4]
  684.         lea     ecx,[esi+4]
  685.         sub     ecx,ebx
  686.         std
  687.         rep     movsb
  688.  
  689.         lea     edi,[ebx+5]
  690.         mov     word[ebx],90
  691.         mov     al,ASEPC
  692.         mov     ecx,79
  693.         cld
  694.         rep     stosb
  695.         mov     al,' '
  696.         mov     ecx,10
  697.         rep     stosb
  698.         mov     byte[ebx+4],';'
  699.  
  700.         inc     [cur_editor.Lines.Count] ;! [lines]
  701.         inc     [cur_editor.Caret.Y] ;! [pos.y]
  702.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  703.  
  704.         call    check_inv_all
  705.         mov     [cur_editor.Modified],1 ;! [modified],1
  706.  
  707.   .exit:
  708.         ret
  709. endf
  710.  
  711. ;-----------------------------------------------------------------------------
  712. func key.ctrl_y ;///// DELETE CURRENT LINE ///////////////////////////////////
  713. ;-----------------------------------------------------------------------------
  714.         mov     eax,[cur_editor.Caret.Y] ;! eax,[pos.y]
  715.         inc     eax
  716.         cmp     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  717.         jge     .exit
  718.  
  719.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  720.         call    get_line_offset
  721.         mov     edi,esi
  722.         lodsd
  723.         and     eax,0x0000FFFF
  724.         add     esi,eax
  725.         push    eax
  726.  
  727.         dec     [cur_editor.Lines.Count] ;! [lines]
  728.         ;mov     ecx,[temp_buf] ;! AREA_TEMP2
  729.         mov     ecx,[cur_editor.Lines]
  730.         add     ecx,[ecx-4]
  731.         sub     ecx,esi
  732.         shr     ecx,2                  ;// fixed (was 4)
  733.         cld
  734.         rep     movsd
  735.  
  736.         pop     eax
  737.         add     eax,4
  738.         neg     eax
  739.         call    editor_realloc_lines
  740.  
  741.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X]
  742.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
  743.  
  744.         call    check_inv_all
  745.         mov     [cur_editor.Modified],1 ;! [modified],1
  746.  
  747.   .exit:
  748.         ret
  749. endf
  750.  
  751. ;-----------------------------------------------------------------------------
  752. func key.up ;///// GO TO PREVIOUS LINE ///////////////////////////////////////
  753. ;-----------------------------------------------------------------------------
  754.         call    clear_selection
  755.  
  756. ;-----------------------------------------------------------------------------
  757.      key.shift_up: ;///// GO TO PREVIOUS LINE, WITH SELECTION ////////////////
  758. ;-----------------------------------------------------------------------------
  759.         mov     eax,[cur_editor.Caret.Y] ;! eax,[pos.y]
  760.         dec     eax
  761.         jns     @f
  762.         xor     eax,eax
  763.     @@: mov     ecx,[cur_editor.TopLeft.Y] ;! ecx,[top_line]
  764.         cmp     eax,ecx
  765.         jae     @f
  766.         dec     ecx
  767.         jns     @f
  768.         xor     ecx,ecx
  769.     @@: test    byte[shi+2],0x01
  770.         jnz     @f
  771.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  772.     @@: call    check_inv_all.skip_init
  773.  
  774.   .exit:
  775.         ret
  776. endf
  777.  
  778. ;-----------------------------------------------------------------------------
  779. func key.down ;///// GO TO NEXT LINE /////////////////////////////////////////
  780. ;-----------------------------------------------------------------------------
  781.         call    clear_selection
  782.  
  783. ;-----------------------------------------------------------------------------
  784.      key.shift_down: ;///// GO TO NEXT LINE, WITH SELECTION //////////////////
  785. ;-----------------------------------------------------------------------------
  786.  
  787.         mov     eax,[cur_editor.Caret.Y] ;! eax,[pos.y]
  788.         inc     eax
  789.         cmp     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  790.         jb      @f
  791.         dec     eax
  792.     @@: mov     ecx,[cur_editor.TopLeft.Y] ;! ecx,[top_line]
  793.         mov     edx,eax
  794.         sub     edx,ecx
  795.         cmp     edx,[lines.scr]
  796.         jb      @f
  797.         inc     ecx
  798.     @@: test    byte[shi+2],0x01
  799.         jnz     @f
  800.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  801.     @@: call    check_inv_all.skip_init
  802.  
  803.   .exit:
  804.         ret
  805. endf
  806.  
  807. ;-----------------------------------------------------------------------------
  808. func key.left ;///// GO TO PREVIOUS CHAR /////////////////////////////////////
  809. ;-----------------------------------------------------------------------------
  810.         call    clear_selection
  811.  
  812. ;-----------------------------------------------------------------------------
  813.      key.shift_left: ;///// GO TO PREVIOUS CHAR, WITH SELECTION //////////////
  814. ;-----------------------------------------------------------------------------
  815.         mov     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  816.         dec     eax
  817.         jns     @f
  818.         inc     eax
  819.     @@: test    byte[shi+2],0x01
  820.         jnz     @f
  821.         mov     [cur_editor.SelStart.X],eax ;! [sel.x],eax
  822.     @@: mov     [cur_editor.Caret.X],eax ;! [pos.x],eax
  823.         call     check_inv_all
  824.  
  825.   .exit:
  826.         ret
  827. endf
  828.  
  829. ;-----------------------------------------------------------------------------
  830. func key.right ;///// GO TO NEXT CHAR ////////////////////////////////////////
  831. ;-----------------------------------------------------------------------------
  832.         call    clear_selection
  833.  
  834. ;-----------------------------------------------------------------------------
  835.      key.shift_right: ;///// GO TO NEXT CHAR, WITH SELECTION /////////////////
  836. ;-----------------------------------------------------------------------------
  837.         mov     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  838.         inc     eax
  839.         cmp     eax,[cur_editor.Columns.Count] ;! eax,[columns]
  840.         jbe     @f
  841.         dec     eax
  842.     @@: test    byte[shi+2],0x01
  843.         jnz     @f
  844.         mov     [cur_editor.SelStart.X],eax ;! [sel.x],eax
  845.     @@: mov     [cur_editor.Caret.X],eax ;! [pos.x],eax
  846.         call    check_inv_all
  847.  
  848.   .exit:
  849.         ret
  850. endf
  851.  
  852. ;-----------------------------------------------------------------------------
  853. func key.pgup ;///// GO TO PREVIOUS PAGE /////////////////////////////////////
  854. ;-----------------------------------------------------------------------------
  855.         call    clear_selection
  856.  
  857. ;-----------------------------------------------------------------------------
  858.      key.shift_pgup: ;///// GO TO PREVIOUS PAGE, WITH SELECTION //////////////
  859. ;-----------------------------------------------------------------------------
  860.         mov     edx,[lines.scr]
  861.         dec     edx
  862.         mov     eax,[cur_editor.Caret.Y] ;! eax,[pos.y]
  863.         mov     ecx,[cur_editor.TopLeft.Y] ;! ecx,[top_line]
  864.         sub     eax,edx
  865.         jns     @f
  866.         xor     eax,eax
  867.     @@: sub     ecx,edx
  868.         jns     @f
  869.         xor     ecx,ecx
  870.     @@: test    byte[shi+2],0x01
  871.         jnz     @f
  872.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  873.     @@: call    check_inv_all.skip_init
  874.  
  875.   .exit:
  876.         ret
  877. endf
  878.  
  879. ;-----------------------------------------------------------------------------
  880. func key.pgdn ;///// GO TO NEXT PAGE /////////////////////////////////////////
  881. ;-----------------------------------------------------------------------------
  882.         call    clear_selection
  883.  
  884. ;-----------------------------------------------------------------------------
  885.      key.shift_pgdn: ;///// GO TO NEXT PAGE, WITH SELECTION //////////////////
  886. ;-----------------------------------------------------------------------------
  887.         mov     edx,[lines.scr]
  888.         dec     edx
  889.         mov     eax,[cur_editor.Caret.Y] ;! eax,[pos.y]
  890.         mov     ecx,[cur_editor.TopLeft.Y] ;! ecx,[top_line]
  891.         add     eax,edx
  892.         add     ecx,edx
  893.         cmp     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  894.         jb      @f
  895.         mov     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  896.         dec     eax
  897.     @@: test    byte[shi+2],0x01
  898.         jnz     @f
  899.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  900.     @@: call    check_inv_all.skip_init
  901.  
  902.   .exit:
  903.         ret
  904. endf
  905.  
  906. ;-----------------------------------------------------------------------------
  907. func key.home ;///// GO TO LINE START ////////////////////////////////////////
  908. ;-----------------------------------------------------------------------------
  909.         call    clear_selection
  910.  
  911. ;-----------------------------------------------------------------------------
  912.      key.shift_home: ;///// GO TO LINE START, WITH SELECTION /////////////////
  913. ;-----------------------------------------------------------------------------
  914.         mov     [cur_editor.Caret.X],0 ;! [pos.x],0
  915.         test    byte[shi+2],0x01
  916.         jnz     @f
  917.         mov     [cur_editor.SelStart.X],0 ;! [sel.x],0
  918.     @@: call    check_inv_all
  919.  
  920.   .exit:
  921.         ret
  922. endf
  923.  
  924. ;-----------------------------------------------------------------------------
  925. func key.end ;///// GO TO LINE END ///////////////////////////////////////////
  926. ;-----------------------------------------------------------------------------
  927.         call    clear_selection
  928.  
  929. ;-----------------------------------------------------------------------------
  930.      key.shift_end: ;///// GO TO LINE END, WITH SELECTION ////////////////////
  931. ;-----------------------------------------------------------------------------
  932.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  933.         call    get_line_offset
  934.         call    get_real_length
  935.         mov     [cur_editor.Caret.X],eax ;! [pos.x],eax
  936.         test    byte[shi+2],0x01
  937.         jnz     @f
  938.         mov     [cur_editor.SelStart.X],eax ;! [sel.x],eax
  939.     @@: call    check_inv_all
  940.  
  941.   .exit:
  942.         ret
  943. endf
  944.  
  945. ;-----------------------------------------------------------------------------
  946. func key.ctrl_home ;///// GO TO PAGE START ///////////////////////////////////
  947. ;-----------------------------------------------------------------------------
  948.         call    clear_selection
  949.  
  950. ;-----------------------------------------------------------------------------
  951.      key.shift_ctrl_home: ;///// GO TO PAGE START, WITH SELECTION ////////////
  952. ;-----------------------------------------------------------------------------
  953.         mov     eax,[cur_editor.TopLeft.Y] ;! eax,[top_line]
  954.         mov     ecx,eax
  955.         test    byte[shi+2],0x01
  956.         jnz     @f
  957.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  958.     @@: call    check_inv_all.skip_init
  959.  
  960.   .exit:
  961.         ret
  962. endf
  963.  
  964. ;-----------------------------------------------------------------------------
  965. func key.ctrl_end ;///// GO TO PAGE END //////////////////////////////////////
  966. ;-----------------------------------------------------------------------------
  967.         call    clear_selection
  968.  
  969. ;-----------------------------------------------------------------------------
  970.      key.shift_ctrl_end: ;///// GO TO PAGE END, WITH SELECTION ///////////////
  971. ;-----------------------------------------------------------------------------
  972.         mov     ecx,[cur_editor.TopLeft.Y] ;! ecx,[top_line]
  973.         mov     eax,[lines.scr]
  974.         cmp     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  975.         jle     @f
  976.         mov     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  977.     @@: add     eax,ecx
  978.         dec     eax
  979.         test    byte[shi+2],0x01
  980.         jnz     @f
  981.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  982.     @@: call    check_inv_all.skip_init
  983.  
  984.   .exit:
  985.         ret
  986. endf
  987.  
  988. ;-----------------------------------------------------------------------------
  989. func key.ctrl_pgup ;///// GO TO DOCUMENT START ///////////////////////////////
  990. ;-----------------------------------------------------------------------------
  991.         call    clear_selection
  992.  
  993. ;-----------------------------------------------------------------------------
  994.      key.shift_ctrl_pgup: ;///// GO TO DOCUMENT START, WITH SELECTION ////////
  995. ;-----------------------------------------------------------------------------
  996.         xor     eax,eax
  997.         mov     [cur_editor.TopLeft.Y],eax ;! [top_line],eax
  998.         mov     [cur_editor.Caret.Y],eax ;! [pos.y],eax
  999.         test    byte[shi+2],0x01
  1000.         jnz     @f
  1001.         mov     [cur_editor.SelStart.Y],eax ;! [sel.y],eax
  1002.     @@: call    check_inv_all.skip_check
  1003.  
  1004.   .exit:
  1005.         ret
  1006. endf
  1007.  
  1008. ;-----------------------------------------------------------------------------
  1009. func key.ctrl_pgdn ;///// GO TO DOCUMENT END /////////////////////////////////
  1010. ;-----------------------------------------------------------------------------
  1011.         call    clear_selection
  1012.  
  1013. ;-----------------------------------------------------------------------------
  1014.      key.shift_ctrl_pgdn: ;///// GO TO DOCUMENT END, WITH SELECTION //////////
  1015. ;-----------------------------------------------------------------------------
  1016.         mov     eax,[cur_editor.Lines.Count] ;! eax,[lines]    ; eax = lines in the file
  1017.         mov     [cur_editor.Caret.Y],eax ;! [pos.y],eax
  1018.         sub     eax,[lines.scr]   ; eax -= lines on the screen
  1019.         jns     @f
  1020.         xor     eax,eax
  1021.     @@: mov     [cur_editor.TopLeft.Y],eax ;! [top_line],eax
  1022.         dec     [cur_editor.Caret.Y] ;! [pos.y]
  1023.         test    byte[shi+2],0x01
  1024.         jnz     @f
  1025.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y]
  1026. ;!      push    [pos.y]
  1027. ;!      pop     [sel.y]
  1028.     @@: call    check_inv_all.skip_check
  1029.  
  1030.   .exit:
  1031.         ret
  1032. endf
  1033.  
  1034. ;-----------------------------------------------------------------------------
  1035. func key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
  1036. ;-----------------------------------------------------------------------------
  1037.         call    delete_selection
  1038.         jnc     .exit.2
  1039.  
  1040.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  1041.         call    get_line_offset
  1042.         and     dword[esi],not 0x00020000
  1043.         or      dword[esi],0x00010000
  1044.         lea     ebx,[esi+4]
  1045.         mov     ebp,esi
  1046.  
  1047.         call    get_real_length
  1048.         or      eax,eax
  1049.         je      .line_up
  1050.  
  1051.         mov     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  1052.         cmp     ecx,eax
  1053.         jae     .line_up
  1054.         lea     edi,[ebx+ecx]
  1055.         neg     ecx
  1056.         movzx   eax,word[ebp]
  1057.         add     ecx,eax;[ebp]
  1058.         repe    scasb
  1059.         je      .line_up
  1060.  
  1061.         mov     edi,ebx
  1062.         mov     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  1063.         add     edi,ecx
  1064.         lea     esi,[edi+1]
  1065.         neg     ecx
  1066.         movzx   eax,word[ebp]
  1067.         add     ecx,eax;[ebp]
  1068.         dec     ecx
  1069.         rep     movsb
  1070.         mov     byte[edi],' '
  1071.  
  1072.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  1073.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  1074.         call    check_inv_all
  1075.         mov     [cur_editor.Modified],1 ;! [modified],1
  1076.         ret
  1077.  
  1078.   .line_up:
  1079.         mov     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  1080.         dec     eax
  1081.         cmp     eax,[cur_editor.Caret.Y] ;! eax,[pos.y]
  1082.         je      .exit
  1083.         mov     edi,[temp_buf] ;! AREA_TEMP+4
  1084.         add     edi,4
  1085.         mov     esi,ebx
  1086.         mov     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  1087.         rep     movsb
  1088.         mov     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  1089.         mov     eax,[temp_buf]
  1090.         mov     [eax],ecx ;! [AREA_TEMP],ecx
  1091.         cmp     cx,[ebp]
  1092.         jbe     @f
  1093.         movzx   eax,word[ebp]
  1094.         sub     ecx,eax;[ebp]
  1095.         sub     edi,ecx
  1096.         mov     al,' '
  1097.         rep     stosb
  1098.     @@: lea     esi,[ebx+4]
  1099.         movzx   eax,word[ebp]
  1100.         add     esi,eax;[ebp]
  1101.         movzx   ecx,word[esi-4]
  1102.         mov     eax,[temp_buf]
  1103.         add     [eax],ecx ;! [AREA_TEMP],ecx
  1104.         or      dword[eax],0x00010000 ;! dword[AREA_TEMP],0x00010000
  1105.         rep     movsb
  1106.  
  1107.         mov     ecx,edi ;! [edi-AREA_TEMP]
  1108.         sub     ecx,[temp_buf]
  1109.  
  1110.         mov     esi,[temp_buf] ;! AREA_TEMP
  1111.         call    get_real_length
  1112.         cmp     eax,[cur_editor.Columns.Count] ;! eax,[columns]
  1113.         jbe     @f
  1114.         mov     [cur_editor.Columns.Count],eax ;! [columns],eax
  1115.     @@:
  1116.         push    ecx
  1117.         mov     edi,[cur_editor.Lines] ;! AREA_TEMP2
  1118.         add     edi,[edi-4]
  1119.         dec     edi
  1120.         lea     esi,[edi+8]
  1121.         sub     esi,ecx
  1122.         movzx   eax,word[ebp]
  1123.         add     esi,eax;[ebp]
  1124. ;       lea     eax,[ebp+4]
  1125. ;       add     eax,[ebp]
  1126.         movzx   eax,word[ebp]
  1127.         movzx   eax,word[ebp+eax+4]
  1128.         add     esi,eax;[eax]
  1129.         lea     ecx,[esi-4]
  1130.         sub     ecx,ebp
  1131.         std
  1132.         cmp     esi,edi
  1133.         jb      @f
  1134.         jz      .lp1
  1135.         mov     edi,ebp
  1136.         add     edi,[esp]
  1137.         lea     esi,[ebp+8]
  1138.         movzx   eax,word[esi-8]
  1139.         add     esi,eax;[esi-8]
  1140.         movzx   eax,word[esi-4]
  1141.         add     esi,eax;[esi-4]
  1142.         mov     ecx,[cur_editor.Lines] ;! AREA_TEMP2
  1143.         add     ecx,[ecx-4]
  1144.         sub     ecx,esi
  1145.         cld
  1146.     @@: rep     movsb
  1147.   .lp1: pop     ecx
  1148.         mov     esi,[temp_buf] ;! AREA_TEMP
  1149.         mov     edi,ebp
  1150.         cld
  1151.         rep     movsb
  1152.  
  1153.   .ok.dec.lines:
  1154.         dec     [cur_editor.Lines.Count] ;! [lines]
  1155.         mov     eax,[cur_editor.Lines.Count] ;! eax,[lines]
  1156.         cmp     [cur_editor.Caret.Y],eax ;! [pos.y],eax
  1157.         jb      @f
  1158.         dec     eax
  1159.         mov     [cur_editor.Caret.Y],eax ;! [pos.y],eax
  1160.     @@: m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  1161.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  1162.  
  1163.         mov     ecx,[cur_editor.Lines.Count]
  1164.         call    get_line_offset
  1165.         movzx   eax,word[esi]
  1166.         lea     esi,[esi+eax+4]
  1167.         mov     eax,[cur_editor.Lines]
  1168.         add     eax,[eax-4]
  1169.         sub     esi,eax
  1170.         lea     eax,[esi+4096]
  1171.         call    editor_realloc_lines
  1172.  
  1173.         mov     [cur_editor.Modified],1 ;! [modified],1
  1174.   .exit.2:
  1175.         call    check_inv_all
  1176.  
  1177.   .exit:
  1178.         ret
  1179. endf
  1180.  
  1181. ;-----------------------------------------------------------------------------
  1182. ; INSERT {
  1183.   key.ins:
  1184. ;// ... toggle insert/overwrite mode here ...
  1185.         xor     [ins_mode],1
  1186.         call    check_inv_str
  1187.         ret
  1188. ; INSERT }
  1189.  
  1190. ;-----------------------------------------------------------------------------
  1191. func key.bkspace ;///// DELETE PREVIOUS CHAR OR SELECTION ////////////////////
  1192. ;-----------------------------------------------------------------------------
  1193.         call    delete_selection
  1194.         jnc     key.del.exit.2
  1195.  
  1196.         mov     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1197.         dec     eax
  1198.         js      .line_up
  1199.  
  1200.         dec     [cur_editor.Caret.X] ;! [pos.x]
  1201.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  1202.         call    get_line_offset
  1203.         and     dword[esi],not 0x00020000
  1204.         or      dword[esi],0x00010000
  1205.  
  1206.         mov     ebx,eax
  1207.         call    get_real_length
  1208.         cmp     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1209.         jae     @f
  1210.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  1211.         call    check_inv_all
  1212.         mov     [cur_editor.Modified],1 ;! [modified],1
  1213.         ret
  1214.  
  1215.     @@: lea     edi,[esi+4+ebx]
  1216.         mov     ecx,ebx
  1217.         neg     ecx
  1218.         movzx   eax,word[esi]
  1219.         add     ecx,eax;[esi]
  1220.         dec     ecx
  1221.         lea     esi,[edi+1]
  1222.         cld
  1223.         rep     movsb
  1224.         mov     byte[edi],' '
  1225.  
  1226.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  1227.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  1228.         call    check_inv_str
  1229.         mov     [cur_editor.Modified],1 ;! [modified],1
  1230.         ret
  1231.  
  1232.   .line_up:
  1233.         cmp     [cur_editor.Caret.Y],0 ;! [pos.y],0
  1234.         jne     @f
  1235.         ret
  1236.     @@: mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  1237.         dec     ecx
  1238.         call    get_line_offset
  1239.         and     dword[esi],not 0x00020000
  1240.         or      dword[esi],0x00010000
  1241.  
  1242.         mov     ebp,esi
  1243.         lea     ebx,[esi+4]
  1244.         movzx   ecx,word[ebp]
  1245.     @@: cmp     byte[ebx+ecx-1],' '
  1246.         jne     @f
  1247.         dec     ecx
  1248.         jg      @b
  1249.     @@: mov     [cur_editor.Caret.X],ecx ;! [pos.x],ecx
  1250.         dec     [cur_editor.Caret.Y] ;! [pos.y]
  1251.         cld
  1252.         jmp     key.del.line_up
  1253. endf
  1254.  
  1255. ;-----------------------------------------------------------------------------
  1256. func key.tab ;///// TABULATE /////////////////////////////////////////////////
  1257. ;-----------------------------------------------------------------------------
  1258.         call    delete_selection
  1259.         mov     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1260.  
  1261.         mov     ecx,eax
  1262.         add     eax,ATABW
  1263.         and     eax,not(ATABW-1)
  1264.         push    eax ' '
  1265.         sub     eax,ecx
  1266.   .direct:
  1267.         push    eax
  1268.         call    editor_realloc_lines
  1269.         pop     eax
  1270.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  1271.         call    get_line_offset
  1272.         and     dword[esi],not 0x00020000
  1273.         or      dword[esi],0x00010000
  1274.  
  1275.         xchg    eax,ecx
  1276.  
  1277.         call    get_real_length
  1278.         cmp     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1279.         jae     @f
  1280.         mov     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1281.     @@: movzx   edx,word[esi]
  1282.         sub     edx,eax
  1283.         cmp     ecx,edx
  1284.         jl      @f
  1285.         push    eax
  1286.         mov     eax,10
  1287.         call    editor_realloc_lines
  1288.         add     esi,eax
  1289.         pop     eax
  1290.         pushad; esi ecx eax
  1291.         mov     ecx,[cur_editor.Lines] ;! AREA_TEMP2-10+1
  1292.         add     ecx,[ecx-4]
  1293.         dec     ecx
  1294.         mov     edi,ecx ;! AREA_TEMP2
  1295.         add     ecx,-10+1
  1296. ;       lea     eax,[esi+4]
  1297. ;       add     eax,[esi]
  1298.         movzx   eax,word[esi]
  1299.         lea     eax,[esi+eax+4]
  1300.         sub     ecx,eax
  1301.         lea     esi,[edi-10] ;! AREA_TEMP2-10
  1302.         std
  1303.         rep     movsb
  1304.         mov     ecx,10
  1305.         mov     al,' '
  1306.         rep     stosb
  1307.         popad;  eax ecx esi
  1308.         add     word[esi],10
  1309.         jmp     @b
  1310.     @@: lea     ebx,[esi+4]
  1311.         push    ecx
  1312. ;       lea     edi,[ebx-1]
  1313. ;       add     edi,[esi]
  1314.         movzx   edi,word[esi]
  1315.         lea     edi,[ebx+edi-1]
  1316.         mov     esi,edi
  1317.         sub     esi,ecx
  1318.         lea     ecx,[esi+1]
  1319.         sub     ecx,ebx
  1320.         sub     ecx,[cur_editor.Caret.X] ;! ecx,[pos.x]
  1321.         std
  1322.         rep     movsb
  1323.   .ok:  pop     ecx             ;*******
  1324.         pop     eax
  1325.         rep     stosb
  1326.         cld
  1327.         pop     [cur_editor.Caret.X] ;! [pos.x]
  1328.         lea     esi,[ebx-4]
  1329.         call    get_real_length
  1330.         cmp     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1331.         jae     @f
  1332.         mov     eax,[cur_editor.Caret.X] ;! eax,[pos.x]
  1333.     @@: cmp     eax,[cur_editor.Columns.Count] ;! eax,[columns]
  1334.         jbe     @f
  1335.         mov     [cur_editor.Columns.Count],eax ;! [columns],eax
  1336.     @@: m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  1337.         m2m     [cur_editor.SelStart.Y],[cur_editor.Caret.Y] ;! [sel.y],[pos.y]
  1338.         call    check_inv_all
  1339.         mov     [cur_editor.Modified],1 ;! [modified],1
  1340.  
  1341.   .exit:
  1342.         ret
  1343. endf
  1344.  
  1345. ;-----------------------------------------------------------------------------
  1346. func key.return ;///// CARRIAGE RETURN ///////////////////////////////////////
  1347. ;-----------------------------------------------------------------------------
  1348.         call    delete_selection
  1349.  
  1350.         mov     eax,14
  1351.         call    editor_realloc_lines
  1352.  
  1353.         mov     ecx,[cur_editor.Caret.Y] ;! ecx,[pos.y]
  1354.         call    get_line_offset
  1355.  
  1356.         mov     ebx,[cur_editor.Caret.X] ;! ebx,[pos.x]
  1357.         cmp     bx,[esi]
  1358.         jb      @f
  1359.         movzx   ebx,word[esi]
  1360.         dec     ebx
  1361.         jns     @f
  1362.         xor     ebx,ebx
  1363.     @@:
  1364.         cld
  1365.  
  1366.         mov     edi,[temp_buf] ;! AREA_TEMP
  1367.         mov     ebp,esi
  1368.         lea     ecx,[ebx+1]
  1369.     @@: dec     ecx
  1370.         jz      @f
  1371.         cmp     byte[esi+ecx+4-1],' '
  1372.         je      @b
  1373.     @@: lea     eax,[ecx+10]
  1374.         or      eax,0x00010000
  1375.         stosd
  1376.         jecxz   @f
  1377.         push    esi
  1378.         add     esi,4
  1379.         rep     movsb
  1380.         pop     esi
  1381.     @@: mov     al,' '
  1382.         mov     ecx,10
  1383.         rep     stosb
  1384.  
  1385.         movzx   ecx,word[esi]
  1386.         sub     ecx,ebx;[pos.x]
  1387.         add     esi,ebx;[pos.x]
  1388.         add     esi,4
  1389.         inc     ecx
  1390.     @@: dec     ecx
  1391.         jz      @f
  1392.         cmp     byte[esi+ecx-1],' '
  1393.         je      @b
  1394.     @@: jz      .lp1
  1395.     @@: cmp     byte[esi],' '
  1396.         jne     .lp1
  1397.         inc     esi
  1398.         loop    @b
  1399.   .lp1: test    [options],OPTS_AUTOINDENT
  1400.         jz      .lp2
  1401.         push    edi ecx
  1402.         movzx   ecx,word[ebp]
  1403.         lea     edi,[ebp+4]
  1404.         mov     al,' '
  1405.         repe    scasb
  1406.         mov     eax,ecx
  1407.         pop     ecx edi
  1408.         je      .lp2
  1409.         neg     eax
  1410.         movzx   edx,word[ebp]
  1411.         add     eax,edx;[ebp]
  1412.         dec     eax
  1413.         jmp     @f
  1414.   .lp2: xor     eax,eax
  1415.     @@: mov     edx,edi
  1416.         add     edi,4
  1417.         mov     [cur_editor.Caret.X],eax ;! [pos.x],eax
  1418.         jecxz   @f
  1419.         push    ecx
  1420.         mov     ecx,eax
  1421.         mov     al,' '
  1422.         rep     stosb
  1423.         pop     ecx
  1424.     @@: jecxz   @f
  1425.         rep     movsb
  1426.     @@: mov     ecx,10
  1427.         mov     al,' '
  1428.         rep     stosb
  1429.  
  1430.         lea     eax,[edi-4]
  1431.         sub     eax,edx
  1432.         or      eax,0x00010000
  1433.         mov     [edx],eax
  1434.  
  1435.         mov     ecx,edi ;! [edi-AREA_TEMP]
  1436.         sub     ecx,[temp_buf]
  1437.  
  1438.         push    ecx
  1439.         mov     edi,[cur_editor.Lines] ;! AREA_TEMP2
  1440.         add     edi,[edi-4]
  1441.         dec     edi
  1442.         lea     esi,[edi+4]
  1443.         sub     esi,ecx
  1444.         movzx   ecx,word[ebp]
  1445.         add     esi,ecx;[ebp]
  1446.         lea     ecx,[esi-4]
  1447.         sub     ecx,ebp
  1448.         std
  1449.         cmp     esi,edi
  1450.         jb      @f
  1451.         je      .lp3
  1452.         lea     esi,[ebp+4]
  1453.         mov     eax,[esp]
  1454.         lea     edi,[esi+eax-4]
  1455.         movzx   ecx,word[ebp]
  1456.         add     esi,ecx;[ebp]
  1457.         mov     ecx,[cur_editor.Lines] ;! AREA_TEMP2
  1458.         add     ecx,[ecx-4]
  1459.         sub     ecx,esi
  1460.         cld
  1461.     @@: rep     movsb
  1462.   .lp3: pop     ecx
  1463.         mov     esi,[temp_buf] ;! AREA_TEMP
  1464.         mov     edi,ebp
  1465.         cld
  1466.         rep     movsb
  1467.  
  1468.         inc     [cur_editor.Caret.Y] ;! [pos.y]
  1469.         inc     [cur_editor.SelStart.Y] ;! [sel.y]
  1470.         inc     [cur_editor.Lines.Count] ;! [lines]
  1471.  
  1472.         m2m     [cur_editor.SelStart.X],[cur_editor.Caret.X] ;! [sel.x],[pos.x]
  1473.  
  1474.         call    check_inv_all
  1475.         mov     [cur_editor.Modified],1 ;! [modified],1
  1476.  
  1477.   .exit:
  1478.         ret
  1479. endf
  1480.  
  1481. ;-----------------------------------------------------------------------------
  1482. func key.ctrl_tab ;///// SWITCH TO NEXT TAB //////////////////////////////////
  1483. ;-----------------------------------------------------------------------------
  1484.         cmp     [tab_bar.Items.Count],1
  1485.         je      .exit
  1486.         xor     eax,eax
  1487.         mov     ebp,[tab_bar.Items]
  1488.     @@: cmp     ebp,[tab_bar.Current.Ptr]
  1489.         je      @f
  1490.         inc     eax
  1491.         add     ebp,sizeof.TABITEM
  1492.         jmp     @b
  1493.     @@: add     ebp,sizeof.TABITEM
  1494.         inc     eax
  1495.         cmp     eax,[tab_bar.Items.Count]
  1496.         jb      @f
  1497.         mov     ebp,[tab_bar.Items]
  1498.     @@: call    set_cur_tab
  1499.         call    make_tab_visible
  1500.         call    align_editor_in_tab
  1501.         call    draw_editor
  1502.         call    draw_tabctl
  1503.   .exit:
  1504.         ret
  1505. endf
  1506.  
  1507. ;-----------------------------------------------------------------------------
  1508. func key.shift_ctrl_tab ;///// SWITCH TO PREVIOUS TAB ////////////////////////
  1509. ;-----------------------------------------------------------------------------
  1510.         cmp     [tab_bar.Items.Count],1
  1511.         je      .exit
  1512.         xor     eax,eax
  1513.         mov     ebp,[tab_bar.Items]
  1514.     @@: cmp     ebp,[tab_bar.Current.Ptr]
  1515.         je      @f
  1516.         inc     eax
  1517.         add     ebp,sizeof.TABITEM
  1518.         jmp     @b
  1519.     @@: add     ebp,-sizeof.TABITEM
  1520.         dec     eax
  1521.         jge     @f
  1522.         imul    eax,[tab_bar.Items.Count],sizeof.TABITEM
  1523.         add     eax,[tab_bar.Items]
  1524.         lea     ebp,[eax-sizeof.TABITEM]
  1525.     @@: call    set_cur_tab
  1526.         call    make_tab_visible
  1527.         call    align_editor_in_tab
  1528.         call    draw_editor
  1529.         call    draw_tabctl
  1530.   .exit:
  1531.         ret
  1532. endf
  1533.  
  1534. ;-----------------------------------------------------------------------------
  1535. func key.ctrl_f4 ;///// CLOSE CURRENT TAB ////////////////////////////////////
  1536. ;-----------------------------------------------------------------------------
  1537.         mov     ebp,[tab_bar.Current.Ptr]
  1538.         call    delete_tab
  1539.         cmp     [tab_bar.Items.Count],0
  1540.         jne     @f
  1541.         call    create_tab
  1542.     @@: ret
  1543. endf
  1544.  
  1545. ;-----------------------------------------------------------------------------
  1546. func key.shift_f9 ;///// SET DEFAULT TAB /////////////////////////////////////
  1547. ;-----------------------------------------------------------------------------
  1548.         mov     eax,[tab_bar.Current.Ptr]
  1549.         cmp     eax,[tab_bar.Default.Ptr]
  1550.         jne     @f
  1551.         xor     eax,eax
  1552.     @@: mov     [tab_bar.Default.Ptr],eax
  1553.         mov     ebp,[tab_bar.Current.Ptr]
  1554.         call    make_tab_visible
  1555.         cmp     [tab_bar.Style],2
  1556.         jbe     @f
  1557.         call    align_editor_in_tab
  1558.         call    draw_editor
  1559.     @@: call    draw_tabctl
  1560.         ret
  1561. endf
  1562.