- Clean up and simplify. (DLR)
edit_update()
- Since we no longer use TOP, remove references to it. Also,
- don't call edit_refresh() anymore: it will call us. (DLR)
+ don't call edit_refresh() anymore; it will call us. (DLR)
do_statusbar_next_word()
- Rework to be more like do_statusbar_prev_word(), to avoid a
potential problem if we start at the end of a line. (DLR)
* assume that current and current_x are up to date. */
void edit_scroll(updown direction, int nlines)
{
+ bool do_redraw = need_vertical_update(0);
const filestruct *foo;
int i;
/* If we scrolled up, we couldn't scroll up all nlines lines, and
* we're now at the top of the file, we need to draw the entire edit
- * window instead of just its top nlines lines. */
+ * window. */
if (direction == UP && i > 0 && openfile->edittop ==
openfile->fileage)
nlines = editwinrows - 2;
foo = foo->next;
}
- /* Draw new lines on the blank lines before, inside, and after the
- * scrolled region. */
- for (; nlines > 0 && foo != NULL; nlines--) {
- update_line(foo, (foo == openfile->current) ?
+ /* Draw new lines on any blank lines before or inside the scrolled
+ * region. If we scrolled down and we're on the top line, or if we
+ * scrolled up and we're on the bottom line, the line won't be
+ * blank, so we don't need to draw it unless the mark is on or we're
+ * not on the first page. */
+ for (i = nlines; i > 0 && foo != NULL; i--) {
+ if ((i == nlines && direction == DOWN) || (i == 1 &&
+ direction == UP)) {
+ if (do_redraw)
+ update_line(foo, (foo == openfile->current) ?
+ openfile->current_x : 0);
+ } else
+ update_line(foo, (foo == openfile->current) ?
openfile->current_x : 0);
foo = foo->next;
}
* updated. */
void edit_redraw(const filestruct *old_current, size_t old_pww)
{
- bool do_refresh = need_vertical_update(0) ||
+ bool do_redraw = need_vertical_update(0) ||
need_vertical_update(old_pww);
const filestruct *foo;
foo = old_current;
while (foo != openfile->current) {
- if (do_refresh)
+ if (do_redraw)
update_line(foo, 0);
#ifndef NANO_SMALL
#endif
}
- if (do_refresh)
+ if (do_redraw)
update_line(openfile->current, openfile->current_x);
}