commit ea1016efdbfb27296fd775254785f634b116881b
parent f63fee79e35752abc98d537aa520a674c4e9bc4e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 3 Jun 2019 13:38:21 +0200
feedback: make an error check work also when curses hasn't started yet
Add a temporary boolean for this, because isendwin() returns TRUE
only when curses mode has actually been started with initscr() and
then exited with endwin().
Diffstat:
4 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/global.c b/src/global.c
@@ -47,6 +47,8 @@ bool as_an_at = TRUE;
bool control_C_was_pressed = FALSE;
/* Whether Ctrl+C was pressed (when a keyboard interrupt is enabled). */
+bool started_curses = FALSE;
+
bool suppress_cursorpos = FALSE;
/* Should we skip constant position display for current keystroke? */
diff --git a/src/nano.c b/src/nano.c
@@ -2502,6 +2502,8 @@ int main(int argc, char **argv)
if (initscr() == NULL)
exit(1);
+ started_curses = TRUE;
+
#ifdef ENABLE_COLOR
set_colorpairs();
#else
diff --git a/src/proto.h b/src/proto.h
@@ -42,6 +42,8 @@ extern bool control_C_was_pressed;
extern bool suppress_cursorpos;
+extern bool started_curses;
+
extern message_type lastmessage;
extern linestruct *pletion_line;
diff --git a/src/winio.c b/src/winio.c
@@ -2213,8 +2213,10 @@ void statusline(message_type importance, const char *msg, ...)
#ifndef NANO_TINY
/* Curses mode shouldn't be off when trying to write to the status bar. */
- if (isendwin()) {
+ if (!started_curses || isendwin()) {
fprintf(stderr, "Out of curses -- please report a bug\n");
+ lastmessage = HUSH;
+ napms(1400);
return;
}
#endif