X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-cui.c;h=650e90345cffa723abc1a04146b7103889ff17bd;hp=107539b32a11a1b5974d70caad18ac5d4c36425d;hb=a68cae0b9d1b165eef07011011a163b906e0587c;hpb=37c9aee3ffc02a299d94867df9df8132b09fc611 diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 107539b..650e903 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.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 @@ -38,6 +38,7 @@ #include "nc-boot-editor.h" #include "nc-config.h" #include "nc-sysinfo.h" +#include "nc-helpscreen.h" static void cui_start(void) { @@ -246,6 +247,28 @@ void cui_show_config(struct cui *cui) cui_set_current(cui, config_screen_scr(cui->config_screen)); } +static void cui_help_exit(struct cui *cui) +{ + cui_set_current(cui, help_screen_return_scr(cui->help_screen)); + talloc_free(cui->help_screen); + cui->help_screen = NULL; +} + +void cui_show_help(struct cui *cui, const char *title, const char *text) +{ + if (!cui->current) + return; + + if (cui->help_screen) + return; + + cui->help_screen = help_screen_init(cui, cui->current, + title, text, cui_help_exit); + + if (cui->help_screen) + cui_set_current(cui, help_screen_scr(cui->help_screen)); +} + /** * cui_set_current - Set the currently active screen and redraw it. */ @@ -272,10 +295,8 @@ static bool process_global_keys(struct cui *cui, int key) { switch (key) { case 0xc: - if (cui->current && cui->current->main_ncw) { - redrawwin(cui->current->main_ncw); - wrefresh(cui->current->main_ncw); - } + if (cui->current && cui->current->main_ncw) + wrefresh(curscr); return true; } return false; @@ -298,6 +319,8 @@ static int cui_process_key(void *arg) for (;;) { int c = getch(); + pb_debug("%s: got key %d\n", __func__, c); + if (c == ERR) break; @@ -522,10 +545,14 @@ static void cui_update_sysinfo(struct system_info *sysinfo, void *arg) if (cui->sysinfo_screen) sysinfo_screen_update(cui->sysinfo_screen, sysinfo); - /* ... and do the same with the config screen */ + /* ... and do the same with the config screen... */ if (cui->config_screen) config_screen_update(cui->config_screen, cui->config, sysinfo); + /* ... and the boot editor. */ + if (cui->boot_editor) + boot_editor_update(cui->boot_editor, sysinfo); + cui_update_mm_title(cui); }