Subversion Repositories Kolibri OS

Rev

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