nano

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

commit c0fa3f04b1f32e5c7b5e996eb9a78f777acc2edb
parent e52d5b0672b318dfcd99ff99e11a49a1f3527670
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Sat, 21 Jan 2017 11:18:17 -0600

softwrap: account for firstcolumn when checking for offscreen current

Make current_is_above_screen() check for current[current_x] being above
edittop at column firstcolumn, and make current_is_below_screen() start
counting down from edittop at column firstcolumn instead of edittop at
column zero.  This means that both functions now account for softwrapped
chunks properly.

Diffstat:
Msrc/winio.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -2908,7 +2908,16 @@ void edit_scroll(scroll_dir direction, int nrows) * otherwise. */ bool current_is_above_screen(void) { - return (openfile->current->lineno < openfile->edittop->lineno); +#ifndef NANO_TINY + if (ISSET(SOFTWRAP)) + /* The cursor is above screen when current[current_x] is before edittop + * at column firstcolumn. */ + return (openfile->current->lineno < openfile->edittop->lineno || + (openfile->current->lineno == openfile->edittop->lineno && + xplustabs() < openfile->firstcolumn)); + else +#endif + return (openfile->current->lineno < openfile->edittop->lineno); } /* Return TRUE if current[current_x] is below the bottom of the screen, and @@ -2918,10 +2927,10 @@ bool current_is_below_screen(void) #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { filestruct *line = openfile->edittop; - size_t leftedge = 0; + size_t leftedge = openfile->firstcolumn; /* If current[current_x] is more than a screen's worth of lines after - * edittop, it's below the screen. */ + * edittop at column firstcolumn, it's below the screen. */ return (go_forward_chunks(editwinrows - 1, &line, &leftedge) == 0 && (line->lineno < openfile->current->lineno || (line->lineno == openfile->current->lineno &&