Subversion Repositories Kolibri OS

Rev

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