Improve terminal initialisation

Don't just abort() on failures, print a proper error message.

Also, set up ncurses as late as possible.  This should be alright wrt.
signal handlers according to ncurses code, as well as XSI:

> Curses implementations may provide for special handling of
> the SIGINT, SIGQUIT and SIGTSTP signals if their disposition
> is SIG_DFL at the time initscr is called ...

termo blocks job control, so SIGTSTP is not a concern at all.
This commit is contained in:
Přemysl Eric Janouch 2021-09-06 21:20:40 +02:00
parent 353174ee3c
commit 30777e8fd3
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 3 additions and 3 deletions

View File

@ -1254,9 +1254,9 @@ app_init_terminal (void)
{ {
TERMO_CHECK_VERSION; TERMO_CHECK_VERSION;
if (!(g.tk = termo_new (STDIN_FILENO, NULL, 0))) if (!(g.tk = termo_new (STDIN_FILENO, NULL, 0)))
abort (); exit_fatal ("failed to set up the terminal");
if (!initscr () || nonl () == ERR) if (!initscr () || nonl () == ERR)
abort (); exit_fatal ("failed to set up the terminal");
// By default we don't use any colors so they're not required... // By default we don't use any colors so they're not required...
if (start_color () == ERR if (start_color () == ERR
@ -4574,9 +4574,9 @@ main (int argc, char *argv[])
app_init_context (); app_init_context ();
app_load_configuration (); app_load_configuration ();
app_init_terminal ();
signals_setup_handlers (); signals_setup_handlers ();
app_init_poller_events (); app_init_poller_events ();
app_init_terminal ();
g_normal_keys = app_init_bindings ("normal", g_normal_keys = app_init_bindings ("normal",
g_normal_defaults, N_ELEMENTS (g_normal_defaults), &g_normal_keys_len); g_normal_defaults, N_ELEMENTS (g_normal_defaults), &g_normal_keys_len);