Subversion Repositories Kolibri OS

Rev

Rev 987 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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