return item->data;
}
+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() */
+
+ /* We may be operating with an incorrect $TERM type; in this case
+ * the keymappings will be slightly broken. We want at least
+ * backspace to work though, so we'll define both DEL and ^H to
+ * map to backspace */
+ define_key("\x7f", KEY_BACKSPACE);
+ define_key("\x08", KEY_BACKSPACE);
+
+ while (getch() != ERR) /* flush stdin */
+ (void)0;
+}
+
+static void cui_atexit(void)
+{
+ clear();
+ refresh();
+ endwin();
+}
+
/**
* cui_abort - Signal the main cui program loop to exit.
*
void cui_resize(struct cui *cui)
{
- pb_log("%s: resizing\n", __func__);
+ pb_debug("%s: resizing\n", __func__);
cui->resize = 1;
}
/**
- * cui_on_exit - A generic main menu ESC callback.
+ * cui_on_exit - A generic main menu exit callback.
*/
void cui_on_exit(struct pmenu *menu)
assert(cui->current == &cui->main->scr);
- pb_log("%s: %s\n", __func__, cod->name);
+ pb_debug("%s: %s\n", __func__, cod->name);
nc_scr_status_printf(cui->current, "Booting %s...", cod->name);
return;
}
- pb_log("%s: {%u,%u}\n", __func__, ws.ws_row, ws.ws_col);
+ pb_debug("%s: {%u,%u}\n", __func__, ws.ws_row, ws.ws_col);
wclear(cui->current->main_ncw);
resize_term(ws.ws_row, ws.ws_col);
ITEM *selected;
int result;
- pb_log("%s: %p %s\n", __func__, opt, opt->id);
+ pb_debug("%s: %p %s\n", __func__, opt, opt->id);
selected = current_item(cui->main->ncm);
goto fail_client_init;
}
- atexit(nc_atexit);
- nc_start();
+ atexit(cui_atexit);
+ cui_start();
waiter_register_io(cui->waitset, STDIN_FILENO, WAIT_IN,
cui_process_key, cui);
}
}
- nc_atexit();
+ cui_atexit();
return cui->abort ? 0 : -1;
}