From 2cf28f9db7566d2415d2679d0d4c3ffb8bee5411 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 10 May 2021 12:17:35 +0200 Subject: [PATCH] statusbar: suppress the cursor when the terminal has just one row When showing a message on the status bar, the cursor should be off. This fixes https://savannah.gnu.org/bugs/?60510. Bug existed since version 2.7.0, since nano allows very flat terminals. --- src/winio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index b6b11ae5..7433eccc 100644 --- a/src/winio.c +++ b/src/winio.c @@ -182,10 +182,14 @@ void read_keys_from(WINDOW *win) bool timed = FALSE; #endif + /* On a one-row terminal, overwrite an unimportant message. */ + if (LINES == 1 && currmenu == MMAIN && lastmessage == HUSH) + edit_refresh(); + /* Before reading the first keycode, display any pending screen updates. */ doupdate(); - if (reveal_cursor && !hide_cursor) + if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH)) curs_set(1); #ifndef NANO_TINY @@ -2245,6 +2249,11 @@ void statusline(message_type importance, const char *msg, ...) if (importance < lastmessage && lastmessage > NOTICE) return; + /* On a one-row terminal, ensure that any changes in the edit window are + * written out first, to prevent them from overwriting the message. */ + if (LINES == 1 && importance < INFO) + wnoutrefresh(edit); + /* Construct the message out of all the arguments. */ compound = nmalloc(MAXCHARLEN * COLS + 1); va_start(ap, msg);