Menu

#1233 wrapping: indentation-aware line-length limit

Completed
open
nobody
1
2018-09-23
2018-09-18
Vic
No

(Below, by "content" of a line i mean the part starting after the indentation.
By "subline" of a wrapped line I mean each part into which the line is broken by wrapping, excluding the Ist part).

When working with deeply nested by indentation, text/code, line wrapping is prohibitted (or else it wraps the indentation of deeply indented lines, distroying the visual structure).
And yet, if the content of the line is very long, it would benefit from wrapping to fit it within the window limits.

To solve this dillema, I suggest user-options for following features, that I have not seen in any other editor (and so could be a first by Scintilla):

Feature 1. Wrap a line when the length of content-part exceeds the window_width. (Thus not when its total length exceeds the window width).In other words:
Wrap a line when the length exceeds: window_width + length(indentation of line).
Each subline be wrapped when its length exceeds: window_width, but also take into account the extra indentation set through SCI_SETWRAPINDENTMODE: so, if that is =2 or =3, then: wrap when length exeeds: window_width minus 1 or 2, respectively.

In this way, the wrap will not distroy the indentation structure, while still wrap the content of current line within the limits of the window , provided also that SCI_SETWRAPINDENTMODE is set to value other than 0.

In addition, to be able to see more than one 1 line's content within the window width, say also the contents of the parent line, and child lines, or more, we need:

Feature 2. Replace the limit of "window_width" in Feature 1 above, with : window_width - N*indent_width, where N=1, 2, 3... (user-chosen)

Alltogether, I think it means introducing a new message/function NEWFUN(int) (maybe called SCI_SETWRAPLIMITMODE), that will control the limit (content) length at which to wrap (sub)lines.
Below extra_indent is the extra indentation set via SCI_SETWRAPINDENTMODE: value(SCI_SETWRAPSTARTINDENT), when SCI_SETWRAPINDENTMODE(0); 0, when SCI_SETWRAPINDENTMODE(1), and extra_indent =1 or =2, when SCI_SETWRAPINDENTMODE(2) or (3), respectively

  • NEWFUN(-1): (current behaviour):
    • wrap line when length exceeds window_width,
    • wrap sublines when their lengths exceed window_width - extra_indent
  • NEWFUN(N), where N=0,1,2,3...:
    • wrap line when length exceeds window_width + width(line_indentation) - N*indent_width,
    • wrap sublines when their length exceeds window_width - extra_indent - N*indent_width

While SCI_SETWRAPINDENTMODE controls the start of wrapped sublines, relative to indenation of the line (Ist subline), NEWFUN will control the length of the (sub)lines, relative to indentation and window width.

NOTE: such wrapping requires horizontal scroll bar to stay ON. You may still want to scroll manually to bring the wrapped content of other lines (further right or left) into the view area.

I will provide graphical illustrations in a reply below

Discussion

  • Vic

    Vic - 2018-09-18

    Graphical illustrations

    Assume the following text, line wrap OFF, where imagine || stands for window margin. Hence, you're only supposed to see the text within the 2 vertical columns of ||:

    a a ||a a a a a a ||a a a a a a a 
      a ||a a a a a a ||a a a a a a a a 
        ||a a a a a a ||a a a a a a a a a 
        ||  a a a a a ||a a a a a a a a a a 
        ||    a a a a ||a a a a a a a a a a a 
        ||      a a a ||a a a a a a a a a a a a 
        ||        a a ||a a a a a a a a a a a a a 
        ||          a ||a a a a a a a a a a a a a a 
        ||            ||a a a a a a a a a a a a a a a 
        ||            ||  a a a a a a a a a a a a a a a 
        ||            ||    a a a a a a a a a a a a a a 
        ||            ||  a a a a a a a a a a a a a a 
      a ||a a a a a a ||a a a a a a a 
    a a ||a a a a a a ||a a a a a a a
    

    With wrap ON, SCI_SETWRAPINDENTMODE(1) and my NEWFUN(0), the same text with the same position of window margins, should look like this. Notice now only parent content (ex - 3rd) can be fully seen in window, the child's - only partially:

    a a ||a a a a     ||
    a a ||a a a a     ||
    a a ||a           ||
      a ||a a a a a   ||
      a ||a a a a a   ||
      a ||a a         ||
        ||a a a a a a ||
        ||a a a a a a ||
        ||a a a       ||
        ||  a a a a a ||a
        ||  a a a a a ||a
        ||  a a a     ||
        ||    a a a a ||a a
        ||    a a a a ||a a
        ||    a a a   ||
        ||      a a a ||a a a
        ||      a a a ||a a a
        ||      a a a ||
        ||        a a ||a a a a
        ||        a a ||a a a a
        ||        a a ||a 
        ||          a ||a a a a a
        ||          a ||a a a a a
        ||          a ||a a 
        ||            ||a a a a a a
        ||            ||a a a a a a
        ||            ||a a a 
        ||            ||  a a a a a a
        ||            ||  a a a a a a
        ||            ||  a a a 
        ||            ||    a a a a a a
        ||            ||    a a a a a a
        ||            ||    a a a 
        ||            ||  a a a a a a 
        ||            ||  a a a a a a 
        ||            ||  a a a 
      a ||a a a a a   ||
      a ||a a a a a   ||
      a ||a a         ||
    a a ||a a a a     ||
    a a ||a a a a     ||
    a a ||a           ||
    

    With wrap ON, SCI_SETWRAPINDENTMODE(1) and my NEWFUN(2), the same text with the same position of window margins, should look like this. Notice now, 4th content is fully seen, as well as its parent (3rd) and child (5th):

    a a ||a a         ||
    a a ||a a         ||
    a a ||a a         ||
    a a ||a           ||
      a ||a a a       ||
      a ||a a a       ||
      a ||a a a       ||
      a ||a a         ||
        ||a a a a     ||
        ||a a a a     ||
        ||a a a a     ||
        ||a a a       ||
        ||  a a a a   ||
        ||  a a a a   ||
        ||  a a a a   ||
        ||  a a a     ||
        ||    a a a a ||
        ||    a a a a ||
        ||    a a a a ||
        ||    a a a   ||
        ||      a a a ||a 
        ||      a a a ||a 
        ||      a a a ||a 
        ||      a a a ||
        ||        a a ||a a 
        ||        a a ||a a 
        ||        a a ||a a 
        ||        a a ||a 
        ||          a ||a a a 
        ||          a ||a a a 
        ||          a ||a a a 
        ||          a ||a a 
        ||            ||a a a a 
        ||            ||a a a a 
        ||            ||a a a a 
        ||            ||a a a 
        ||            ||  a a a a 
        ||            ||  a a a a 
        ||            ||  a a a a 
        ||            ||  a a a 
        ||            ||    a a a a 
        ||            ||    a a a a 
        ||            ||    a a a a 
        ||            ||    a a 
        ||            ||  a a a a 
        ||            ||  a a a a 
        ||            ||  a a a a 
        ||            ||  a a 
      a ||a a a       ||
      a ||a a a       ||
      a ||a a a       ||
      a ||a           ||
    a a ||a a         ||
    a a ||a a         ||
    a a ||a a         ||
    a a ||a           ||
    

    This new function will allow comfortable navigation of nested code/text of UNLIMITTED size/depth, regardless of windown width. (For ex, with (page/arrow) up/down to get into one line, then home, end keys to bring its content fully into the window view).

    IMO, it will be one of the most important wrap-related features.

     
  • Neil Hodgson

    Neil Hodgson - 2018-09-18

    Novel features are better discussed on the mailing list as relatively few people watch the feature request tracker. For me, wrapping is a rarely used option and deeply nested code should be hard wrapped by hand or a tool like astyle.

    https://groups.google.com/group/scintilla-interest

     
    • Vic

      Vic - 2018-09-18

      deeply nested code should be hard wrapped by hand

      that's exactly why I suggest this feature: so that we don't have to wrap by hand... Also, you don't know in advance how narrow the window is going to get and when. And when the window is wide, above feature uses all of it, so you don't have to scroll up-down a lot.

      Thanks for the recommendation of the link, I will post it there too then.
      But since I've already posted it here, would you please aprove my first reply with examples, to have it complete here? I can make it shorter if that's the problem.

      Also, I just checked it out: you cannot put monospaced code there (correct me if I'm wrong). Too bad few people come here... Maybe I can just link to here, where the examples (my Ist reply, under moderation) definitely require monospaced font

       
  • Vic

    Vic - 2018-09-18

    Graphical illustrations

    (don't know when Ist reply will get approved; this is shorter version)

    Assume the following text, line wrap OFF, where imagine || stands for window margin. Hence, you're only supposed to see the text within the 2 vertical columns of ||:

    a a ||a a a a a a ||a a a a a a a 
      a ||a a a a a a ||a a a a a a a a 
        ||a a a a a a ||a a a a a a a a a 
        ||  a a a a a ||a a a a a a a a a a 
        ||    a a a a ||a a a a a a a a a a a 
        ||      a a a ||a a a a a a a a a a a a
    

    With wrap ON, SCI_SETWRAPINDENTMODE(1) and my NEWFUN(0), the same text with the same position of window margins, should look like this. Notice now only parent content (ex- 3rd) can be fully seen in window, the child's - only partially:

    a a ||a a a a     ||
    a a ||a a a a     ||
    a a ||a           ||
      a ||a a a a a   ||
      a ||a a a a a   ||
      a ||a a         ||
        ||a a a a a a ||
        ||a a a a a a ||
        ||a a a       ||
        ||  a a a a a ||a
        ||  a a a a a ||a
        ||  a a a     ||
        ||    a a a a ||a a
        ||    a a a a ||a a
        ||    a a a   ||
        ||      a a a ||a a a
        ||      a a a ||a a a
        ||      a a a ||
    

    With wrap ON, SCI_SETWRAPINDENTMODE(1) and my NEWFUN(2), the same text with the same position of window margins, should look like this. Notice now, 4th content is fully seen, as well as its parent (3rd) and child (5th):

    a a ||a a         ||
    a a ||a a         ||
    a a ||a a         ||
    a a ||a           ||
      a ||a a a       ||
      a ||a a a       ||
      a ||a a a       ||
      a ||a a         ||
        ||a a a a     ||
        ||a a a a     ||
        ||a a a a     ||
        ||a a a       ||
        ||  a a a a   ||
        ||  a a a a   ||
        ||  a a a a   ||
        ||  a a a     ||
        ||    a a a a ||
        ||    a a a a ||
        ||    a a a a ||
        ||    a a a   ||
        ||      a a a ||a 
        ||      a a a ||a 
        ||      a a a ||a 
        ||      a a a ||
    

    This new function will allow comfortable navigation of nested code/text of UNLIMITTED size/depth, regardless of windown width. (For ex, with (page/arrow)up/down to get into one content, then home, end keys to bring it fully into the window view).

     

    Last edit: Vic 2018-09-20
  • Neil Hodgson

    Neil Hodgson - 2018-09-23

    Unless there is stronger demand for this, it does not appear worth adding.

     

Log in to post a comment.

MongoDB Logo MongoDB