Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. ;-----------------------------------------------------------------------------
  3. func draw_editor ;///// DRAW EDITOR //////////////////////////////////////////
  4. ;-----------------------------------------------------------------------------
  5.  
  6.         mov     ebx,[cur_editor.Bounds.Left-2]
  7.         mov     bx,word[cur_editor.Bounds.Right]
  8.         sub     bx,word[cur_editor.Bounds.Left]
  9.         inc     ebx
  10.         mov     ecx,[cur_editor.Bounds.Top-2]
  11.         mov     cx,word[cur_editor.Bounds.Bottom]
  12.         sub     cx,word[cur_editor.Bounds.Top]
  13.         inc     ecx
  14.         mov     edx,[cl_3d_inset]
  15.         call    draw_framerect
  16.  
  17.         mov     [cur_editor.Gutter.Visible],0
  18.         test    [options],OPTS_LINENUMS
  19.         jnz     @f
  20.         xor     eax,eax
  21.         jmp     .lp1
  22.     @@: inc     [cur_editor.Gutter.Visible]
  23.         mov     edi,p_info+100
  24.         mov     eax,[cur_editor.Lines.Count]
  25.         mov     ecx,10
  26.         call    uint2str
  27.         lea     eax,[edi-p_info-100]
  28.         cmp     eax,3
  29.         jae     @f
  30.         mov     eax,3
  31.     @@: imul    eax,6
  32.         add     eax,8
  33.   .lp1: mov     [cur_editor.Gutter.Width],eax
  34.         mov     [left_ofs],eax
  35.  
  36.         mov     eax,[cur_editor.Bounds.Right]
  37.         sub     eax,[cur_editor.Bounds.Left]
  38.         sub     eax,[cur_editor.Gutter.Width]
  39.         sub     eax,SCRLW+LCHGW+4
  40.         js      .exit
  41.         cdq
  42.         mov     ebx,6
  43.         div     ebx
  44.         mov     [columns.scr],eax
  45.  
  46.         mov     eax,[cur_editor.Bounds.Bottom]
  47.         sub     eax,[cur_editor.Bounds.Top]
  48.  
  49.         sub     eax,SCRLW+3
  50.         js      .exit
  51.         cdq
  52.         mov     ebx,LINEH
  53.         div     ebx
  54.         mov     [lines.scr],eax
  55.  
  56.         call    draw_editor_gutter
  57.         call    draw_editor_vscroll
  58.         call    draw_editor_hscroll
  59.         call    draw_editor_text
  60.         call    draw_editor_caret
  61.  
  62.   .exit:
  63.         ret
  64. endf
  65.  
  66. ;-----------------------------------------------------------------------------
  67. func draw_editor_gutter ;///// DRAW EDITOR GUTTER (LEFT PANEL) ///////////////
  68. ;-----------------------------------------------------------------------------
  69.         cmp     [cur_editor.Gutter.Visible],0
  70.         je      .exit
  71.  
  72.         add     esp,-4*8*2
  73.  
  74.         mov     ebx,[cur_editor.Bounds.Left-2]
  75.         mov     bx,word[cur_editor.Gutter.Width]
  76.         add     ebx,0x00010000
  77.         mov     ecx,[cur_editor.Bounds.Top-2]
  78.         mov     cx,word[cur_editor.Bounds.Bottom]
  79.         sub     cx,word[cur_editor.Bounds.Top]
  80.         add     cx,-SCRLW
  81.         add     ecx,0x00010000
  82.         dec     cx
  83.         mcall   13,,,[cl_3d_normal]
  84.  
  85.         add     bx,word[cur_editor.Bounds.Left]
  86.         push    bx
  87.         shl     ebx,16
  88.         pop     bx
  89.         add     ecx,[cur_editor.Bounds.Top]
  90.         mcall   38,,,[cl_3d_inset]
  91.  
  92.         add     ebx,-2*65536
  93.         mov     bx,word[cur_editor.Bounds.Top]
  94.         add     bx,3
  95.         mov     edi,[sc.work_text]
  96.         mov     ecx,[cur_editor.TopLeft.Y]
  97.         inc     ecx
  98.         mov     edx,p_info+100
  99.     @@: pushad
  100.         push    eax edx edi
  101.         mov     eax,ecx
  102.         mov     ecx,10
  103.         mov     edi,edx
  104.         call    uint2str
  105.         mov     esi,edi
  106.         pop     edi edx eax
  107.         sub     esi,edx
  108.         imul    eax,esi,6*65536
  109.         sub     ebx,eax
  110.         mcall   4,,edi
  111.         popad
  112.         add     ebx,LINEH
  113.         inc     ecx
  114.         cmp     ecx,[cur_editor.Lines.Count]
  115.         jg      @f
  116.         mov     esi,ecx
  117.         sub     esi,[cur_editor.TopLeft.Y]
  118.         cmp     esi,[lines.scr]
  119.         jbe     @b
  120.     @@: add     esp,4*8*2
  121.  
  122.   .exit:
  123.         ret
  124. endf
  125.  
  126. ;-----------------------------------------------------------------------------
  127. func draw_editor_vscroll ;///// DRAW EDITOR VERTICAL SCROLL BAR //////////////
  128. ;-----------------------------------------------------------------------------
  129.         mov     ebx,[cur_editor.Bounds.Right]
  130.         shl     ebx,16
  131.         add     ebx,(-SCRLW)*65536+SCRLW
  132.         mov     ecx,[cur_editor.Bounds.Top-2]
  133.         mov     cx,SCRLW
  134.         cmp     [bot_mode],0
  135.         jne     @f
  136.         mcall   8,,,'VSL' or 0x40000000
  137.     @@: pushad
  138.         sar     ebx,16
  139.         sar     ecx,16
  140.         push    ebx ecx SCRLW SCRLW
  141.         call    draw_3d_panel
  142.         popad
  143.         mov     eax,8
  144.  
  145.         pushad
  146.         push    0x18
  147.         shr     ecx,16
  148.         mov     bx,cx
  149.         add     ebx,(SCRLW/2-2)*65536+SCRLW/2-3
  150.         mcall   4,,[sc.work_text],esp,1
  151.         add     esp,4
  152.         popad
  153.  
  154.         mov     ecx,[cur_editor.Bounds.Bottom]
  155.         shl     ecx,16
  156.         add     ecx,(-SCRLW*2)*65536+SCRLW
  157.         cmp     [bot_mode],0
  158.         jne     @f
  159.         mcall   ,,,'VSG' or 0x40000000
  160.     @@: pushad
  161.         sar     ebx,16
  162.         sar     ecx,16
  163.         push    ebx ecx SCRLW SCRLW
  164.         call    draw_3d_panel
  165.         popad
  166.         mov     eax,8
  167.  
  168.         pushad
  169.         push    0x19
  170.         shr     ecx,16
  171.         mov     bx,cx
  172.         add     ebx,(SCRLW/2-2)*65536+SCRLW/2-3
  173.         mcall   4,,[sc.work_text],esp,1
  174.         add     esp,4
  175.         popad
  176.  
  177.         push    ebx
  178.         mov     eax,[cur_editor.Lines.Count]
  179.         mov     ebx,[lines.scr]
  180.         mov     ecx,[cur_editor.TopLeft.Y]
  181.         mov     edx,[cur_editor.Bounds.Bottom]
  182.         sub     edx,[cur_editor.Bounds.Top]
  183.         add     edx,-SCRLW*3;+1
  184.         call    get_scroll_vars
  185.         mov     [cur_editor.VScroll.Top],eax
  186.         mov     [cur_editor.VScroll.Size],ebx
  187.         pop     ebx
  188.  
  189.         mov     ecx,eax
  190.         add     ecx,[cur_editor.Bounds.Top]
  191.         add     ecx,SCRLW+1
  192.  
  193.         pushad
  194.         sar     ebx,16
  195.         push    ebx ecx SCRLW [cur_editor.VScroll.Size]
  196.         dec     dword[esp]
  197.         call    draw_3d_panel
  198.         popad
  199.         mov     eax,13
  200.         add     ebx,1*65536-1
  201.  
  202.         mov     ecx,[cur_editor.Bounds.Top-2]
  203.         mov     cx,word[cur_editor.VScroll.Top]
  204.         add     ecx,(SCRLW+1)*65536
  205.         mov     edx,[sc.work]
  206.         or      cx,cx
  207.         jle     @f
  208.         mcall   13
  209.     @@:
  210.         mov     ecx,[cur_editor.Bounds.Top]
  211.         add     ecx,[cur_editor.VScroll.Top]
  212.         add     ecx,[cur_editor.VScroll.Size]
  213.         add     ecx,SCRLW+1
  214.         mov     di,cx
  215.         shl     ecx,16
  216.         mov     cx,word[cur_editor.Bounds.Bottom]
  217.         sub     cx,di
  218.         sub     cx,SCRLW*2;+1
  219.         jle     @f
  220.         mcall
  221.     @@:
  222.         rol     ebx,16
  223.         dec     bx
  224.         push    bx
  225.         rol     ebx,16
  226.         pop     bx
  227.         mov     ecx,[cur_editor.Bounds.Top-2]
  228.         mov     cx,word[cur_editor.Bounds.Bottom]
  229.         add     ecx,(SCRLW)*65536-SCRLW*2-1
  230.         mcall   38,,,[cl_3d_inset]
  231.  
  232.         ret
  233. endf
  234.  
  235. ;-----------------------------------------------------------------------------
  236. func draw_editor_hscroll ;///// DRAW EDITOR HORIZONTAL SCROLL BAR ////////////
  237. ;-----------------------------------------------------------------------------
  238.         mov     ebx,[cur_editor.Bounds.Left-2]
  239.         mov     bx,SCRLW
  240.         mov     ecx,[cur_editor.Bounds.Bottom]
  241.         shl     ecx,16
  242.         add     ecx,(-SCRLW)*65536+SCRLW
  243.         cmp     [bot_mode],0
  244.         jne     @f
  245.         mcall   8,,,'HSL' or 0x40000000
  246.     @@: pushad
  247.         sar     ebx,16
  248.         sar     ecx,16
  249.         push    ebx ecx SCRLW SCRLW
  250.         call    draw_3d_panel
  251.         popad
  252.  
  253.         pushad
  254.         push    0x1B
  255.         shr     ecx,16
  256.         mov     bx,cx
  257.         add     ebx,(SCRLW/2-2)*65536+SCRLW/2-3
  258.         mcall   4,,[sc.work_text],esp,1
  259.         add     esp,4
  260.         popad
  261.  
  262.         mov     ebx,[cur_editor.Bounds.Right]
  263.         shl     ebx,16
  264.         add     ebx,(-SCRLW*2)*65536+SCRLW
  265.         cmp     [bot_mode],0
  266.         jne     @f
  267.         mcall   8,,,'HSG' or 0x40000000
  268.     @@: pushad
  269.         sar     ebx,16
  270.         sar     ecx,16
  271.         push    ebx ecx SCRLW SCRLW
  272.         call    draw_3d_panel
  273.         popad
  274.  
  275.         pushad
  276.         push    0x1A
  277.         shr     ecx,16
  278.         mov     bx,cx
  279.         add     ebx,(SCRLW/2-2)*65536+SCRLW/2-3
  280.         mcall   4,,[sc.work_text],esp,1
  281.         add     esp,4
  282.         popad
  283.  
  284.         push    ecx
  285.         mov     eax,[cur_editor.Columns.Count]
  286.         mov     ebx,[columns.scr]
  287.         mov     ecx,[cur_editor.TopLeft.X]
  288.         mov     edx,[cur_editor.Bounds.Right]
  289.         sub     edx,[cur_editor.Bounds.Left]
  290.         add     edx,-(SCRLW*3)
  291.         call    get_scroll_vars
  292.         mov     [cur_editor.HScroll.Top],eax
  293.         mov     [cur_editor.HScroll.Size],ebx
  294.         pop     ecx
  295.  
  296.         mov     ebx,eax
  297.         add     ebx,[cur_editor.Bounds.Left]
  298.         add     ebx,SCRLW+1
  299.         shl     ebx,16
  300.         mov     bx,word[cur_editor.HScroll.Size]
  301.  
  302.         pushad
  303.         sar     ecx,16
  304.         rol     ebx,16
  305.         movsx   eax,bx
  306.         sar     ebx,16
  307.         dec     ebx
  308.         push    eax ecx ebx SCRLW
  309.         call    draw_3d_panel
  310.         popad
  311.         add     ecx,1*65536-1
  312.  
  313.         mov     ebx,[cur_editor.Bounds.Left-2]
  314.         mov     bx,word[cur_editor.Bounds.Left]
  315.         mov     bx,word[cur_editor.HScroll.Top]
  316.         add     ebx,(1+SCRLW)*65536
  317.         mcall   13,,,[sc.work]
  318.         mov     ebx,[cur_editor.Bounds.Left]
  319.         add     ebx,1+SCRLW
  320.         add     ebx,[cur_editor.HScroll.Top]
  321.         add     ebx,[cur_editor.HScroll.Size]
  322.         mov     di,bx
  323.         shl     ebx,16
  324.         mov     bx,word[cur_editor.Bounds.Right]
  325.         sub     bx,di
  326.         sub     bx,SCRLW*2
  327.         jle     @f
  328.         mcall
  329.     @@:
  330.         mov     ebx,[cur_editor.Bounds.Left-2]
  331.         mov     bx,word[cur_editor.Bounds.Right]
  332.         add     ebx,(SCRLW)*65536-SCRLW*2-1
  333.         rol     ecx,16
  334.         dec     cx
  335.         push    cx
  336.         rol     ecx,16
  337.         pop     cx
  338.         mcall   38,,,[cl_3d_inset]
  339.  
  340.         ret
  341. endf
  342.  
  343. ;-----------------------------------------------------------------------------
  344. func draw_editor_text.part ;///// DRAW EDITOR TEXT (PARTLY) //////////////////
  345. ;-----------------------------------------------------------------------------
  346. ; EAX = start line
  347. ; EBX = end line
  348. ;-----------------------------------------------------------------------------
  349.         cmp     [cur_editor.Lines],0
  350.         jne     @f
  351.         ret
  352.     @@: push    eax
  353.         mov     eax,[cur_editor.Bounds.Bottom]
  354.         sub     eax,[cur_editor.Bounds.Top]
  355.         cmp     eax,LINEH
  356.         pop     eax
  357.         jge     @f
  358.         ret
  359.     @@:
  360.         mov     ebp,cur_editor
  361.         call    init_sel_vars
  362.         call    check_bottom_right
  363.  
  364.         pushad
  365.  
  366.         push    eax
  367.         mov     eax,[cur_editor.Bounds.Left]
  368.         add     eax,[cur_editor.Gutter.Width]
  369.         add     eax,LCHGW+3
  370.         mov     [left_ofs],eax
  371.         mov     eax,[cur_editor.Bounds.Top]
  372.         add     eax,3
  373.         mov     [top_ofs],eax
  374.         pop     eax
  375.  
  376.         cmp     [lines.scr],0
  377.         jle     .exit
  378.  
  379.         cmp     eax,ebx
  380.         jle     @f
  381.         xchg    eax,ebx
  382.     @@: cmp     eax,[cur_editor.TopLeft.Y]
  383.         jge     @f
  384.         mov     eax,[cur_editor.TopLeft.Y]
  385.     @@: mov     ecx,[cur_editor.TopLeft.Y]
  386.         add     ecx,[lines.scr]
  387.         cmp     ebx,ecx
  388.         jl      @f
  389.         dec     ecx
  390.         mov     ebx,ecx
  391.     @@: cmp     eax,ebx
  392.         jg      .exit
  393.  
  394.         mov     ecx,eax
  395.         push    eax
  396.         call    get_line_offset
  397.  
  398.   .start:
  399.         mov     ecx,ebx
  400.         sub     ecx,eax
  401.         inc     ecx
  402.  
  403.         mov     ebx,[top_ofs]
  404.         add     ebx,[left_ofs-2]
  405.         sub     eax,[cur_editor.TopLeft.Y]
  406.         imul    eax,LINEH
  407.         add     ebx,eax
  408.  
  409.         imul    ebp,[cur_editor.TopLeft.X],6*65536
  410.         mov     [draw_blines],0
  411.  
  412.         jmp     draw_editor_text.next_line
  413.  
  414.   .exit:
  415.         popad
  416.         ret
  417. endf
  418.  
  419. ;-----------------------------------------------------------------------------
  420. func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
  421. ;-----------------------------------------------------------------------------
  422.         cmp     [cur_editor.Lines],0
  423.         jne     @f
  424.         ret
  425.     @@: mov     eax,[cur_editor.Bounds.Bottom]
  426.         sub     eax,[cur_editor.Bounds.Top]
  427.         cmp     eax,LINEH
  428.         jge     @f
  429.         ret
  430.     @@:
  431.         mov     ebp,cur_editor
  432.         call    init_sel_vars
  433.         call    check_bottom_right
  434.  
  435.         pushad
  436.  
  437.         mov     eax,[cur_editor.Bounds.Left]
  438.         add     eax,[cur_editor.Gutter.Width]
  439.         add     eax,LCHGW+3
  440.         mov     [left_ofs],eax
  441.         mov     eax,[cur_editor.Bounds.Top]
  442.         add     eax,3
  443.         mov     [top_ofs],eax
  444.  
  445.         mov     ebx,[top_ofs]
  446.         add     ebx,[left_ofs-2]
  447.  
  448.         mov     ecx,[cur_editor.TopLeft.Y]
  449.         push    ecx
  450.         call    get_line_offset
  451.  
  452.   .start:
  453.         add     esp,4
  454.         mov     ecx,[lines.scr]
  455.         or      ecx,ecx
  456.         jle     .exit
  457.         add     esp,-4
  458.  
  459.         imul    ebp,[cur_editor.TopLeft.X],6*65536
  460.         mov     [draw_blines],1
  461.  
  462.   .next_line:
  463.  
  464.         push    ecx ebx
  465.  
  466.         mov     ecx,ebx
  467.         shl     ecx,16
  468.         mov     cl,LINEH
  469.         mov     ebx,[cur_editor.Bounds.Right]
  470.         add     ebx,-SCRLW
  471.         add     ebx,[left_ofs-2]
  472.         sub     ebx,[left_ofs]
  473.         add     ebx,-2*65536+2
  474.  
  475.   ; selection (text background)
  476.         mov     [in_sel],0
  477.         mov     edx,[color_tbl.back]
  478.         mov     eax,[esp+4*2]
  479.         cmp     eax,[sel.begin.y]
  480.         jl      .lp6
  481.         je      .lp1
  482.         cmp     eax,[sel.end.y]
  483.         jg      .lp6
  484.         je      .lp3
  485.         jmp     .lp6.2
  486.   .lp1: mov     eax,[sel.begin.y]
  487.         cmp     eax,[sel.end.y]
  488.         je      .lp5
  489.   .lp2: mov     eax,[sel.begin.x]
  490.         sub     eax,[cur_editor.TopLeft.X]
  491.         jle     .lp6.2
  492.         cmp     eax,[columns.scr]
  493.         jge     .lp6
  494.         imul    eax,6
  495.         pushad
  496.         sub     bx,ax
  497.         rol     ebx,16
  498.         mov     bx,ax
  499.         add     ebx,[left_ofs]
  500.         add     ebx,-2
  501.         rol     ebx,16
  502.         mov     edx,[color_tbl.back.sel]
  503.         mcall   13
  504.         popad
  505.         mov     bx,ax
  506.         mov     [in_sel],2
  507.         jmp     .lp6
  508.   .lp3: mov     eax,[sel.begin.y]
  509.         cmp     eax,[sel.end.y]
  510.         je      .lp5
  511.   .lp4: mov     eax,[sel.end.x]
  512.         sub     eax,[cur_editor.TopLeft.X]
  513.         jle     .lp6
  514.         cmp     eax,[columns.scr]
  515.         jg      .lp6.2
  516.         imul    eax,6
  517.         pushad
  518.         sub     bx,ax
  519.         rol     ebx,16
  520.         add     eax,[left_ofs]
  521.         add     eax,-2
  522.         mov     bx,ax
  523.         rol     ebx,16
  524.         mcall   13
  525.         popad
  526.         inc     eax
  527.         mov     edx,[color_tbl.back.sel]
  528.         mov     bx,ax
  529.         mov     [in_sel],3
  530.         jmp     .lp6
  531.   .lp5: mov     eax,[cur_editor.TopLeft.X]
  532.         cmp     eax,[sel.begin.x]
  533.         jge     .lp4
  534.         add     eax,[columns.scr]
  535.         cmp     eax,[sel.end.x]
  536.         jl      .lp2
  537.         mov     eax,[sel.begin.x]
  538.         cmp     eax,[sel.end.x]
  539.         je      .lp6
  540.         sub     eax,[cur_editor.TopLeft.X]
  541.         imul    eax,6
  542.         pushad
  543.         mov     ebx,[sel.end.x]
  544.         sub     ebx,[sel.begin.x]
  545.         imul    ebx,6
  546.         sal     ebx,16
  547.         dec     eax
  548.         add     eax,[left_ofs]
  549.         mov     bx,ax
  550.         rol     ebx,16
  551.         mov     edx,[color_tbl.back.sel]
  552.         mcall   13
  553.         movzx   eax,bx
  554.         sar     ebx,16
  555.         add     eax,ebx
  556.         mov     ebx,eax
  557.         sal     ebx,16
  558.         sub     ax,[esp+4*4]
  559.         neg     ax
  560.         add     ax,word[left_ofs]
  561.         add     ax,-2
  562.         mov     bx,ax
  563.         mov     edx,[color_tbl.back]
  564.         mcall   13
  565.         popad
  566.         mov     bx,ax
  567.         mov     [in_sel],4
  568.         jmp     .lp6
  569.  
  570.   .lp6.2:
  571.         mov     edx,[color_tbl.back.sel]
  572.         inc     [in_sel]
  573.   .lp6:
  574.         mcall   13
  575.  
  576.         lodsd
  577.  
  578.         pushad
  579.         mov     edx,[color_tbl.back]
  580.         test    eax,0x00010000
  581.         jz      @f
  582.         mov     edx,[color_tbl.line.moded]
  583.         test    eax,0x00020000
  584.         jz      @f
  585.         mov     edx,[color_tbl.line.saved]
  586.     @@: mov     ebx,[left_ofs]
  587.  
  588.         add     ebx,-LCHGW-2;-4
  589.         shl     ebx,16
  590.         mov     bx,LCHGW
  591.         mcall   13
  592.         popad
  593.  
  594.         xor     ecx,ecx
  595.         and     eax,0x0000FFFF
  596.         mov     [cur_line_len],eax
  597.  
  598.         or      eax,eax
  599.         ja      .next_block
  600.         add     esp,4*2
  601.         jmp     .exit
  602.  
  603.   .next_block:
  604.  
  605.         push    esi ecx
  606.         call    .get_next_part
  607.         pop     ebx
  608.  
  609.         push    ecx
  610.         mov     ecx,eax
  611.  
  612.         push    esi ebx
  613.         mov     eax,ebx
  614.         sub     ebx,[cur_editor.TopLeft.X]
  615.         cmp     ebx,[columns.scr]
  616.         jge     .skip_t
  617.         add     ebx,esi
  618.         jle     .skip_t
  619.         mov     ebx,[esp+8+4*2] ;// 4*2=esi+ebx
  620.         sub     eax,[cur_editor.TopLeft.X]
  621.         jge     .qqq
  622.         sub     edx,eax
  623.         add     esi,eax
  624.         xor     eax,eax
  625.         jmp     .qqq2
  626.   .qqq:
  627.         imul    eax,6*65536
  628.   .qqq2:
  629.         and     ebx,0x0000FFFF
  630.         add     eax,[left_ofs-2]
  631.         add     ebx,eax
  632.  
  633.         mov     eax,[esp]   ; ebx
  634.         add     eax,[esp+4] ; esi
  635.         sub     eax,[cur_editor.TopLeft.X]
  636.         sub     eax,[columns.scr]
  637.         jle     .qweqwe
  638.         sub     esi,eax
  639.   .qweqwe:
  640.  
  641.         mov     al,[in_sel]
  642.         cmp     al,0
  643.         je      .draw_t
  644.         dec     al
  645.         jz      .ya4
  646.   .nt1: dec     al
  647.         jnz     .nt2
  648.         mov     eax,[esp]
  649.         cmp     eax,[sel.begin.x]
  650.         jge     .ya4
  651.         add     eax,[esp+4]
  652.         cmp     eax,[sel.begin.x]
  653.         jl      .draw_t
  654. ;---[ selection crosses block from the right ]-(-
  655.   .ya1: mov     eax,esi
  656.         mov     esi,[sel.begin.x]
  657.         sub     esi,[esp]
  658.         pushad
  659.         mov     ecx,[cur_editor.TopLeft.X]
  660.         sub     ecx,[esp+4*8]
  661.         jle     @f
  662.         sub     esi,ecx
  663.         sub     [esp+4],ecx
  664.     @@: sub     eax,esi
  665.         add     edx,esi
  666.         imul    esi,6
  667.         rol     ebx,16
  668.         add     bx,si
  669.         rol     ebx,16
  670.         mov     esi,eax
  671.         mov     ecx,[color_tbl.text.sel]
  672.         mcall   4
  673.         popad
  674.         jmp     .draw_t
  675. ;----------------------------------------------)-
  676.   .nt2: dec     al
  677.         jnz     .nt3
  678.         mov     eax,[esp]
  679.         cmp     eax,[sel.end.x]
  680.         jge     .draw_t
  681.         add     eax,[esp+4]
  682.         cmp     eax,[sel.end.x]
  683.         jl      .ya4
  684. ;---[ selection crosses block from the left ]--(-
  685.   .ya2: mov     eax,[sel.end.x]
  686.         sub     eax,[esp]
  687.         push    ebx
  688.         mov     ebx,[esp+4]
  689.         sub     ebx,[cur_editor.TopLeft.X]
  690.         jge     .ya2.1
  691.         add     eax,ebx
  692.   .ya2.1:
  693.         pop     ebx
  694.         pushad
  695.         mov     esi,eax
  696.         mov     ecx,[color_tbl.text.sel]
  697.         mcall   4
  698.         popad
  699.         sub     esi,eax
  700.         add     edx,eax
  701.         imul    eax,6*65536
  702.         add     ebx,eax
  703.         jmp     .draw_t
  704. ;----------------------------------------------)-
  705.   .nt3: mov     eax,[esp]
  706.         cmp     eax,[sel.end.x]
  707.         jge     .draw_t
  708.         cmp     eax,[sel.begin.x]
  709.         jge     @f
  710.         add     eax,[esp+4]
  711.         cmp     eax,[sel.begin.x]
  712.         jl      .draw_t
  713.         cmp     eax,[sel.end.x]
  714.         jl      .ya1
  715. ;---[ selection inside block ]-----------------(-
  716.         mov     eax,esi
  717.         mov     esi,[sel.begin.x]
  718.         sub     esi,[esp]
  719.         push    eax
  720.         mov     eax,[esp+4]
  721.         sub     eax,[cur_editor.TopLeft.X]
  722.         jge     .nt3.1
  723.         add     esi,eax
  724.   .nt3.1:
  725.         pop     eax
  726.         sub     eax,esi
  727.         pushad
  728.         add     edx,esi
  729.         imul    esi,6*65536
  730.         add     ebx,esi
  731.         mov     esi,[sel.end.x]
  732.         sub     esi,[sel.begin.x]
  733.         mov     ecx,[color_tbl.text.sel]
  734.         sub     eax,esi
  735.         push    eax
  736.         mcall   4
  737.         add     edx,esi
  738.         imul    esi,6*65536
  739.         add     ebx,esi
  740.         pop     esi
  741.         mov     ecx,[esp+4*6]
  742.         mcall   4
  743.         popad
  744.         jmp     .draw_t
  745. ;----------------------------------------------)-
  746.     @@: add     eax,esi
  747.         dec     eax
  748.         cmp     eax,[sel.end.x]
  749.         jge     .ya2
  750. ;---[ block inside selection ]-----------------(-
  751.   .ya4: mov     ecx,[color_tbl.text.sel]
  752. ;----------------------------------------------)-
  753.  
  754.   .draw_t:
  755.         mcall   4
  756.   .skip_t:
  757.         pop     eax eax ; ebx esi
  758.         imul    eax,6
  759.         add     [esp+4*2+2],ax
  760.         pop     ecx esi
  761.         cmp     ecx,[cur_line_len]
  762.         jl      .next_block
  763.  
  764.         pop     ebx ecx
  765.         and     ebx,0x0000FFFF
  766.         add     ebx,[left_ofs-2]
  767.         add     ebx,LINEH
  768.         add     esi,[cur_line_len]
  769.         inc     dword[esp]
  770.         dec     ecx
  771.         jg      .next_line
  772.  
  773.   .exit:
  774.  
  775.         cmp     [draw_blines],0
  776.         je      .exit.2
  777.         mov     eax,[cur_editor.Bounds.Left]
  778.         add     eax,[cur_editor.Gutter.Width]
  779.         inc     eax
  780.         mov     ebx,eax
  781.         shl     ebx,16
  782.         mov     bx,word[cur_editor.Bounds.Right]
  783.         sub     bx,ax
  784.         add     ebx,-SCRLW
  785.         mov     edx,[color_tbl.back]
  786.         mov     eax,13
  787.         mov     ecx,[esp-8]
  788.         add     ecx,LINEH
  789.         shl     ecx,16
  790.         mov     cx,word[cur_editor.Bounds.Bottom]
  791.         sub     cx,[esp-8]
  792.         add     cx,-SCRLW-LINEH
  793.         jle     @f
  794.         mcall
  795.     @@: mov     ecx,[cur_editor.Bounds.Top-2]
  796.         mov     cx,2
  797.         add     ecx,0x00010000
  798.         mcall
  799.         mov     ebx,[cur_editor.Bounds.Right]
  800.         mov     ecx,[cur_editor.Bounds.Bottom]
  801.         shl     ebx,16
  802.         shl     ecx,16
  803.         add     ebx,-(SCRLW-1)*65536+SCRLW-1
  804.         add     ecx,-(SCRLW-1)*65536+SCRLW-1
  805.         mcall
  806.  
  807.   .exit.2:
  808.         popad
  809.         add     esp,4
  810.         ret
  811. endf
  812.  
  813. ;-----------------------------------------------------------------------------
  814. func draw_editor_text.get_next_part ;/////////////////////////////////////////
  815. ;-----------------------------------------------------------------------------
  816. ; Input:
  817. ;  ECX = current letter
  818. ;  ESI = string
  819. ; Output:
  820. ;  ECX = color
  821. ;  EDX = string
  822. ;  ESI = length
  823. ;-----------------------------------------------------------------------------
  824.         cmp     [cur_editor.AsmMode],0
  825.         je      .plain.text
  826.         xor     ebx,ebx
  827.         mov     edx,ecx
  828.         add     esi,ecx
  829.         mov     edi,symbols
  830.         mov     al,[esi]
  831.         cmp     al,';'
  832.         je      .comment
  833.         mov     ecx,symbols.size
  834.         repne   scasb
  835.         je      .symbol
  836.         cmp     al,'$'
  837.         jne     @f
  838.         mov     edi,symbols
  839.         mov     al,[esi+1]
  840.         mov     ecx,symbols.size
  841.         repne   scasb
  842.         je      .not_symbol
  843.         jmp     .number
  844.     @@: cmp     al,'0'
  845.         jb      @f
  846.         cmp     al,'9'
  847.         jbe     .number
  848.     @@: cmp     al,"'"
  849.         je      .string
  850.         cmp     al,'"'
  851.         je      .string
  852.   .not_symbol:
  853.         inc     ebx
  854.         inc     edx
  855.         cmp     edx,[cur_line_len]
  856.         jge     @f
  857.         mov     edi,symbols
  858.         mov     al,[esi+ebx]
  859.         cmp     al,';'
  860.         je      @f
  861.         mov     ecx,symbols.size
  862.         repne   scasb
  863.         jne     .not_symbol
  864.     @@: mov     ecx,edx
  865.         mov     edx,esi
  866.         mov     esi,ebx
  867.         mov     eax,[color_tbl.text]
  868.         ret
  869.   .symbol:
  870.         inc     ebx
  871.         inc     edx
  872.         cmp     edx,[cur_line_len]
  873.         jge     @f
  874.         mov     edi,symbols
  875.         mov     al,[esi+ebx]
  876.         mov     ecx,symbols.size
  877.         repne   scasb
  878.         je      .symbol
  879.     @@: mov     ecx,edx
  880.         mov     edx,esi
  881.         mov     esi,ebx
  882.         mov     eax,[color_tbl.symbol]
  883.         ret
  884.   .comment:
  885.         neg     edx
  886.         add     edx,[cur_line_len]
  887.         xchg    edx,esi
  888.         mov     ecx,[cur_line_len]
  889.         mov     eax,[color_tbl.comment]
  890.         ret
  891.   .number:
  892.         inc     ebx
  893.         inc     edx
  894.         cmp     edx,[cur_line_len]
  895.         jge     @f
  896.         mov     edi,symbols
  897.         mov     al,[esi+ebx]
  898.         cmp     al,';'
  899.         je      @f
  900.         mov     ecx,symbols.size
  901.         repne   scasb
  902.         jne     .number
  903.     @@: mov     ecx,edx
  904.         mov     edx,esi
  905.         mov     esi,ebx
  906.         mov     eax,[color_tbl.number]
  907.         ret
  908.   .string:
  909.         inc     ebx
  910.         inc     edx
  911.         cmp     edx,[cur_line_len]
  912.         jge     @f
  913.         cmp     [esi+ebx],al
  914.         jne     .string
  915.         inc     ebx
  916.         inc     edx
  917.     @@:
  918.         mov     ecx,edx
  919.         mov     edx,esi
  920.         mov     esi,ebx
  921.         mov     eax,[color_tbl.string]
  922.         ret
  923.   .plain.text:
  924.         mov     edx,[cur_line_len]
  925.         xchg    edx,esi
  926.         mov     ecx,[cur_line_len]
  927.         mov     eax,[color_tbl.text]
  928.         ret
  929. endf
  930.  
  931. ;-----------------------------------------------------------------------------
  932. func draw_editor_caret ;///// DRAW EDITOR TEXT CARET /////////////////////////
  933. ;-----------------------------------------------------------------------------
  934.         cmp     [bot_mode],0
  935.         jne     @f
  936.         mov     ebx,[cur_editor.Caret.X]
  937.         sub     ebx,[cur_editor.TopLeft.X]
  938.         js      @f
  939.         cmp     ebx,[columns.scr]
  940.         ja      @f
  941.         imul    ebx,6
  942.         add     ebx,[left_ofs]
  943.         dec     ebx
  944.         push    bx
  945.         shl     ebx,16
  946.         pop     bx
  947.         mov     eax,[cur_editor.Caret.Y]
  948.         sub     eax,[cur_editor.TopLeft.Y]
  949.         js      @f
  950.         cmp     eax,[lines.scr]
  951.         jge     @f
  952.         imul    eax,LINEH
  953.         add     eax,[top_ofs]
  954.         mov     esi,eax
  955.         shl     esi,16
  956.         add     eax,LINEH-2
  957.         mov     si,ax
  958.         mov     ecx,2
  959.         cmp     [ins_mode],0
  960.         jne     .lp8
  961.         add     cl,4
  962.   .lp8: push    ecx
  963.         mcall   38,,esi,0x01000000
  964.         add     ebx,0x00010001
  965.         pop     ecx
  966.         loop    .lp8
  967.     @@:
  968.         ret
  969. endf
  970.  
  971. ;-----------------------------------------------------------------------------
  972. func editor_realloc_lines ;///// ADD $DELTA$ TO LINES SIZE ///////////////////
  973. ;-----------------------------------------------------------------------------
  974. ; EAX = delta
  975. ;-----------------------------------------------------------------------------
  976.         push    ebx ecx
  977.         mov     ebx,[cur_editor.Lines.Size]
  978.         add     ebx,eax
  979.         mov     eax,[cur_editor.Lines]
  980.         mov     [cur_editor.Lines.Size],ebx
  981.         mov     ecx,eax
  982.         call    mem.ReAlloc
  983.         mov     [cur_editor.Lines],eax
  984.         sub     eax,ecx
  985.         pop     ecx ebx
  986.         ret
  987. endf
  988.  
  989. REDRAW_TEXT      = 00000001b
  990. REDRAW_HSCROLL   = 00000010b
  991. REDRAW_VSCROLL   = 00000100b
  992. REDRAW_ONELINE   = 00001000b
  993. REDRAW_TWOLINES  = 00010000b
  994.  
  995. ;-----------------------------------------------------------------------------
  996. func editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
  997. ;-----------------------------------------------------------------------------
  998.         call    .check_cursor_visibility
  999.   .direct:
  1000.         xor     edx,edx
  1001.  
  1002.         mov     eax,[cur_editor.Lines.Count]
  1003.         cmp     eax,[checker_ed.Lines.Count]
  1004.         je      @f
  1005.         or      dl,REDRAW_TEXT+REDRAW_VSCROLL+REDRAW_HSCROLL
  1006.     @@: mov     eax,[cur_editor.TopLeft.Y]
  1007.         cmp     eax,[checker_ed.TopLeft.Y]
  1008.         je      @f
  1009.         or      dl,REDRAW_TEXT+REDRAW_VSCROLL
  1010.     @@: mov     eax,[cur_editor.TopLeft.X]
  1011.         cmp     eax,[checker_ed.TopLeft.X]
  1012.         je      @f
  1013.         or      dl,REDRAW_TEXT+REDRAW_HSCROLL
  1014.     @@: or      dl,dl
  1015.         jnz     .redraw
  1016.  
  1017.         mov     ecx,[cur_editor.Caret.Y]
  1018.         call    get_line_offset
  1019.         call    get_real_length
  1020.         cmp     eax,[checker_ed_ll]
  1021.         je      @f
  1022.         mov     [checker_ed_ll],eax
  1023.         or      dl,REDRAW_ONELINE
  1024.     @@:
  1025.         mov     eax,[cur_editor.Caret.Y]
  1026.         cmp     eax,[checker_ed.Caret.Y]
  1027.         je      @f
  1028.         or      dl,REDRAW_TWOLINES
  1029.     @@: mov     eax,[cur_editor.Caret.X]
  1030.         cmp     eax,[checker_ed.Caret.X]
  1031.         je      @f
  1032.         or      dl,REDRAW_ONELINE
  1033.     @@: mov     ebp,cur_editor
  1034.         call    init_sel_vars
  1035.         mov     al,[sel.selected]
  1036.         mov     ebp,checker_ed
  1037.         call    init_sel_vars
  1038.         cmp     al,[sel.selected]
  1039.         je      @f
  1040.         cmp     al,0
  1041.         je      .clear_sel
  1042.         jmp     .draw_sel
  1043.     @@: cmp     al,0
  1044.         jne     .redraw_sel
  1045.  
  1046.         or      dl,dl
  1047.         jz      .exit
  1048.         test    dl,REDRAW_TWOLINES
  1049.         jz      .one_line
  1050.         push    edx
  1051.         mov     eax,[checker_ed.Caret.Y]
  1052.         mov     ebx,eax
  1053.         call    draw_editor_text.part
  1054.         pop     edx
  1055.   .one_line:
  1056.         mov     eax,[cur_editor.Caret.Y]
  1057.         mov     ebx,eax
  1058.         call    draw_editor_text.part
  1059.         call    draw_editor_caret
  1060.         jmp     .exit
  1061.  
  1062.   .clear_sel:
  1063.         ;// use checker_ed
  1064.         mov     eax,[sel.begin.y]
  1065.         mov     ebx,[sel.end.y]
  1066.         push    eax ebx
  1067.         call    draw_editor_text.part
  1068.         pop     edx ecx
  1069.         mov     eax,[cur_editor.Caret.Y]
  1070.         cmp     eax,ecx
  1071.         jb      @f
  1072.         cmp     eax,edx
  1073.         jbe     .lp1
  1074.     @@: mov     ebx,eax
  1075.         call    draw_editor_text.part
  1076.   .lp1: call    draw_editor_caret
  1077.         jmp     .exit
  1078.  
  1079.   .draw_sel:
  1080.         ;// use cur_editor
  1081.         mov     ebp,cur_editor
  1082.         call    init_sel_vars
  1083.         mov     eax,[sel.begin.y]
  1084.         mov     ebx,[sel.end.y]
  1085.         push    eax ebx
  1086.         call    draw_editor_text.part
  1087.         pop     edx ecx
  1088.         mov     eax,[checker_ed.Caret.Y]
  1089.         cmp     eax,ecx
  1090.         jb      @f
  1091.         cmp     eax,edx
  1092.         jbe     .lp2
  1093.     @@: mov     ebx,eax
  1094.         call    draw_editor_text.part
  1095.   .lp2: call    draw_editor_caret
  1096.         jmp     .exit
  1097.  
  1098.   .redraw_sel:
  1099.         ;// use checker_ed and cur_editor
  1100.         mov     eax,[checker_ed.Caret.Y]
  1101.         mov     ebx,[cur_editor.Caret.Y]
  1102.         cmp     eax,ebx
  1103.         jb      @f
  1104.         xchg    eax,ebx
  1105.     @@: call    draw_editor_text.part
  1106.         call    draw_editor_caret
  1107.         jmp     .exit
  1108.  
  1109.   .redraw:
  1110.         push    edx
  1111.         call    draw_editor_gutter
  1112.         call    draw_editor_text
  1113.         call    draw_editor_caret
  1114.         test    byte[esp],REDRAW_VSCROLL
  1115.         jz      @f
  1116.         call    draw_editor_vscroll
  1117.     @@: pop     edx
  1118.         test    dl,REDRAW_HSCROLL
  1119.         jz      @f
  1120.         call    draw_editor_hscroll
  1121.     @@: jmp     .exit
  1122.  
  1123.   .exit:
  1124.         mov     esi,cur_editor
  1125.         mov     edi,checker_ed
  1126.         mov     ecx,sizeof.EDITOR/4
  1127.         cld
  1128.         rep     movsd
  1129.         ret
  1130.  
  1131.   .check_cursor_visibility:
  1132.         push    eax ebx
  1133.     .chk_y:
  1134.         mov     eax,[cur_editor.Caret.Y]
  1135.         or      eax,eax
  1136.         jge     @f
  1137.         mov     [cur_editor.Caret.Y],0
  1138.         jmp     .chk_dy
  1139.     @@: cmp     eax,[cur_editor.Lines.Count]
  1140.         jl      .chk_dy
  1141.         mov     eax,[cur_editor.Lines.Count]
  1142.         dec     eax
  1143.         mov     [cur_editor.Caret.Y],eax
  1144.     .chk_dy:
  1145.         mov     eax,[cur_editor.TopLeft.Y]
  1146.         cmp     eax,[cur_editor.Caret.Y]
  1147.         jle     @f
  1148.         m2m     [cur_editor.TopLeft.Y],[cur_editor.Caret.Y]
  1149.     @@: add     eax,[lines.scr]
  1150.         cmp     eax,[cur_editor.Caret.Y]
  1151.         jg      .chk_x
  1152.         mov     eax,[cur_editor.Caret.Y]
  1153.         sub     eax,[lines.scr]
  1154.         inc     eax
  1155.         mov     [cur_editor.TopLeft.Y],eax
  1156.     .chk_x:
  1157.         mov     eax,[cur_editor.Caret.X]
  1158.         or      eax,eax
  1159.         jge     @f
  1160.         mov     [cur_editor.Caret.X],0
  1161.         jmp     .chk_dx
  1162.     @@: cmp     eax,[cur_editor.Columns.Count]
  1163.         jl      .chk_dx
  1164.         mov     eax,[cur_editor.Columns.Count]
  1165.         mov     [cur_editor.Caret.X],eax
  1166.     .chk_dx:
  1167.         mov     eax,[cur_editor.TopLeft.X]
  1168.         cmp     eax,[cur_editor.Caret.X]
  1169.         jle     @f
  1170.         m2m     [cur_editor.TopLeft.X],[cur_editor.Caret.X]
  1171.     @@: add     eax,[columns.scr]
  1172.         cmp     eax,[cur_editor.Caret.X]
  1173.         jg      @f
  1174.         mov     eax,[cur_editor.Caret.X]
  1175.         sub     eax,[columns.scr]
  1176.         inc     eax
  1177.         mov     [cur_editor.TopLeft.X],eax
  1178.     @@: cmp     [mev],MEV_LDOWN
  1179.         jne     @f
  1180.         push    [cur_editor.Caret.X] [cur_editor.Caret.Y]
  1181.         pop     [cur_editor.SelStart.Y] [cur_editor.SelStart.X]
  1182.     @@: pop     ebx eax
  1183.         ret
  1184. endf
  1185.