]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-cui.c
ui/ncurses: Add help facility to text screens
[petitboot] / ui / ncurses / nc-cui.c
index 9427e4a40dad1d97b06dc8c9a52ac8e6b65e07f6..650e90345cffa723abc1a04146b7103889ff17bd 100644 (file)
@@ -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 <assert.h>
 #include <errno.h>
@@ -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.
  */