diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ncurses/generic-main-help.c | 7 | ||||
-rw-r--r-- | ui/ncurses/generic-main.c | 4 | ||||
-rw-r--r-- | ui/ncurses/nc-boot-editor-help.c | 6 | ||||
-rw-r--r-- | ui/ncurses/nc-boot-editor.c | 4 | ||||
-rw-r--r-- | ui/ncurses/nc-config-help.c | 7 | ||||
-rw-r--r-- | ui/ncurses/nc-config.c | 4 | ||||
-rw-r--r-- | ui/ncurses/nc-cui.c | 3 | ||||
-rw-r--r-- | ui/ncurses/nc-cui.h | 4 | ||||
-rw-r--r-- | ui/ncurses/nc-helpscreen.c | 5 | ||||
-rw-r--r-- | ui/ncurses/nc-helpscreen.h | 13 | ||||
-rw-r--r-- | ui/ncurses/nc-menu.h | 2 | ||||
-rw-r--r-- | ui/ncurses/nc-sysinfo.c | 4 | ||||
-rw-r--r-- | ui/ncurses/nc-textscreen.c | 2 | ||||
-rw-r--r-- | ui/ncurses/nc-textscreen.h | 20 |
14 files changed, 53 insertions, 32 deletions
diff --git a/ui/ncurses/generic-main-help.c b/ui/ncurses/generic-main-help.c index d3c5662..ac690c5 100644 --- a/ui/ncurses/generic-main-help.c +++ b/ui/ncurses/generic-main-help.c @@ -1,5 +1,7 @@ -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\ @@ -14,4 +16,5 @@ network interface, type I (information).\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" +); diff --git a/ui/ncurses/generic-main.c b/ui/ncurses/generic-main.c index abf3356..f253469 100644 --- a/ui/ncurses/generic-main.c +++ b/ui/ncurses/generic-main.c @@ -40,7 +40,7 @@ #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) { @@ -234,7 +234,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui) } 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, " *"); diff --git a/ui/ncurses/nc-boot-editor-help.c b/ui/ncurses/nc-boot-editor-help.c index 3f0c7fb..4c0ba24 100644 --- a/ui/ncurses/nc-boot-editor-help.c +++ b/ui/ncurses/nc-boot-editor-help.c @@ -1,4 +1,6 @@ -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 \ @@ -21,4 +23,4 @@ Example: /boot/device-tree.dtb\n\ \n\ Boot arguments: enter the kernel command-line arguments. This is optional.\n\ Example: root=/dev/sda1 console=hvc0\n\ -\n"; +\n"); diff --git a/ui/ncurses/nc-boot-editor.c b/ui/ncurses/nc-boot-editor.c index 6bc1d89..6da3630 100644 --- a/ui/ncurses/nc-boot-editor.c +++ b/ui/ncurses/nc-boot-editor.c @@ -73,7 +73,7 @@ struct boot_editor { 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) { @@ -222,7 +222,7 @@ static void boot_editor_process_key(struct nc_scr *scr, int key) 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; diff --git a/ui/ncurses/nc-config-help.c b/ui/ncurses/nc-config-help.c index 828fce7..18c51d4 100644 --- a/ui/ncurses/nc-config-help.c +++ b/ui/ncurses/nc-config-help.c @@ -1,4 +1,6 @@ -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 \ @@ -35,5 +37,4 @@ only want to configure a single interface during boot.\n" "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."); diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 54eb7ac..a095353 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -35,7 +35,7 @@ #define N_FIELDS 25 -extern const char *config_help_text; +extern struct help_text config_help_text; enum autoboot_type { AUTOBOOT_ANY, @@ -146,7 +146,7 @@ static void config_screen_process_key(struct nc_scr *scr, int key) } 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); diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 96d82ca..cd7952f 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -270,7 +270,8 @@ static void cui_help_exit(struct cui *cui) 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; diff --git a/ui/ncurses/nc-cui.h b/ui/ncurses/nc-cui.h index 8632806..e9e4d38 100644 --- a/ui/ncurses/nc-cui.h +++ b/ui/ncurses/nc-cui.h @@ -23,6 +23,7 @@ #include "ui/common/joystick.h" #include "nc-menu.h" +#include "nc-helpscreen.h" struct cui_opt_data { const char *name; @@ -75,7 +76,8 @@ void cui_item_edit(struct pmenu_item *item); 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); diff --git a/ui/ncurses/nc-helpscreen.c b/ui/ncurses/nc-helpscreen.c index 3b27d57..fd76a43 100644 --- a/ui/ncurses/nc-helpscreen.c +++ b/ui/ncurses/nc-helpscreen.c @@ -48,7 +48,8 @@ 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 *)) { struct help_screen *screen; @@ -63,7 +64,7 @@ struct help_screen *help_screen_init(struct cui *cui, _("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; diff --git a/ui/ncurses/nc-helpscreen.h b/ui/ncurses/nc-helpscreen.h index f104411..99b99f7 100644 --- a/ui/ncurses/nc-helpscreen.h +++ b/ui/ncurses/nc-helpscreen.h @@ -19,13 +19,24 @@ #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 */ diff --git a/ui/ncurses/nc-menu.h b/ui/ncurses/nc-menu.h index 12eafaf..2f66bbb 100644 --- a/ui/ncurses/nc-menu.h +++ b/ui/ncurses/nc-menu.h @@ -88,7 +88,7 @@ struct pmenu { 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); diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c index 0d362e4..f793010 100644 --- a/ui/ncurses/nc-sysinfo.c +++ b/ui/ncurses/nc-sysinfo.c @@ -35,7 +35,7 @@ struct sysinfo_screen { 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) { @@ -115,7 +115,7 @@ struct sysinfo_screen *sysinfo_screen_init(struct cui *cui, 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); diff --git a/ui/ncurses/nc-textscreen.c b/ui/ncurses/nc-textscreen.c index 4ae0db4..826244c 100644 --- a/ui/ncurses/nc-textscreen.c +++ b/ui/ncurses/nc-textscreen.c @@ -174,7 +174,7 @@ struct nc_scr *text_screen_scr(struct text_screen *screen) } 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; diff --git a/ui/ncurses/nc-textscreen.h b/ui/ncurses/nc-textscreen.h index 72b8c8a..25107cb 100644 --- a/ui/ncurses/nc-textscreen.h +++ b/ui/ncurses/nc-textscreen.h @@ -22,15 +22,15 @@ #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, @@ -45,7 +45,7 @@ void text_screen_append_line(struct text_screen *screen, 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); |