nano

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

commit 19a124e80614cf294b896eaf6e603eb52055114a
parent d9106abfda2daed7b9cd0d096d4b52ad67b78a14
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 31 May 2020 16:14:43 +0200

display: avoid an additional redrawing when redrawing the screen

When resizing the screen or toggling the help lines or refreshing
the screen with ^L, what used to be total_refresh() would first call
what used to be total_redraw(), to tell ncurses to redraw whatever
had been on the screen so far, before proceeding to fully redraw the
content of the title bar and the edit window and the bottom bars.
That was duplicate work.

Thus, rename total_redraw() to total_refresh(), so that ^L in the
edit window, help viewer, and file browser will redraw the screen
just once.  This also preserves whatever was on the status bar
(when --quickblank isn't used).

Rename the old total_refresh() to draw_all_subwindows() and call
this routine when resizing the screen or toggling the help lines
or returning from the credits crawl.

Diffstat:
Msrc/browser.c | 2+-
Msrc/help.c | 2+-
Msrc/nano.c | 4++--
Msrc/proto.h | 2+-
Msrc/winio.c | 7+++----
5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/browser.c b/src/browser.c @@ -154,7 +154,7 @@ char *do_browser(char *path) func = interpret(&kbinput); if (func == total_refresh) { - total_redraw(); + total_refresh(); #ifndef NANO_TINY /* Simulate a window resize to force a directory reread. */ kbinput = KEY_WINCH; diff --git a/src/help.c b/src/help.c @@ -194,7 +194,7 @@ void show_help(void) func = interpret(&kbinput); if (func == total_refresh) { - total_redraw(); + total_refresh(); } else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right || func == do_up || func == do_down)) { func(); diff --git a/src/nano.c b/src/nano.c @@ -1053,7 +1053,7 @@ void regenerate_screen(void) /* If we have an open buffer, redraw the contents of the subwindows. */ if (openfile) { ensure_firstcolumn_is_aligned(); - total_refresh(); + draw_all_subwindows(); } } @@ -1071,7 +1071,7 @@ void do_toggle(int flag) switch (flag) { case NO_HELP: window_init(); - total_refresh(); + draw_all_subwindows(); break; #ifdef ENABLE_MOUSE case USE_MOUSE: diff --git a/src/proto.h b/src/proto.h @@ -639,8 +639,8 @@ size_t actual_last_column(size_t leftedge, size_t column); void edit_redraw(linestruct *old_current, update_type manner); void edit_refresh(void); void adjust_viewport(update_type location); -void total_redraw(void); void total_refresh(void); +void draw_all_subwindows(void); void do_cursorpos(bool force); void do_cursorpos_void(void); void spotlight(size_t from_col, size_t to_col); diff --git a/src/winio.c b/src/winio.c @@ -3309,7 +3309,7 @@ void adjust_viewport(update_type manner) } /* Unconditionally redraw the entire screen. */ -void total_redraw(void) +void total_refresh(void) { #ifdef USE_SLANG /* Slang curses emulation brain damage, part 4: Slang doesn't define @@ -3323,9 +3323,8 @@ void total_redraw(void) /* Redraw the entire screen, then refresh the title bar and the content of * the edit window (when not in the file browser), and the bottom bars. */ -void total_refresh(void) +void draw_all_subwindows(void) { - total_redraw(); if (currmenu != MBROWSER && currmenu != MWHEREISFILE && currmenu != MGOTODIR) titlebar(title); #ifdef ENABLE_HELP @@ -3620,6 +3619,6 @@ void do_credits(void) scrollok(edit, FALSE); nodelay(edit, FALSE); - total_refresh(); + draw_all_subwindows(); } #endif /* ENABLE_EXTRA */