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().
master
Benno Schulenberg 2019-06-03 13:38:21 +02:00
parent f63fee79e3
commit ea1016efdb
4 changed files with 9 additions and 1 deletions

View File

@ -47,6 +47,8 @@ bool as_an_at = TRUE;
bool control_C_was_pressed = FALSE; bool control_C_was_pressed = FALSE;
/* Whether Ctrl+C was pressed (when a keyboard interrupt is enabled). */ /* Whether Ctrl+C was pressed (when a keyboard interrupt is enabled). */
bool started_curses = FALSE;
bool suppress_cursorpos = FALSE; bool suppress_cursorpos = FALSE;
/* Should we skip constant position display for current keystroke? */ /* Should we skip constant position display for current keystroke? */

View File

@ -2502,6 +2502,8 @@ int main(int argc, char **argv)
if (initscr() == NULL) if (initscr() == NULL)
exit(1); exit(1);
started_curses = TRUE;
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
set_colorpairs(); set_colorpairs();
#else #else

View File

@ -42,6 +42,8 @@ extern bool control_C_was_pressed;
extern bool suppress_cursorpos; extern bool suppress_cursorpos;
extern bool started_curses;
extern message_type lastmessage; extern message_type lastmessage;
extern linestruct *pletion_line; extern linestruct *pletion_line;

View File

@ -2213,8 +2213,10 @@ void statusline(message_type importance, const char *msg, ...)
#ifndef NANO_TINY #ifndef NANO_TINY
/* Curses mode shouldn't be off when trying to write to the status bar. */ /* 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"); fprintf(stderr, "Out of curses -- please report a bug\n");
lastmessage = HUSH;
napms(1400);
return; return;
} }
#endif #endif