-const char *main_menu_help_text =
+#include "nc-helpscreen.h"
+
+struct help_text main_menu_help_text = define_help_text(
"From the main menu screen, select a boot option. The options displayed are \
available on the system and the network.\n\
\n\
\n\
To make changes to the system configuration, type C (configure).\n\
\n\
-To close the Petitboot interface, type X (exit).\n";
+To close the Petitboot interface, type X (exit).\n"
+);
#include "ui/common/discover-client.h"
#include "nc-cui.h"
-extern const char *main_menu_help_text;
+extern const struct help_text main_menu_help_text;
static void print_version(void)
{
}
m->help_title = _("main menu");
- m->help_text = main_menu_help_text;
+ m->help_text = &main_menu_help_text;
menu_opts_off(m->ncm, O_SHOWDESC);
set_menu_mark(m->ncm, " *");
-const char *boot_editor_help_text = "\
+#include "nc-helpscreen.h"
+
+struct help_text boot_editor_help_text = define_help_text("\
This screen allows you to edit or create boot options.\n\
\n\
Device: This is a list of block devices available on the system. Select \
\n\
Boot arguments: enter the kernel command-line arguments. This is optional.\n\
Example: root=/dev/sda1 console=hvc0\n\
-\n";
+\n");
char *args;
};
-extern const char *boot_editor_help_text;
+extern const struct help_text boot_editor_help_text;
static struct boot_editor *boot_editor_from_scr(struct nc_scr *scr)
{
case STATE_HELP:
boot_editor->state = STATE_EDIT;
cui_show_help(boot_editor->cui, _("Boot Option Editor"),
- boot_editor_help_text);
+ &boot_editor_help_text);
break;
default:
break;
-const char *config_help_text = "\
+#include "nc-helpscreen.h"
+
+struct help_text config_help_text = define_help_text("\
Autoboot: There are three possible options for automatic-boot hehaviour:\n"
"\n"
"Don't autoboot: boot options will be listed in the petitboot menu, but none \
"Static IP configuration: Allows you to specify an IPv4 address and network \
mask, gateway, and a DNS server or servers for a network interface. Select \
this option if you do not have a DHCP server, or want explicit control of \
-network settings."
-;
+network settings.");
#define N_FIELDS 25
-extern const char *config_help_text;
+extern struct help_text config_help_text;
enum autoboot_type {
AUTOBOOT_ANY,
} else if (screen->show_help) {
screen->show_help = false;
cui_show_help(screen->cui, _("System Configuration"),
- config_help_text);
+ &config_help_text);
} else if (handled) {
pad_refresh(screen);
cui->help_screen = NULL;
}
-void cui_show_help(struct cui *cui, const char *title, const char *text)
+void cui_show_help(struct cui *cui, const char *title,
+ const struct help_text *text)
{
if (!cui->current)
return;
#include "ui/common/joystick.h"
#include "nc-menu.h"
+#include "nc-helpscreen.h"
struct cui_opt_data {
const char *name;
void cui_item_new(struct pmenu *menu);
void cui_show_sysinfo(struct cui *cui);
void cui_show_config(struct cui *cui);
-void cui_show_help(struct cui *cui, const char *title, const char *text);
+void cui_show_help(struct cui *cui, const char *title,
+ const struct help_text *text);
int cui_send_config(struct cui *cui, struct config *config);
void cui_send_reinit(struct cui *cui);
struct help_screen *help_screen_init(struct cui *cui,
struct nc_scr *current_scr,
- const char *title_suffix, const char *text,
+ const char *title_suffix,
+ const struct help_text *text,
void (*on_exit)(struct cui *))
{
struct help_screen *screen;
_("Petitboot help: %s"), title_suffix);
text_screen_init(&screen->text_scr, cui, title, on_exit);
- text_screen_set_text(&screen->text_scr, text);
+ text_screen_set_text(&screen->text_scr, text->text);
text_screen_draw(&screen->text_scr);
return screen;
#define _NC_HELPSCREEN_H
struct help_screen;
+struct cui;
+
+/* Container struct for type-safety; we need to use gettext() before
+ * displaying the untranslated string. */
+struct help_text {
+ const char *text;
+};
+
+#define define_help_text(s) { .text = s }
struct nc_scr *help_screen_scr(struct help_screen *screen);
struct nc_scr *help_screen_return_scr(struct help_screen *screen);
struct help_screen *help_screen_init(struct cui *cui,
struct nc_scr *current_scr,
- const char *title_suffix, const char *text,
+ const char *title_suffix,
+ const struct help_text *text,
void (*on_exit)(struct cui *));
+
#endif /* defined _NC_HELPSCREEN_H */
unsigned int item_count;
unsigned int insert_pt;
const char *help_title;
- const char *help_text;
+ const struct help_text *help_text;
int (*hot_key)(struct pmenu *menu, struct pmenu_item *item, int c);
void (*on_exit)(struct pmenu *menu);
void (*on_new)(struct pmenu *menu);
struct text_screen text_scr;
};
-extern const char *sysinfo_help_text;
+extern const struct help_text sysinfo_help_text;
struct nc_scr *sysinfo_screen_scr(struct sysinfo_screen *screen)
{
text_screen_init(&screen->text_scr, cui,
_("Petitboot System Information"), on_exit);
text_screen_set_help(&screen->text_scr,
- _("System Information"), sysinfo_help_text);
+ _("System Information"), &sysinfo_help_text);
sysinfo_screen_update(screen, sysinfo);
}
void text_screen_set_help(struct text_screen *screen, const char *title,
- const char *text)
+ const struct help_text *text)
{
screen->help_title = title;
screen->help_text = text;
#include "nc-cui.h"
struct text_screen {
- struct nc_scr scr;
- struct cui *cui;
- const char **lines;
- int n_lines;
- int n_alloc_lines;
- int scroll_y;
- const char *help_title;
- const char *help_text;
- void (*on_exit)(struct cui *);
+ struct nc_scr scr;
+ struct cui *cui;
+ const char **lines;
+ int n_lines;
+ int n_alloc_lines;
+ int scroll_y;
+ const char *help_title;
+ const struct help_text *help_text;
+ void (*on_exit)(struct cui *);
};
void text_screen_init(struct text_screen *screen, struct cui *cui,
const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void text_screen_set_text(struct text_screen *screen, const char *text);
void text_screen_set_help(struct text_screen *screen, const char *title,
- const char *text);
+ const struct help_text *text);
/* interaction */
void text_screen_process_key(struct nc_scr *scr, int key);