X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-menu.c;h=7533f30e4df8d96048ae6e33c559629af5a81aee;hp=e28168edd4cf6d253e10e4c2f04fa3939fd25192;hb=c6dad307d1c305015066e179d392fae695b8cf08;hpb=f1599796efed1eb67759cf42f47fe4bf6a9bf93c diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c index e28168e..7533f30 100644 --- a/ui/ncurses/nc-menu.c +++ b/ui/ncurses/nc-menu.c @@ -16,9 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if defined(HAVE_CONFIG_H) #include "config.h" - -#define _GNU_SOURCE +#endif #include #include @@ -27,6 +27,7 @@ #include "log/log.h" #include "talloc/talloc.h" #include "ui/common/ui-system.h" +#include "nc-cui.h" #include "nc-menu.h" /** @@ -162,7 +163,7 @@ int pmenu_item_replace(struct pmenu_item *i, const char *name) set_item_userptr(nci, i); - menu->scr.unpost(&menu->scr); + nc_scr_unpost(&menu->scr); set_menu_items(menu->ncm, NULL); // FIXME: need to assure item name is a talloc string. @@ -173,7 +174,7 @@ int pmenu_item_replace(struct pmenu_item *i, const char *name) i->nci = nci; set_menu_items(menu->ncm, menu->items); - menu->scr.post(&menu->scr); + nc_scr_post(&menu->scr); return 0; } @@ -205,6 +206,7 @@ static void pmenu_process_key(struct nc_scr *scr, int key) switch (key) { case 27: /* ESC */ + case 'x': if (menu->on_exit) menu->on_exit(menu); nc_flush_keys(); @@ -232,16 +234,27 @@ static void pmenu_process_key(struct nc_scr *scr, int key) if (item->on_edit) item->on_edit(item); break; - case 'o': - DBGS("on_open: %p\n", menu->on_open); - if (menu->on_open) - menu->on_open(menu); + case 'n': + if (menu->on_new) + menu->on_new(menu); break; + case ' ': case '\n': case '\r': if (item->on_execute) item->on_execute(item); break; + case 'i': + cui_show_sysinfo(cui_from_arg(scr->ui_ctx)); + break; + case 'c': + cui_show_config(cui_from_arg(scr->ui_ctx)); + break; + case 'h': + if (menu->help_text) + cui_show_help(cui_from_arg(scr->ui_ctx), + menu->help_title, menu->help_text); + break; default: menu_driver(menu->ncm, key); break; @@ -378,6 +391,8 @@ int pmenu_setup(struct pmenu *menu) /* Makes menu scrollable. */ set_menu_format(menu->ncm, LINES - nc_scr_frame_lines, 1); + set_menu_grey(menu->ncm, A_NORMAL); + return 0; }