diff --git a/src/ui/core.c b/src/ui/core.c index f67df803..93d240cd 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -54,6 +54,7 @@ static int inp_size; static gboolean perform_resize = FALSE; +static gboolean ui_suspended = FALSE; static GTimer* ui_idle_time; static WINDOW* main_scr; @@ -63,6 +64,16 @@ static Display* display; static void _ui_draw_term_title(void); +// Skip drawing while an external editor is active (ui_suspended) or after the +// screen has been closed (endwin). The flag is authoritative and does not rely +// on isendwin() staying TRUE, which a stray doupdate() during the session could +// otherwise clear. +static gboolean +_ui_redraw_suspended(void) +{ + return ui_suspended || isendwin(); +} + static void _ui_close(void) { @@ -120,8 +131,7 @@ ui_sigwinch_handler(int sig) void ui_update(void) { - // UI is suspended - if (isendwin()) { + if (_ui_redraw_suspended()) { return; } @@ -179,6 +189,7 @@ ui_reset_idle_time(void) void ui_suspend(void) { + ui_suspended = TRUE; inp_suspend(); doupdate(); endwin(); @@ -187,6 +198,7 @@ ui_suspend(void) void ui_resume(void) { + ui_suspended = FALSE; refresh(); inp_resume(); } @@ -210,8 +222,7 @@ ui_flash(void) void ui_resize(void) { - // UI is suspended - if (isendwin()) { + if (_ui_redraw_suspended()) { return; } @@ -233,8 +244,7 @@ ui_resize(void) void ui_redraw(void) { - // UI is suspended - if (isendwin()) { + if (_ui_redraw_suspended()) { return; }