screen: don't redraw the current line unnecessarily

When moving the cursor up or down one line, redraw the new current
line only when the target column (placewewant) is beyond the screen,
or when the mark is on.

(This still redraws the current and prior lines unnecessarily when
they are in fact shorter than the screen is wide and the mark is off,
but we'll let that pass for now.)

Also, when softwrap is on, we don't have have to redraw the current
and prior lines at all (when the mark is off): they are in full view,
there is nothing to show or hide.
master
Benno Schulenberg 2016-04-12 13:29:51 +02:00
parent 9d7930328b
commit e393a6c345
1 changed files with 11 additions and 18 deletions

View File

@ -401,13 +401,11 @@ void do_up(
#endif
editwinrows / 2 + 1);
/* If we're below the first line of the edit window, update the
* line we were on before and the line we're on now. The former
* needs to be redrawn if we're not on the first page, and the
* latter needs to be drawn unconditionally. */
if (openfile->current_y > 0) {
if (need_screen_update(0))
update_line(openfile->current->next, 0);
/* If we're not on the first line of the edit window, and the target
* column is beyond the screen or the mark is on, redraw the prior
* and current lines. */
if (openfile->current_y > 0 && need_screen_update(0)) {
update_line(openfile->current->next, 0);
update_line(openfile->current, openfile->current_x);
}
}
@ -498,17 +496,12 @@ void do_down(
if (ISSET(SOFTWRAP))
edit_refresh_needed = TRUE;
}
/* If we're above the last line of the edit window, update the line
* we were on before and the line we're on now. The former needs to
* be redrawn if we're not on the first page, and the latter needs
* to be drawn unconditionally. */
if (openfile->current_y < editwinrows - 1
#ifndef NANO_TINY
|| ISSET(SOFTWRAP)
#endif
) {
if (need_screen_update(0))
update_line(openfile->current->prev, 0);
/* If we're not on the last line of the edit window, and the target
* column is beyond the screen or the mark is on, redraw the prior
* and current lines. */
if (openfile->current_y < editwinrows - 1 && need_screen_update(0)) {
update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x);
}
}