mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-30 00:23:28 +03:00
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.
This commit is contained in:
parent
e52d5b0672
commit
c0fa3f04b1
13
src/winio.c
13
src/winio.c
@ -2908,6 +2908,15 @@ void edit_scroll(scroll_dir direction, int nrows)
|
||||
* otherwise. */
|
||||
bool current_is_above_screen(void)
|
||||
{
|
||||
#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);
|
||||
}
|
||||
|
||||
@ -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 &&
|
||||
|
Loading…
Reference in New Issue
Block a user