From e52d5b0672b318dfcd99ff99e11a49a1f3527670 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sat, 21 Jan 2017 11:02:58 -0600 Subject: [PATCH] softwrap: remove and replace workarounds for firstcolumn Actually enable scrolling edittop partially off the screen by making edit_scroll() and adjust_viewport() use firstcolumn properly when iterating through softwrapped chunks in softwrap mode, or lines in non-softwrap mode. In non-softwrap mode, firstcolumn should still always be zero, because it's initially set to that, and because passing it through the iterators will maintain it at that. This fixes https://savannah.gnu.org/bugs/?49100. Reported-by: David Lawrence Ramsey --- src/winio.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/winio.c b/src/winio.c index 3123a077..8839110a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2837,10 +2837,6 @@ void edit_scroll(scroll_dir direction, int nrows) filestruct *line; size_t leftedge; - /* FIXME: This should be replaced with openfile->firstcolumn when the - * latter is added. */ - size_t firstcolumn = 0; - /* Part 1: nrows is the number of rows we're going to scroll the text of * the edit window. */ @@ -2848,18 +2844,9 @@ void edit_scroll(scroll_dir direction, int nrows) * of direction) nrows rows, or as many rows as we can if there are fewer * than nrows rows available. */ if (direction == UPWARD) - i = go_back_chunks(nrows, &openfile->edittop, &firstcolumn); + i = go_back_chunks(nrows, &openfile->edittop, &openfile->firstcolumn); else - i = go_forward_chunks(nrows, &openfile->edittop, &firstcolumn); - -#ifndef NANO_TINY - /* FIXME: nano currently can't handle a partially scrolled edittop, - * so for now: move edittop back to a full line and refresh. */ - if (ISSET(SOFTWRAP) && firstcolumn > 0) { - openfile->edittop = openfile->edittop->prev; - refresh_needed = TRUE; - } -#endif + i = go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn); /* Limit nrows to the number of rows we could scroll. */ nrows -= i; @@ -2892,7 +2879,7 @@ void edit_scroll(scroll_dir direction, int nrows) /* If we scrolled up, we're on the line before the scrolled region. */ line = openfile->edittop; - leftedge = firstcolumn; + leftedge = openfile->firstcolumn; /* If we scrolled down, move down to the line before the scrolled region. */ if (direction == DOWNWARD) @@ -3041,10 +3028,6 @@ void adjust_viewport(update_type manner) { int goal = 0; - /* FIXME: This should be replaced with openfile->firstcolumn when the - * latter is added. */ - size_t firstcolumn = 0; - /* If manner is CENTERING, move edittop half the number of window rows * back from current. If manner is FLOWING, move edittop back 0 rows * or (editwinrows - 1) rows, depending on where current has moved. @@ -3070,11 +3053,11 @@ void adjust_viewport(update_type manner) #ifndef NANO_TINY if (ISSET(SOFTWRAP)) - firstcolumn = (xplustabs() / editwincols) * editwincols; + openfile->firstcolumn = (xplustabs() / editwincols) * editwincols; #endif /* Move edittop back goal rows, starting at current[current_x]. */ - go_back_chunks(goal, &openfile->edittop, &firstcolumn); + go_back_chunks(goal, &openfile->edittop, &openfile->firstcolumn); #ifdef DEBUG fprintf(stderr, "adjust_viewport(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);