From: Chris Allegretta Date: Thu, 3 Sep 2009 02:48:35 +0000 (+0000) Subject: Fix regular scrolling with softwrap enabled too. Stop trying to be clever and just X-Git-Tag: v2.1.11~5 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5687c3dfa6d9f31aaf02d268112a1563a4d778bc;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index 70158adf..16107fe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 2009-08-29 Chris Allegretta - * Fix more soft wrapping issues, particularly with soft scrolling, + * Fix more soft wrapping issues, particularly with scrolling, discovered by Hannes . 2009-08-19 Chris Allegretta diff --git a/src/winio.c b/src/winio.c index 3835601a..8c60c062 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2939,26 +2939,32 @@ void edit_scroll(scroll_dir direction, ssize_t nlines) if (nlines < 1) return; - if (need_vertical_update(0) || ISSET(SOFTWRAP) && strlen(openfile->edittop->data) / (COLS - 1) > 1) + if (need_vertical_update(0)) do_redraw = TRUE; /* If using soft wrapping, we want to scroll down enough to display the entire next line, if possible... */ - if (ISSET(SOFTWRAP)) { + if (ISSET(SOFTWRAP) && direction == DOWN_DIR) { #ifdef DEBUG fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n"); #endif - for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) - i -= strlenpt(foo->data) / (COLS - 1); + for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) { + ssize_t len = strlenpt(foo->data) / (COLS - 1); + if (len > 0) + do_redraw = TRUE; + i -= len; + } if (foo) { extracuzsoft += strlenpt(foo->data) / (COLS - 1); #ifdef DEBUG fprintf(stderr, "Setting extracuzsoft to %zd due to strlen %zd of line %zd\n", extracuzsoft, strlenpt(foo->data), foo->lineno); #endif + + /* 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; #ifdef DEBUG fprintf(stderr, "Edittop adjustment, setting nlines to %zd\n", nlines); @@ -2968,9 +2974,15 @@ void edit_scroll(scroll_dir direction, ssize_t nlines) 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 * text of the edit window. */