Add DLR's fixes to the wrapping behavior

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1282 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2002-09-21 02:19:45 +00:00
parent 079b5495c8
commit 81dea02ca7
2 changed files with 15 additions and 10 deletions

View File

@ -95,7 +95,7 @@ CVS code -
characters on the line is exactly one over the limit. (David characters on the line is exactly one over the limit. (David
Benbennick) Benbennick)
- Restore the previous wrapping point behavior (pre 1.1.10) - Restore the previous wrapping point behavior (pre 1.1.10)
(David Benbennick). (David Benbennick, fixes by DLR).
do_alt_speller() do_alt_speller()
- Readd DLR's fix to preserve marking when using the alternate - Readd DLR's fix to preserve marking when using the alternate
spell checker; it was accidentally dropped. (David spell checker; it was accidentally dropped. (David

23
nano.c
View File

@ -1479,13 +1479,13 @@ int do_wrap(filestruct *inptr)
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
/* indentation comes from the next line if wrapping, else from /* Indentation comes from the next line if wrapping, else from
* this line */ * this line. */
indentation = (wrapping ? wrap_line : inptr->data); indentation = (wrapping ? wrap_line : inptr->data);
indent_len = indent_length(indentation); indent_len = indent_length(indentation);
if (wrapping) if (wrapping)
/* The wrap_line text should not duplicate indentation. Note /* The wrap_line text should not duplicate indentation.
* in this case we need not increase new_line_len. */ * Note in this case we need not increase new_line_len. */
wrap_line += indent_len; wrap_line += indent_len;
else else
new_line_len += indent_len; new_line_len += indent_len;
@ -1504,13 +1504,18 @@ int do_wrap(filestruct *inptr)
#endif #endif
strcat(newline, after_break); strcat(newline, after_break);
/* We end the old line after wrap_loc. Note this does not eat the /* We end the old line after wrap_loc. Note this does not eat the
space. */ * space. */
null_at(&inptr->data, wrap_loc + 1); null_at(&inptr->data, wrap_loc + 1);
totsize++; totsize++;
if (wrapping) { if (wrapping) {
/* In this case, totsize increases by 1 since we add a space /* In this case, totsize increases by 1 since we add a space
between after_break and wrap_line. */ * between after_break and wrap_line. If the line already ends
strcat(newline, " "); * in a space, we don't add a space and decrement totsize to
* account for that. */
if (newline[strlen(newline) - 1] != ' ')
strcat(newline, " ");
else
totsize--;
strcat(newline, wrap_line); strcat(newline, wrap_line);
free(inptr->next->data); free(inptr->next->data);
inptr->next->data = newline; inptr->next->data = newline;
@ -1518,7 +1523,7 @@ int do_wrap(filestruct *inptr)
filestruct *temp = (filestruct *)nmalloc(sizeof(filestruct)); filestruct *temp = (filestruct *)nmalloc(sizeof(filestruct));
/* In this case, the file size changes by +1 for the new line, and /* In this case, the file size changes by +1 for the new line, and
+indent_len for the new indentation. */ * +indent_len for the new indentation. */
#ifndef NANO_SMALL #ifndef NANO_SMALL
totsize += indent_len; totsize += indent_len;
#endif #endif
@ -1528,7 +1533,7 @@ int do_wrap(filestruct *inptr)
temp->next = inptr->next; temp->next = inptr->next;
temp->prev->next = temp; temp->prev->next = temp;
/* If !temp->next, then temp is the last line of the file, so we /* If !temp->next, then temp is the last line of the file, so we
* must set filebot */ * must set filebot. */
if (temp->next) if (temp->next)
temp->next->prev = temp; temp->next->prev = temp;
else else