From ddf1bce642a1a708775d81c45b08d674ba7b5095 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 23 Jan 2018 09:31:44 +0100 Subject: [PATCH] Add screen_exit() fn to restore screen defaults in debug mode Signed-off-by: Joachim Nilsson --- src/util.c | 14 ++++++++++++++ src/util.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/util.c b/src/util.c index 2f4735b8..34da1a57 100644 --- a/src/util.c +++ b/src/util.c @@ -157,6 +157,10 @@ char *sanitize(char *arg, size_t len) return NULL; } +/* + * Called at boot, and shutdown, to (re)initialize the + * screen size for print() et al. + */ void screen_init(void) { if (!isatty(STDOUT_FILENO)) @@ -165,6 +169,16 @@ void screen_init(void) initscr(&screen_rows, &screen_cols); } +/* + * Called when debug mode is enabled to revert back + * to old-school safe defaults. + */ +void screen_exit(void) +{ + screen_rows = 24; + screen_cols = 80; +} + /** * Local Variables: * indent-tabs-mode: t diff --git a/src/util.h b/src/util.h index 26659b33..476afb44 100644 --- a/src/util.h +++ b/src/util.h @@ -48,6 +48,7 @@ char *uptime (long secs, char *buf, size_t len); char *sanitize (char *arg, size_t len); void screen_init (void); +void screen_exit (void); int screen_width (void); #endif /* FINIT_UTIL_H_ */