Roman Zippel wrote:
> A simple example would be
> help texts, right now they are per symbol, but they should really be per
> menu, so archs can provide different help texts for something.
This patch does this and at the same time introduce a few API
funtions used to access the help text.
The relevant api functions are introduced in the various frontends.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
+static const char *get_help(struct menu *menu)
+{
+ if (menu_has_help(menu))
+ return menu_get_help(menu);
+ else
+ return nohelp_text;
+}
+
static void strip(char *str)
{
char *p = str;
static void strip(char *str)
{
char *p = str;
int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
- const char *def, *help;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
case '?':
/* print help */
if (line[1] == '\n') {
case '?':
/* print help */
if (line[1] == '\n') {
- help = nohelp_text;
- if (menu->sym->help)
- help = menu->sym->help;
- printf("\n%s\n", menu->sym->help);
+ printf("\n%s\n", get_help(menu));
struct symbol *sym = menu->sym;
int type;
tristate oldval, newval;
struct symbol *sym = menu->sym;
int type;
tristate oldval, newval;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
printf("/m");
if (oldval != yes && sym_tristate_within_range(sym, yes))
printf("/y");
printf("/m");
if (oldval != yes && sym_tristate_within_range(sym, yes))
printf("/y");
+ if (menu_has_help(menu))
printf("/?");
printf("] ");
conf_askvalue(sym, sym_get_string_value(sym));
printf("/?");
printf("] ");
conf_askvalue(sym, sym_get_string_value(sym));
if (sym_set_tristate_value(sym, newval))
return 0;
help:
if (sym_set_tristate_value(sym, newval))
return 0;
help:
- help = nohelp_text;
- if (sym->help)
- help = sym->help;
- printf("\n%s\n", help);
+ printf("\n%s\n", get_help(menu));
goto conf_childs;
}
printf("[1-%d", cnt);
goto conf_childs;
}
printf("[1-%d", cnt);
+ if (menu_has_help(menu))
printf("?");
printf("]: ");
switch (input_mode) {
printf("?");
printf("]: ");
switch (input_mode) {
fgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
fgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
- printf("\n%s\n", menu->sym->help ?
- menu->sym->help : nohelp_text);
+ printf("\n%s\n", get_help(menu));
continue;
}
if (!line[0])
continue;
}
if (!line[0])
if (!child)
continue;
if (line[strlen(line) - 1] == '?') {
if (!child)
continue;
if (line[strlen(line) - 1] == '?') {
- printf("\n%s\n", child->sym->help ?
- child->sym->help : nohelp_text);
+ printf("\n%s\n", get_help(child));
continue;
}
sym_set_choice_value(sym, child->sym);
continue;
}
sym_set_choice_value(sym, child->sym);
struct symbol {
struct symbol *next;
char *name;
struct symbol {
struct symbol *next;
char *name;
enum symbol_type type;
struct symbol_value curr;
struct symbol_value def[4];
enum symbol_type type;
struct symbol_value curr;
struct symbol_value def[4];
struct property *prompt;
struct expr *dep;
unsigned int flags;
struct property *prompt;
struct expr *dep;
unsigned int flags;
struct file *file;
int lineno;
void *data;
struct file *file;
int lineno;
void *data;
static gboolean show_debug = FALSE;
static gboolean resizeable = FALSE;
static gboolean show_debug = FALSE;
static gboolean resizeable = FALSE;
-static char nohelp_text[] =
- N_("Sorry, no help available for this option yet.\n");
-
GtkWidget *main_wnd = NULL;
GtkWidget *tree1_w = NULL; // left frame
GtkWidget *tree2_w = NULL; // right frame
GtkWidget *main_wnd = NULL;
GtkWidget *tree1_w = NULL; // left frame
GtkWidget *tree2_w = NULL; // right frame
GtkTextIter start, end;
const char *prompt = menu_get_prompt(menu);
gchar *name;
GtkTextIter start, end;
const char *prompt = menu_get_prompt(menu);
gchar *name;
- const char *help = _(nohelp_text);
- if (!menu->sym)
- help = "";
- else if (menu->sym->help)
- help = _(menu->sym->help);
+ help = _(menu_get_help(menu));
if (menu->sym && menu->sym->name)
name = g_strdup_printf(_(menu->sym->name));
if (menu->sym && menu->sym->name)
name = g_strdup_printf(_(menu->sym->name));
menu->file == NULL ? "Root Menu" : menu->file->name,
menu->lineno);
menu->file == NULL ? "Root Menu" : menu->file->name,
menu->lineno);
- if (menu->sym != NULL && menu->sym->help != NULL)
- message__add(menu->sym->help, menu->sym->name,
+ if (menu->sym != NULL && menu_has_help(menu))
+ message__add(menu_get_help(menu), menu->sym->name,
menu->file == NULL ? "Root Menu" : menu->file->name,
menu->lineno);
menu->file == NULL ? "Root Menu" : menu->file->name,
menu->lineno);
P(menu_get_prompt,const char *,(struct menu *menu));
P(menu_get_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
P(menu_get_prompt,const char *,(struct menu *menu));
P(menu_get_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
+P(menu_has_help,bool,(struct menu *menu));
+P(menu_get_help,const char *,(struct menu *menu));
/* symbol.c */
P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
/* symbol.c */
P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
struct gstr help = str_new();
struct symbol *sym = menu->sym;
struct gstr help = str_new();
struct symbol *sym = menu->sym;
+ if (menu_has_help(menu))
{
if (sym->name) {
str_printf(&help, "CONFIG_%s:\n\n", sym->name);
{
if (sym->name) {
str_printf(&help, "CONFIG_%s:\n\n", sym->name);
- str_append(&help, _(sym->help));
+ str_append(&help, _(menu_get_help(menu)));
str_append(&help, "\n");
}
} else {
str_append(&help, "\n");
}
} else {
+bool menu_has_help(struct menu *menu)
+{
+ return menu->help != NULL;
+}
+
+const char *menu_get_help(struct menu *menu)
+{
+ if (menu->help)
+ return menu->help;
+ else
+ return "";
+}
if (showDebug())
debug = debug_info(sym);
if (showDebug())
debug = debug_info(sym);
- help = print_filter(_(sym->help));
+ help = print_filter(_(menu_get_help(menu)));
} else if (menu->prompt) {
head += "<big><b>";
head += print_filter(_(menu->prompt->text));
} else if (menu->prompt) {
head += "<big><b>";
head += print_filter(_(menu->prompt->text));
- current_entry->sym->help = (yyvsp[0].string);
+ current_entry->help = (yyvsp[0].string);
- if (sym->help) {
- int len = strlen(sym->help);
- while (sym->help[--len] == '\n')
- sym->help[len] = 0;
- fprintf(out, " help\n%s\n", sym->help);
+ if (menu->help) {
+ int len = strlen(menu->help);
+ while (menu->help[--len] == '\n')
+ menu->help[len] = 0;
+ fprintf(out, " help\n%s\n", menu->help);
help: help_start T_HELPTEXT
{
help: help_start T_HELPTEXT
{
- current_entry->sym->help = $2;
+ current_entry->help = $2;
- if (sym->help) {
- int len = strlen(sym->help);
- while (sym->help[--len] == '\n')
- sym->help[len] = 0;
- fprintf(out, " help\n%s\n", sym->help);
+ if (menu->help) {
+ int len = strlen(menu->help);
+ while (menu->help[--len] == '\n')
+ menu->help[len] = 0;
+ fprintf(out, " help\n%s\n", menu->help);