aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2007-07-20 18:00:36 -0400
committerSam Ravnborg <sam@ravnborg.org>2007-07-25 15:14:26 -0400
commit03d29122738f0bd81afd44b1f566e64ebf8d06fe (patch)
tree10038c037b7b82577fec387fa6cd8042fc8633e7
parent4a645d5ea65baaa5736bcb566673bf4a351b2ad8 (diff)
kconfig: attach help text to menus
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>
-rw-r--r--scripts/kconfig/conf.c31
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/gconf.c10
-rw-r--r--scripts/kconfig/kxgettext.c4
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/mconf.c4
-rw-r--r--scripts/kconfig/menu.c12
-rw-r--r--scripts/kconfig/qconf.cc2
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped12
-rw-r--r--scripts/kconfig/zconf.y12
10 files changed, 49 insertions, 43 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 1199baf866ca..8be6a4269e63 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -37,6 +37,14 @@ static struct menu *rootEntry;
37 37
38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); 38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
39 39
40static const char *get_help(struct menu *menu)
41{
42 if (menu_has_help(menu))
43 return menu_get_help(menu);
44 else
45 return nohelp_text;
46}
47
40static void strip(char *str) 48static void strip(char *str)
41{ 49{
42 char *p = str; 50 char *p = str;
@@ -171,7 +179,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
171int conf_string(struct menu *menu) 179int conf_string(struct menu *menu)
172{ 180{
173 struct symbol *sym = menu->sym; 181 struct symbol *sym = menu->sym;
174 const char *def, *help; 182 const char *def;
175 183
176 while (1) { 184 while (1) {
177 printf("%*s%s ", indent - 1, "", menu->prompt->text); 185 printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -186,10 +194,7 @@ int conf_string(struct menu *menu)
186 case '?': 194 case '?':
187 /* print help */ 195 /* print help */
188 if (line[1] == '\n') { 196 if (line[1] == '\n') {
189 help = nohelp_text; 197 printf("\n%s\n", get_help(menu));
190 if (menu->sym->help)
191 help = menu->sym->help;
192 printf("\n%s\n", menu->sym->help);
193 def = NULL; 198 def = NULL;
194 break; 199 break;
195 } 200 }
@@ -207,7 +212,6 @@ static int conf_sym(struct menu *menu)
207 struct symbol *sym = menu->sym; 212 struct symbol *sym = menu->sym;
208 int type; 213 int type;
209 tristate oldval, newval; 214 tristate oldval, newval;
210 const char *help;
211 215
212 while (1) { 216 while (1) {
213 printf("%*s%s ", indent - 1, "", menu->prompt->text); 217 printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -233,7 +237,7 @@ static int conf_sym(struct menu *menu)
233 printf("/m"); 237 printf("/m");
234 if (oldval != yes && sym_tristate_within_range(sym, yes)) 238 if (oldval != yes && sym_tristate_within_range(sym, yes))
235 printf("/y"); 239 printf("/y");
236 if (sym->help) 240 if (menu_has_help(menu))
237 printf("/?"); 241 printf("/?");
238 printf("] "); 242 printf("] ");
239 conf_askvalue(sym, sym_get_string_value(sym)); 243 conf_askvalue(sym, sym_get_string_value(sym));
@@ -269,10 +273,7 @@ static int conf_sym(struct menu *menu)
269 if (sym_set_tristate_value(sym, newval)) 273 if (sym_set_tristate_value(sym, newval))
270 return 0; 274 return 0;
271help: 275help:
272 help = nohelp_text; 276 printf("\n%s\n", get_help(menu));
273 if (sym->help)
274 help = sym->help;
275 printf("\n%s\n", help);
276 } 277 }
277} 278}
278 279
@@ -342,7 +343,7 @@ static int conf_choice(struct menu *menu)
342 goto conf_childs; 343 goto conf_childs;
343 } 344 }
344 printf("[1-%d", cnt); 345 printf("[1-%d", cnt);
345 if (sym->help) 346 if (menu_has_help(menu))
346 printf("?"); 347 printf("?");
347 printf("]: "); 348 printf("]: ");
348 switch (input_mode) { 349 switch (input_mode) {
@@ -359,8 +360,7 @@ static int conf_choice(struct menu *menu)
359 fgets(line, 128, stdin); 360 fgets(line, 128, stdin);
360 strip(line); 361 strip(line);
361 if (line[0] == '?') { 362 if (line[0] == '?') {
362 printf("\n%s\n", menu->sym->help ? 363 printf("\n%s\n", get_help(menu));
363 menu->sym->help : nohelp_text);
364 continue; 364 continue;
365 } 365 }
366 if (!line[0]) 366 if (!line[0])
@@ -391,8 +391,7 @@ static int conf_choice(struct menu *menu)
391 if (!child) 391 if (!child)
392 continue; 392 continue;
393 if (line[strlen(line) - 1] == '?') { 393 if (line[strlen(line) - 1] == '?') {
394 printf("\n%s\n", child->sym->help ? 394 printf("\n%s\n", get_help(child));
395 child->sym->help : nohelp_text);
396 continue; 395 continue;
397 } 396 }
398 sym_set_choice_value(sym, child->sym); 397 sym_set_choice_value(sym, child->sym);
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 6084525f604b..d6c33ce6dfdf 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -71,7 +71,6 @@ enum {
71struct symbol { 71struct symbol {
72 struct symbol *next; 72 struct symbol *next;
73 char *name; 73 char *name;
74 char *help;
75 enum symbol_type type; 74 enum symbol_type type;
76 struct symbol_value curr; 75 struct symbol_value curr;
77 struct symbol_value def[4]; 76 struct symbol_value def[4];
@@ -139,7 +138,7 @@ struct menu {
139 struct property *prompt; 138 struct property *prompt;
140 struct expr *dep; 139 struct expr *dep;
141 unsigned int flags; 140 unsigned int flags;
142 //char *help; 141 char *help;
143 struct file *file; 142 struct file *file;
144 int lineno; 143 int lineno;
145 void *data; 144 void *data;
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 61d8166166ef..262908cfc2ac 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -38,9 +38,6 @@ static gboolean show_all = FALSE;
38static gboolean show_debug = FALSE; 38static gboolean show_debug = FALSE;
39static gboolean resizeable = FALSE; 39static gboolean resizeable = FALSE;
40 40
41static char nohelp_text[] =
42 N_("Sorry, no help available for this option yet.\n");
43
44GtkWidget *main_wnd = NULL; 41GtkWidget *main_wnd = NULL;
45GtkWidget *tree1_w = NULL; // left frame 42GtkWidget *tree1_w = NULL; // left frame
46GtkWidget *tree2_w = NULL; // right frame 43GtkWidget *tree2_w = NULL; // right frame
@@ -462,12 +459,9 @@ static void text_insert_help(struct menu *menu)
462 GtkTextIter start, end; 459 GtkTextIter start, end;
463 const char *prompt = menu_get_prompt(menu); 460 const char *prompt = menu_get_prompt(menu);
464 gchar *name; 461 gchar *name;
465 const char *help = _(nohelp_text); 462 const char *help;
466 463
467 if (!menu->sym) 464 help = _(menu_get_help(menu));
468 help = "";
469 else if (menu->sym->help)
470 help = _(menu->sym->help);
471 465
472 if (menu->sym && menu->sym->name) 466 if (menu->sym && menu->sym->name)
473 name = g_strdup_printf(_(menu->sym->name)); 467 name = g_strdup_printf(_(menu->sym->name));
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
index 11f7dab94715..6eb72a7f2562 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -170,8 +170,8 @@ void menu_build_message_list(struct menu *menu)
170 menu->file == NULL ? "Root Menu" : menu->file->name, 170 menu->file == NULL ? "Root Menu" : menu->file->name,
171 menu->lineno); 171 menu->lineno);
172 172
173 if (menu->sym != NULL && menu->sym->help != NULL) 173 if (menu->sym != NULL && menu_has_help(menu))
174 message__add(menu->sym->help, menu->sym->name, 174 message__add(menu_get_help(menu), menu->sym->name,
175 menu->file == NULL ? "Root Menu" : menu->file->name, 175 menu->file == NULL ? "Root Menu" : menu->file->name,
176 menu->lineno); 176 menu->lineno);
177 177
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 15030770d1ad..4d09f6ddefe3 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -15,6 +15,8 @@ P(menu_is_visible,bool,(struct menu *menu));
15P(menu_get_prompt,const char *,(struct menu *menu)); 15P(menu_get_prompt,const char *,(struct menu *menu));
16P(menu_get_root_menu,struct menu *,(struct menu *menu)); 16P(menu_get_root_menu,struct menu *,(struct menu *menu));
17P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 17P(menu_get_parent_menu,struct menu *,(struct menu *menu));
18P(menu_has_help,bool,(struct menu *menu));
19P(menu_get_help,const char *,(struct menu *menu));
18 20
19/* symbol.c */ 21/* symbol.c */
20P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 22P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d2c2a429887b..bc5854ed6055 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -725,11 +725,11 @@ static void show_help(struct menu *menu)
725 struct gstr help = str_new(); 725 struct gstr help = str_new();
726 struct symbol *sym = menu->sym; 726 struct symbol *sym = menu->sym;
727 727
728 if (sym->help) 728 if (menu_has_help(menu))
729 { 729 {
730 if (sym->name) { 730 if (sym->name) {
731 str_printf(&help, "CONFIG_%s:\n\n", sym->name); 731 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
732 str_append(&help, _(sym->help)); 732 str_append(&help, _(menu_get_help(menu)));
733 str_append(&help, "\n"); 733 str_append(&help, "\n");
734 } 734 }
735 } else { 735 } else {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index f14aeac67d4f..f9d0d91a3fe4 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -417,3 +417,15 @@ struct menu *menu_get_parent_menu(struct menu *menu)
417 return menu; 417 return menu;
418} 418}
419 419
420bool menu_has_help(struct menu *menu)
421{
422 return menu->help != NULL;
423}
424
425const char *menu_get_help(struct menu *menu)
426{
427 if (menu->help)
428 return menu->help;
429 else
430 return "";
431}
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index f2a23a9c3938..e4eeb59a8c24 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1041,7 +1041,7 @@ void ConfigInfoView::menuInfo(void)
1041 if (showDebug()) 1041 if (showDebug())
1042 debug = debug_info(sym); 1042 debug = debug_info(sym);
1043 1043
1044 help = print_filter(_(sym->help)); 1044 help = print_filter(_(menu_get_help(menu)));
1045 } else if (menu->prompt) { 1045 } else if (menu->prompt) {
1046 head += "<big><b>"; 1046 head += "<big><b>";
1047 head += print_filter(_(menu->prompt->text)); 1047 head += print_filter(_(menu->prompt->text));
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 9a06b6771eee..ec21db77f78b 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1722,7 +1722,7 @@ yyreduce:
1722 case 83: 1722 case 83:
1723 1723
1724 { 1724 {
1725 current_entry->sym->help = (yyvsp[0].string); 1725 current_entry->help = (yyvsp[0].string);
1726;} 1726;}
1727 break; 1727 break;
1728 1728
@@ -2280,11 +2280,11 @@ void print_symbol(FILE *out, struct menu *menu)
2280 break; 2280 break;
2281 } 2281 }
2282 } 2282 }
2283 if (sym->help) { 2283 if (menu->help) {
2284 int len = strlen(sym->help); 2284 int len = strlen(menu->help);
2285 while (sym->help[--len] == '\n') 2285 while (menu->help[--len] == '\n')
2286 sym->help[len] = 0; 2286 menu->help[len] = 0;
2287 fprintf(out, " help\n%s\n", sym->help); 2287 fprintf(out, " help\n%s\n", menu->help);
2288 } 2288 }
2289 fputc('\n', out); 2289 fputc('\n', out);
2290} 2290}
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 92eb02bdf9c5..79db4cf22a51 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -402,7 +402,7 @@ help_start: T_HELP T_EOL
402 402
403help: help_start T_HELPTEXT 403help: help_start T_HELPTEXT
404{ 404{
405 current_entry->sym->help = $2; 405 current_entry->help = $2;
406}; 406};
407 407
408/* depends option */ 408/* depends option */
@@ -649,11 +649,11 @@ void print_symbol(FILE *out, struct menu *menu)
649 break; 649 break;
650 } 650 }
651 } 651 }
652 if (sym->help) { 652 if (menu->help) {
653 int len = strlen(sym->help); 653 int len = strlen(menu->help);
654 while (sym->help[--len] == '\n') 654 while (menu->help[--len] == '\n')
655 sym->help[len] = 0; 655 menu->help[len] = 0;
656 fprintf(out, " help\n%s\n", sym->help); 656 fprintf(out, " help\n%s\n", menu->help);
657 } 657 }
658 fputc('\n', out); 658 fputc('\n', out);
659} 659}