Subversion Repositories Kolibri OS

Rev

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