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.
master
Benno Schulenberg 2020-05-31 16:14:43 +02:00
parent d9106abfda
commit 19a124e806
5 changed files with 8 additions and 9 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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:

View File

@ -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);

View File

@ -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 */