Menu

#1356 Add option to set the width for the eol-is-selected rectangle

Initial
open
None
5
2021-05-18
2020-05-18
Zufu Liu
No

Currently average character width is used in EditView::DrawEOL():

// Draw the eol-is-selected rectangle
rcSegment.left = xEol + xStart + virtualSpace + blobsWidth;
rcSegment.right = rcSegment.left + vsDraw.aveCharWidth;

when vsDraw.selEOLFilled is disabled, some people feel there is an extra space on selected lines.

There are other editors (Windows Notepad) don't draw the rectangle at all, and others (Kate based LiteIDE, ICSharpCode.AvalonEdit) draw with half average character width or like.

LiteIDE

I think this can be implemented by set width in pixel or set percentage to aveCharWidth like tab width.

Related

Feature Requests: #1577

Discussion

  • Neil Hodgson

    Neil Hodgson - 2020-05-18

    There is ongoing work for EOL annotations that may conflict with this so wait until that is finished.

     
  • Zufu Liu

    Zufu Liu - 2020-06-28

    A draft implementation.

     
  • Neil Hodgson

    Neil Hodgson - 2021-05-16

    The patch relies on drawing an average character width then overdrawing part to remove some of that. It won't handle some reasonable future changes like setting the width to 150%.

    To properly emulate Visual Studio's appearance, the 'EOL-selection rectangle' should move after any fold text and the area between the text end and the fold text be treated as a spacer or left padding for the fold text.

     
    • Zufu Liu

      Zufu Liu - 2021-05-16

      Which looks for me is a complex change to draw 'EOL-selection rectangle' after fold display text like Visual Studio.

       
  • Neil Hodgson

    Neil Hodgson - 2021-05-16

    Changes that would make this area of the code simpler to evolve include:

    • Add the widths of the fold text and eol annotation to LineLayout so its easier to check for their existence and where to draw
    • This could be seen as dividing the line into 5 horizontal zones: text, optional fold, eol selected, optional annotation, remainder
    • Extract the similar background + selection drawing logic from FillLineRemainder and DrawEOL so it can be reused
     
    👍
    1

    Last edit: Neil Hodgson 2021-05-16
    • Zufu Liu

      Zufu Liu - 2021-05-18

      Add the widths of the fold text and eol annotation to LineLayout so its easier to check for their existence and where to draw

      fold text and eol annotation are rarely used (even used only a few lines will have them), adding widths for them will complicate LineLayout validating.

       

Log in to post a comment.