bugGNU nano - Bugs: bug #49959, [Request] do softwrap at word...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #49959: [Request] do softwrap at word boundaries instead of at screen's edge

Submitter:  Nicholas Boel <accession>
Submitted:  Fri 30 Dec 2016 09:45:30 PM UTC
Votes: 7
 
Severity:  1 - Wish Status:  Fixed
Assigned to:  dolorous Open/Closed:  Closed

Jump to the original submission

Sat 22 Jul 2017 07:08:28 PM UTC, comment #15: 

The feature has been release in nano-2.8.6.

Benno Schulenberg <bens>
Group administrator
Tue 11 Jul 2017 01:45:13 PM UTC, comment #14: 

Fixed in git, commit bb4d0d54.  Feature will appear in 2.8.6 in about a week.

Benno Schulenberg <bens>
Group administrator
Wed 21 Jun 2017 09:15:47 AM UTC, comment #13: 

No need to vote.  Giving positive feedback here or on the devel list is good enough.  :)

Benno Schulenberg <bens>
Group administrator
Tue 20 Jun 2017 07:28:30 PM UTC, comment #12: 

FYI, tested more extensively after work today, utilizing the patched nano-2.8.4 as an external editor for an offline message reader and a newsgroup reader as well.

Both instances have worked flawlessly so far, and do exactly what I had originally requested. My text is much more readable now while using softwrap and using window sizes other than 80x24. Just as well, my written text is not altered in any way (nor should it be!) and will give readers themselves the ability to format it in any way it wants due to the format-flowed text.

Thanks for the patch, David!

With that said (and some more testing), is there some sort of way to vote to add this to the release version here on savannah?

Nicholas Boel <accession>
Tue 20 Jun 2017 04:42:44 PM UTC, comment #11: 

Rishabh,

Thanks for the feedback, and good to know that it's working for the most part.  Patch 0003 does say that '>' must appear on early breaking points.  However, patch 0007, which adds the AT_BLANKS flag, modifies that.

According to patch 0007's first paragraph, the '>' characters marking two-column characters at the edge of the screen are disabled when the AT_BLANKS flag is enabled.  So the code is doing exactly what it's supposed to be doing: show '>' if atblanks is unset, don't show '>' if atblanks is set.  As for why, breaking on whitespace is supposed to make nano more word-processor-like in how it displays text, so the '>' characters shouldn't be displayed then.

I suppose the wording in both patches could be made clearer, though.

David Lawrence Ramsey <dolorous>
Group Member
Tue 20 Jun 2017 04:27:41 PM UTC, comment #10: 

Posting the mail that Benno is talking about in comment #3. It is return by me as a reply to comment #3, with slight changes which is now irrelevant changes. Primarily, I came across an issue in the patch written by David.

I applied the patch to 2.8.4 and tested it with few options. Looks fine to me. But patch "0003-softwrap-change-softwrapping-to-allow-varying-chunk-.patch" in paragraph 3 mentions that '>' must appear if breaking point is before the last column. While testing I never could see it appear. So I looked for corresponding code (line 2770, src/winio.c) -

        if (!ISSET(AT_BLANKS) && to_col - from_col < editwincols) {
            mvwaddch(edit, row - 1, to_col - from_col, '>');
        }

I suppose the condition is wrong. '>' must appear when ISSET(AT_BLANKS) is true but we are testing for false. I did verify it (see attached file "just-rectify-the-if-condition.patch").

(file #40958)

Rishabh Dave <prongs>
Tue 20 Jun 2017 02:52:02 PM UTC, comment #9: 

Yes.  Hard wrapping and softwrapping are two different things: hard wrapping actually changes the text, while softwrap only appears to change the text.  They do interact, as you've seen, but if you want to enter a line long enough to be softwrapped without its being hard wrapped first, you'll generally have to shut hard wrapping off.

Good to know things are working now :)

David Lawrence Ramsey <dolorous>
Group Member
Tue 20 Jun 2017 10:35:44 AM UTC, comment #8: 

So hard wrapping is enabled by default even when softwrap is set?

To be clear, in order to get rid of hard wrapping completely I have to set both softwrap and nowrap in nanorc? That was something I had never known prior to this discussion.

When doing this, wrapping occurs where I would expect from softwrap, and I don't have to mess with "set fill" any more.

I understand why "set fill -1" does what it does now that it is specific to hardwrap. It was just confusing at the time while trying to use it with softwrap. ;)

So, it seems with:

set atblanks
set softwrap
set nowrap

.. things are looking good so far. Thanks for the patchset and the assistance in using it properly!

Nicholas Boel <accession>
Tue 20 Jun 2017 03:10:50 AM UTC, comment #7: 

Okay.  It's good that things are clearer.  If I understand your problem under the 160x48 terminal properly, I think it's another effect of hard wrapping.  Hard wrapping is enabled by default, and the fill option is set to -8 by default, so nano will wrap 8 characters from the screen edge by default.  If you don't want that, you should either toggle hard wrapping off via Meta-L, or add "set nowrap" to your nanorc.

The original problem under "set fill -1" isn't a bug so much as a corner case of hard wrapping.  With the text the way you describe it, the line gets softwrapped at exactly the screen width (the text ends one column before the screen width, and the single whitespace after it gets preserved because lines are hardwrapped after whitespace).  The blank character indicating the end of the line then gets pushed to the first column of the second row (if it didn't, it would be unreachable, and you wouldn't be able to add to the end of the line), and the next line gets pushed to the third row.

David Lawrence Ramsey <dolorous>
Group Member
Tue 20 Jun 2017 01:30:59 AM UTC, comment #6: 

That was exactly the same problem as the one I was describing. I took your advice and removed "set fill -1" from my nanorc after re-checking this. On an 80x24 screen it will wrap the last word (screen) to the next line, as I would expect.

However, I normally use a 160x48 window, and nano doesn't seem to be acting the same in both cases. With the larger window, it seems to be wrapping 8 characters from the end of the window - which is why I had originally thought it had something to do with the commented out example "set fill -8", and began changing it.

Now that I know this is not the correct thing to do, I will have to wait to see if that is some sort of action in the patchset to deal with windows larger than 80x24, or something that was possibly missed - as it does indeed go to the end of the line of any size window in the unpatched nano 2.8.4.

Nicholas Boel <accession>
Tue 20 Jun 2017 01:02:50 AM UTC, comment #5: 

Nicholas,

Good to know.  With the patchset applied, softwrap mode always wraps one column before the edge of the screen (not counting whitespace on that column).  The fill option only affects hard wrapping, and hard wrapping is turned on if "set fill -1" is in your nanorc, so it sounds like hard wrapping is interacting with softwrapping in this case.

I don't know for sure without a more specific example, though.  If you open the attached file (nicholasbug.txt) in patched nano on an 80x24 terminal, press End to go to the end of the line, and then press Space, the cursor will end up at the first column of the second row.  If you then type "x", the second row will remain blank, and the cursor will end up at the second column of the third row, just after the "x".  Is that the same problem as the one you're describing?

(file #40943)

David Lawrence Ramsey <dolorous>
Group Member
Mon 19 Jun 2017 10:35:55 PM UTC, comment #4: 

I have tried the patch set by David (softwrap-variable-width-2.zip) and have only seemed to find one issue so far.

When setting "set fill -1" in nanorc along with "set atblanks" and "set softwrap", when the current line ends in a single whitespace directly after a word ends (ie: before space is pressed), and then space is pressed before typing the next word, the cursor seems to skip a line leaving a blank line when it wraps.

I have tried the same setup with "set fill -2" and lower and can not make the same thing occur.

Aside from that, so far it seems to be doing exactly what I wanted! I'll keep at it to see if I can break anything. ;)

Thanks to everyone involved for putting some time into this!

Nicholas Boel <accession>
Mon 19 Jun 2017 06:07:48 PM UTC, comment #3: 

Nicholas, Rishabh,

Please stop sending email to just a couple of people.  Instead put your information in this bug, or reply to the patch submission on nano-devel.  Because now David has no idea that you have found something wrong in his patch, Rishabh.

As Nicholas says, leaving room for a space in the last column is to avoid having a row beginning with a space.  Calling that a matter of cosmetics is very mild: it is majorly ugly, and is even somewhat confusing, because it might be interpreted is an indentation.

Benno Schulenberg <bens>
Group administrator
Sat 17 Jun 2017 09:44:10 AM UTC, comment #2: 

Hello Nicholas and Rishabh,

There is a patch set by David that adds the ability to softwrap at whitespace.  See the zip archive attached to this message: http://lists.gnu.org/archive/html/nano-devel/2017-05/msg00017.html

Apply the seven patches to 2.8.4 (or to a branch in a git repo), compile, and then put "set atblanks" in your .nanorc, and then nano should softwrap overlong lines at whitespace -- when using --softwrap, of course.

If you can try it out and report back your findings, that would be nice.  (I have very little time these days, so I haven't yet gotten around to reviewing the patch set.)

Benno Schulenberg <bens>
Group administrator
Wed 14 Jun 2017 06:22:25 PM UTC, comment #1: 

Hello Nicholas,

I ran "nano --ignorerc --softwrap" and could never see wrapping through breaking of words. Nano always looks for whitespace closest to 72nd character and once it does that, it shifts text (from the whitespace to the end of the line) to the next line.

For example, after running above command I entered 50 'a' characters and then after 1 space character I entered 21 more 'a' characters. On the last 'a' (ie 72nd character on the line) nano shifts the last 21 'a' characters to the next line.

Or... are we talking about vim's "breakat" feature which lets breaking/wrapping at characters other than whitespace? Or are you running a different configuration or an older version? I am using 2.8.4.

Rishabh Dave <prongs>
Fri 30 Dec 2016 09:45:30 PM UTC, original submission:  

I was wondering if when using softwrap (-$) if in the future it could wrap at word boundaries rather than breaking the words up between two lines. Similar to the "set lbr" option that's usable in vimrc.

Whether this be another option to use in conjunction with softwrap or as part of the softwrap option, would be fine.

I suppose this is more of a cosmetic thing than a technical issue, but it would make using nano as an email editor or an editor for posting to newsgroups and other forms of messaging easier on the eyes while composing.

Thank you for your time and continued work on this great editor!

--
Nick

Nicholas Boel <accession>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #40943:  nicholasbug.txt added by dolorous (79B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dolorous (Updated the item)
  • -email is unavailable- added by prongs (Posted a comment)
  • -email is unavailable- added by accession (Voted in favor of this item)
  • -email is unavailable- added by pepa65 (Voted in favor of this item)
  • -email is unavailable- added by bens (Updated the item)
  • -email is unavailable- added by accession (Submitted the item)
  •  

    There are 7 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-22 bens Open/ClosedOpen Closed
    2017-07-11 bens StatusIn Progress Fixed
    2017-06-20 prongs Attached File- Added just-rectify-the-if-condition.patch, #40958
    2017-06-20 dolorous Attached File- Added nicholasbug.txt, #40943
    2017-06-19 bens StatusNone In Progress
        Assigned toNone dolorous
    2017-04-05 accession Carbon-Copy- Added accession
    2017-02-15 pepa65 Carbon-Copy- Added pepa65
    2016-12-31 bens Severity3 - Normal 1 - Wish
        Summary[Request] Softwrap at word boundaries [Request] do softwrap at word boundaries instead of at screen's edge

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code