nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 03b168d0e389cabb07fd25eb0e3aa10d5cd00fa5
parent 2f6647687a8bd55416efae1dbf91f1ef97dd8bc6
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Tue, 26 Jul 2016 20:06:10 +0200

tweaks: restore earlier conditions to prevent superfluous redrawings

When doing an <Up> on the top line, or a <Down> on the bottom line of
the edit window, the affected lines have already been redrawn by the
scrolling code, so there is no need to do that again.

(However, that does not prevent the second line (or the last-but-one
line) from being redrawn unnecessarily when using the M-- (or M-+)
command elsewhere on the screen and /that/ line is horizontally
scrolled.  But we'll let that pass for now.)

Diffstat:
Msrc/move.c | 30++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/move.c b/src/move.c @@ -439,12 +439,15 @@ void do_up(bool scroll_only) #endif editwinrows / 2 + 1); - /* Redraw the prior line if it was horizontally scrolled. */ - if (need_horizontal_scroll(was_column, 0)) - update_line(openfile->current->next, 0); - /* Redraw the current line if it needs to be horizontally scrolled. */ - if (need_horizontal_scroll(0, xplustabs())) - update_line(openfile->current, openfile->current_x); + /* If the lines weren't already redrawn, see if they need to be. */ + if (openfile->current_y > 0) { + /* Redraw the prior line if it was horizontally scrolled. */ + if (need_horizontal_scroll(was_column, 0)) + update_line(openfile->current->next, 0); + /* Redraw the current line if it needs to be horizontally scrolled. */ + if (need_horizontal_scroll(0, xplustabs())) + update_line(openfile->current, openfile->current_x); + } } /* Move up one line. */ @@ -521,12 +524,15 @@ void do_down(bool scroll_only) } } - /* Redraw the prior line if it was horizontally scrolled. */ - if (need_horizontal_scroll(was_column, 0)) - update_line(openfile->current->prev, 0); - /* Redraw the current line if it needs to be horizontally scrolled. */ - if (need_horizontal_scroll(0, xplustabs())) - update_line(openfile->current, openfile->current_x); + /* If the lines weren't already redrawn, see if they need to be. */ + if (openfile->current_y < editwinrows - 1) { + /* Redraw the prior line if it was horizontally scrolled. */ + if (need_horizontal_scroll(was_column, 0)) + update_line(openfile->current->prev, 0); + /* Redraw the current line if it needs to be horizontally scrolled. */ + if (need_horizontal_scroll(0, xplustabs())) + update_line(openfile->current, openfile->current_x); + } } /* Move down one line. */