From e393a6c345880398223538d38c8b20d95390b486 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 12 Apr 2016 13:29:51 +0200 Subject: [PATCH] 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. --- src/move.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/move.c b/src/move.c index 14c0ca07..e3d43df4 100644 --- a/src/move.c +++ b/src/move.c @@ -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); } }