nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] do_wrap


From: David Benbennick
Subject: [Nano-devel] do_wrap
Date: Sun, 10 Mar 2002 11:55:57 -0500 (EST)

Attached is a patch for the do_wrap function of nano.c.  I have rewritten
the function, to remove some bugs and simplify it.  In particular, nano
with my patch is 1216 bytes smaller out of 106k, and with NANO_SMALL
turned on it is 1088 bytes smaller out of 42k.  The code is also 160 lines
shorter, and uses only two mallocs (a charalloc and a null_at) during
do_wrap.

First, the bugs I fixed:

1) When wrapping at a ".  ", the second space was lost.

2) The copy-mark got bolloxed on wrapping if you were typing before it.

3) Typing <Space> in the middle of a long word would wrap the cursor to
the beginning of the next line.  Then typing a <Space> again would create
a new paragraph.

4) When prepending the wrapped text to the next line (ala SAMELINEWRAP),
Nano 1.1.7 allows the next line to get too long.  Pico and my patch both
check this case.

5) Case 1b of the original do_wrap was not implemented correctly.  That
is, the comment explained what should happen, then the code did something
else.

6) The old do_wrap would sometimes strip spaces from the end of the newly
wrapped line.  The cases were complicated and arbitrary.  The new do_wrap
turns exactly one space into a \n, and keeps all others.  Thus the file
size does not increase on wrapping.  That is, typing a character increases
the size by 1 byte in all cases.

7) A related fact is that if you type a regular paragraph, it will now be
wrapped so that it doesn't change when justified.  This is since do_wrap
now doesn't keep an extra space at the end of each line.



There is one downside to my patch, namely

8) Consider the following.  You have two lines, say

aaaaaaaa aaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaa
bbbbbbbbb bbbbbbbbbbbbbb bbbbbbbbbb bbbbbbb

You put the cursor at the front of the second line, and type
<Backspace><Space><Backspace>.  In pico and nano both, the net effect is
that the two words are on one line, separated by a space.  In my patch,
this is not the case: you instead get

aaaaaaaa aaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaa
aaaaaaabbbbbbbbb bbbbbbbbbbbbbb bbbbbbbbbb bbbbbbb
       ^---- here is where the cursor ends up.

This change is a result of points 3) and 6) above.

In pico, nano, and my patch, there is a second way to get the words on one
line, namely to go to the end of the first line and type <Space><Ctrl-d>,
or <Space><Right-arrow><Backspace>.  Also, you can do Meta-w to turn off
word wrapping.

The possible problem is that people are used to the first way, and will be
annoyed if it doesn't work anymore, even if it is more logically
consistent.



So what are people's opinions?  Is point 8) too annoying, or is it easy to
get used to?  If it is too annoying, I will be happy to submit a new patch
that removes point 8) at the expense of point 3), while still fixing
the other bugs listed.



By the way, there is another independent bug fixed by my patch.  Namely,
typing before the copy-mark in nano doesn't shift the mark forward, while
in pico and my patch it does.

Attachment: nano-10mar10:57.diff.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]