aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/conf.c
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 /scripts/kconfig/conf.c
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>
Diffstat (limited to 'scripts/kconfig/conf.c')
-rw-r--r--scripts/kconfig/conf.c31
1 files changed, 15 insertions, 16 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);