nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 9aeb9da0118a292ded7e2077517e81e78ee001a2
parent b0ae3938fa1de03f00d954c5afdd77e122b6dac6
Author: Adam Rogoyski <rogoyski@cs.utexas.edu>
Date:   Fri, 16 Jun 2000 01:19:31 +0000

Fix do_wrap() and fix_wrap() to handle empty lines, lines without spaces, and recursively call
check_wrap() for when a wrapped line needs to be wrapped when SAMELINEWRAP is set.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@20 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
Mnano.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/nano.c b/nano.c @@ -1143,6 +1143,7 @@ assert (strlenpt(inptr->data) >= fill); if (ISSET(SAMELINEWRAP)) { /* Plus one for the space which concatenates the two lines together plus 1 for \0. */ char *p = nmalloc(strlen(temp->data) + strlen(inptr->next->data) + 2); + int old_x = current_x, old_y = current_y; strcpy (p, temp->data); strcat (p, " "); @@ -1153,6 +1154,21 @@ assert (strlenpt(inptr->data) >= fill); free (temp->data); free (temp); + + + /* The next line line may need to be wrapped as well. */ + current_y = old_y + 1; + current_x = strlen(inptr->next->data); + while (current_x >= 0) { + if (isspace(inptr->next->data[current_x]) && (current_x < fill)) + break; + current_x--; + } + if (current_x >= 0) + check_wrap(inptr->next, ' '); + + current_x = old_x; + current_y = old_y; } /* Else we start a new line. */ else { @@ -1217,6 +1233,9 @@ void check_wrap(filestruct * inptr, char ch) if (!inptr->data[i]) return; + if (no_spaces(inptr->data)) + return; + do_wrap(inptr, ch); } }