From f858d94d2a7bad8641318cac0d2427ff59a1ec7c Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 16 Jan 2018 14:47:14 +0100 Subject: [PATCH] Reinitialize screen at shutdown and when in debug mode Signed-off-by: Joachim Nilsson --- src/helpers.c | 7 +++++++ src/log.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/helpers.c b/src/helpers.c index 52ab145c..2b5fc14d 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -110,6 +110,13 @@ void print(int action, const char *fmt, ...) if (log_is_silent()) return; + /* + * In debug mode we must reinitialize often, user may be + * resizing their terminal to cope with debug output. + */ + if (log_is_debug()) + screen_init(); + if (fmt) { va_start(ap, fmt); printv(fmt, ap); diff --git a/src/log.c b/src/log.c index d0f8e8f2..6402dd62 100644 --- a/src/log.c +++ b/src/log.c @@ -29,6 +29,7 @@ #include "finit.h" #include "log.h" +#include "util.h" static int up = 0; static int debug = 0; @@ -65,6 +66,9 @@ void log_exit(void) sched_yield(); fputs("\n", stderr); } + + /* Reinitialize screen, terminal may have been resized at runtime */ + screen_init(); } void log_open(void)