screen: elide a variable and serialize some logic for clarity
Also, don't force a full refresh of the edit window simply because the current line needs to be horizontally scrolled. And further, when the adjustment of edittop has determined that a full refresh is needed, get out and don't bother scrolling some lines first.master
parent
503654e60e
commit
2246029447
19
src/winio.c
19
src/winio.c
|
@ -2853,7 +2853,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||||
{
|
{
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
filestruct *foo;
|
filestruct *foo;
|
||||||
bool do_redraw = need_screen_update(0);
|
|
||||||
|
|
||||||
assert(nlines > 0);
|
assert(nlines > 0);
|
||||||
|
|
||||||
|
@ -2880,7 +2879,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||||
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
|
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
|
||||||
i -= len;
|
i -= len;
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
do_redraw = TRUE;
|
edit_refresh_needed = TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2888,14 +2887,14 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||||
/* Limit nlines to the number of lines we could scroll. */
|
/* Limit nlines to the number of lines we could scroll. */
|
||||||
nlines -= i;
|
nlines -= i;
|
||||||
|
|
||||||
/* Don't bother scrolling zero lines or more than the number of
|
/* Don't bother scrolling zero lines, nor more than the window can hold. */
|
||||||
* lines in the edit window minus one; in both cases, get out, and
|
if (nlines == 0)
|
||||||
* call edit_refresh() beforehand if we need to. */
|
return;
|
||||||
if (nlines == 0 || do_redraw || nlines >= editwinrows) {
|
if (nlines >= editwinrows)
|
||||||
if (do_redraw || nlines >= editwinrows)
|
edit_refresh_needed = TRUE;
|
||||||
edit_refresh_needed = TRUE;
|
|
||||||
|
if (edit_refresh_needed == TRUE)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* Scroll the text of the edit window up or down nlines lines,
|
/* Scroll the text of the edit window up or down nlines lines,
|
||||||
* depending on the value of direction. */
|
* depending on the value of direction. */
|
||||||
|
@ -2943,7 +2942,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||||
for (i = nlines; i > 0 && foo != NULL; i--) {
|
for (i = nlines; i > 0 && foo != NULL; i--) {
|
||||||
if ((i == nlines && direction == DOWNWARD) || (i == 1 &&
|
if ((i == nlines && direction == DOWNWARD) || (i == 1 &&
|
||||||
direction == UPWARD)) {
|
direction == UPWARD)) {
|
||||||
if (do_redraw)
|
if (need_screen_update(0))
|
||||||
update_line(foo, (foo == openfile->current) ?
|
update_line(foo, (foo == openfile->current) ?
|
||||||
openfile->current_x : 0);
|
openfile->current_x : 0);
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue