>From be88012b8501e57a648827a715d250c89cb4b219 Mon Sep 17 00:00:00 2001 From: Brand Huntsman Date: Fri, 24 Aug 2018 07:22:03 -0600 Subject: [PATCH] redo statusbar after removing help bars Signed-off-by: Brand Huntsman --- src/nano.c | 8 ++++++++ src/proto.h | 1 + src/winio.c | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/nano.c b/src/nano.c index b05709c1..af2d3232 100644 --- a/src/nano.c +++ b/src/nano.c @@ -678,9 +678,13 @@ void emergency_save(const char *die_filename, struct stat *die_stat) free(targetname); } +static int had_bottomrows = 0; + /* Initialize the three window portions nano uses. */ void window_init(void) { + bool _redo_statusbar = FALSE; + /* When resizing, first delete the existing windows. */ if (edit != NULL) { if (topwin != NULL) @@ -702,6 +706,9 @@ void window_init(void) int bottomrows = (ISSET(NO_HELP) && (currmenu == MMAIN || currmenu == MMOST) ? 1 : (LINES < 5) ? 1 : 3); + _redo_statusbar = (had_bottomrows > bottomrows); + had_bottomrows = bottomrows; + editwinrows = LINES - toprows - bottomrows; /* Set up the normal three subwindows. */ @@ -712,6 +719,7 @@ void window_init(void) /* In case the terminal shrunk, make sure the status line is clear. */ wipe_statusbar(); + if (_redo_statusbar) redo_statusbar(); /* Turn the keypad on for the windows, if necessary. */ if (!ISSET(REBIND_KEYPAD)) { diff --git a/src/proto.h b/src/proto.h index b472148a..0407a5be 100644 --- a/src/proto.h +++ b/src/proto.h @@ -638,6 +638,7 @@ void blank_bottombars(void); void check_statusblank(void); char *display_string(const char *buf, size_t column, size_t span, bool isdata); void titlebar(const char *path); +void redo_statusbar(); void statusbar(const char *msg); void warn_and_shortly_pause(const char *msg); void statusline(message_type importance, const char *msg, ...); diff --git a/src/winio.c b/src/winio.c index b9f18ccf..e7c1e0b2 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2144,6 +2144,15 @@ void titlebar(const char *path) wrefresh(topwin); } +static const char *last_status_msg = NULL; + +/* Display previous message on statusbar. */ +void redo_statusbar() +{ + // TODO: lastmessage should be renamed to last_status_importance + statusline(lastmessage, last_status_msg); +} + /* Display a normal message on the statusbar, quietly. */ void statusbar(const char *msg) { @@ -2176,6 +2185,8 @@ void statusline(message_type importance, const char *msg, ...) UNSET(WHITESPACE_DISPLAY); #endif + last_status_msg = msg; + /* Ignore a message with an importance that is lower than the last one. */ if ((lastmessage == ALERT && importance != ALERT) || (lastmessage == MILD && importance == HUSH)) -- 2.16.4