X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-cui.c;h=8ad89553a5ebed3875d1eaa0da5e71235172a2ba;hp=d3e00aa03a0e6199f030b46209fe45194843092f;hb=2bc0df4aa35a89c5af7e54f459e2bbde20ca6a7e;hpb=646d77d8156ad72da1c24f734a029a525ba4bed9 diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index d3e00aa..8ad8955 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -92,16 +92,30 @@ static bool lockdown_active(void) #endif } +static void cui_set_curses_options(bool curses_mode) +{ + if (curses_mode) { + cbreak(); /* Disable line buffering. */ + noecho(); /* Disable getch() echo. */ + nonl(); /* Disable new-line translation. */ + intrflush(stdscr, FALSE); /* Disable interrupt flush. */ + curs_set(0); /* Make cursor invisible */ + nodelay(stdscr, TRUE); /* Enable non-blocking getch() */ + } else { + nocbreak(); /* Enable line buffering. */ + echo(); /* Enable getch() echo. */ + nl(); /* Enable new-line translation. */ + intrflush(stdscr, TRUE); /* Enable interrupt flush. */ + curs_set(1); /* Make cursor visible */ + nodelay(stdscr, FALSE); /* Disable non-blocking getch() */ + } +} + static void cui_start(void) { initscr(); /* Initialize ncurses. */ - cbreak(); /* Disable line buffering. */ - noecho(); /* Disable getch() echo. */ keypad(stdscr, TRUE); /* Enable num keypad keys. */ - nonl(); /* Disable new-line translation. */ - intrflush(stdscr, FALSE); /* Disable interrupt flush. */ - curs_set(0); /* Make cursor invisible */ - nodelay(stdscr, TRUE); /* Enable non-blocking getch() */ + cui_set_curses_options(true); /* We may be operating with an incorrect $TERM type; in this case * the keymappings will be slightly broken. We want at least @@ -650,6 +664,12 @@ static int cui_process_key(void *arg) } } + if (cui->preboot_mode) { + /* Turn curses options back on if the user interacts */ + cui->preboot_mode = false; + cui_set_curses_options(true); + } + if (!cui->has_input && key_cancels_boot(c)) { cui->has_input = true; if (cui->client) { @@ -980,8 +1000,21 @@ static void cui_update_status(struct status *status, void *arg) statuslog_append_steal(cui, cui->statuslog, status); /* Ignore status messages from the backlog */ - if (!status->backlog) - nc_scr_status_printf(cui->current, "%s", status->message); + if (status->backlog) + return; + + nc_scr_status_printf(cui->current, "%s", status->message); + + if (cui->preboot_mode && + (!status->boot_active || status->type == STATUS_ERROR)) { + cui_set_curses_options(true); + cui->preboot_mode = false; + } else { + cui->preboot_mode = status->boot_active && + status->type == STATUS_INFO; + if (cui->preboot_mode) + cui_set_curses_options(false); + } } /*