Fix regular scrolling with softwrap enabled too. Stop trying to be clever and just

figure out if we need to bail and call edit_refresh().



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4406 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2009-09-03 02:48:35 +00:00
parent 139934a236
commit 5687c3dfa6
2 changed files with 19 additions and 7 deletions

View File

@ -1,5 +1,5 @@
2009-08-29 Chris Allegretta <chrisa@asty.org> 2009-08-29 Chris Allegretta <chrisa@asty.org>
* Fix more soft wrapping issues, particularly with soft scrolling, * Fix more soft wrapping issues, particularly with scrolling,
discovered by Hannes <mr_creosote@mutantwatch.de>. discovered by Hannes <mr_creosote@mutantwatch.de>.
2009-08-19 Chris Allegretta <chrisa@asty.org> 2009-08-19 Chris Allegretta <chrisa@asty.org>

View File

@ -2939,26 +2939,32 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
if (nlines < 1) if (nlines < 1)
return; return;
if (need_vertical_update(0) || ISSET(SOFTWRAP) && strlen(openfile->edittop->data) / (COLS - 1) > 1) if (need_vertical_update(0))
do_redraw = TRUE; do_redraw = TRUE;
/* If using soft wrapping, we want to scroll down enough to display the entire next /* If using soft wrapping, we want to scroll down enough to display the entire next
line, if possible... */ line, if possible... */
if (ISSET(SOFTWRAP)) { if (ISSET(SOFTWRAP) && direction == DOWN_DIR) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n"); fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
#endif #endif
for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) {
i -= strlenpt(foo->data) / (COLS - 1); ssize_t len = strlenpt(foo->data) / (COLS - 1);
if (len > 0)
do_redraw = TRUE;
i -= len;
}
if (foo) { if (foo) {
extracuzsoft += strlenpt(foo->data) / (COLS - 1); extracuzsoft += strlenpt(foo->data) / (COLS - 1);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Setting extracuzsoft to %zd due to strlen %zd of line %zd\n", extracuzsoft, fprintf(stderr, "Setting extracuzsoft to %zd due to strlen %zd of line %zd\n", extracuzsoft,
strlenpt(foo->data), foo->lineno); strlenpt(foo->data), foo->lineno);
#endif #endif
/* Now account for whether the edittop line itself is >COLS, if scrolling down */ /* Now account for whether the edittop line itself is >COLS, if scrolling down */
for (foo = openfile->edittop; direction != UP_DIR && foo && extracuzsoft > 0; nlines++) { for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
extracuzsoft -= strlenpt(foo->data) / (COLS - 1) + 1; extracuzsoft -= strlenpt(foo->data) / (COLS - 1) + 1;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Edittop adjustment, setting nlines to %zd\n", nlines); fprintf(stderr, "Edittop adjustment, setting nlines to %zd\n", nlines);
@ -2968,8 +2974,14 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
foo = foo->next; foo = foo->next;
} }
} }
} else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
for (foo = openfile->edittop, i = editwinrows; foo && i > 0; i--, foo = foo->prev) {
if (strlenpt(foo->data) / (COLS - 1) > 0) {
do_redraw = TRUE;
break;
}
}
} }
/* Part 1: nlines is the number of lines we're going to scroll the /* Part 1: nlines is the number of lines we're going to scroll the
* text of the edit window. */ * text of the edit window. */