Commit 22c7eca6 authored by Li Zefan's avatar Li Zefan Committed by Michal Marek

menuconfig: add support to show hidden options which have prompts

Usage:
  Press <Z> to show all config symbols which have prompts.

Quote Tim Bird:

| I've been bitten by this numerous times.  I most often
| use ftrace on ARM, but when I go back to x86, I almost
| always go through a sequence of searching for the
| function graph tracer in the menus, then realizing it's
| completely missing until I disable CC_OPTIMIZE_FOR_SIZE.
|
| Is there any way to have the menu item appear, but be
| unsettable unless the SIZE option is disabled?  I'm
| not a Kconfig guru...

I myself found this useful too. For example, I need to test
ftrace/tracing and want to be sure all the tracing features are
enabled, so I  enter the "Tracers" menu, and press <Z> to
see if there is any config hidden.

I also noticed gconfig and xconfig have a button "Show all options",
but that's a bit too much, and I think normally what we are not
interested in those configs which have no prompt thus can't be
changed by users.

Exmaple:

      --- Tracers
      -*-   Kernel Function Tracer
      - -     Kernel Function Graph Tracer
      [*]   Interrupts-off Latency Tracer
      - -   Preemption-off Latency Tracer
      [*]   Sysprof Tracer

Here you can see 2 tracers are not selectable, and then can find
out how to make them selectable.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 7b5d8721
...@@ -11,7 +11,8 @@ P(conf_set_changed_callback, void,(void (*fn)(void))); ...@@ -11,7 +11,8 @@ P(conf_set_changed_callback, void,(void (*fn)(void)));
/* menu.c */ /* menu.c */
P(rootmenu,struct menu,); P(rootmenu,struct menu,);
P(menu_is_visible,bool,(struct menu *menu)); P(menu_is_visible, bool, (struct menu *menu));
P(menu_has_prompt, bool, (struct menu *menu));
P(menu_get_prompt,const char *,(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_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu)); P(menu_get_parent_menu,struct menu *,(struct menu *menu));
......
...@@ -383,6 +383,10 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -383,6 +383,10 @@ int dialog_menu(const char *title, const char *prompt,
case 'n': case 'n':
case 'm': case 'm':
case '/': case '/':
case 'h':
case '?':
case 'z':
case '\n':
/* save scroll info */ /* save scroll info */
*s_scroll = scroll; *s_scroll = scroll;
delwin(menu); delwin(menu);
...@@ -390,8 +394,10 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -390,8 +394,10 @@ int dialog_menu(const char *title, const char *prompt,
item_set(scroll + choice); item_set(scroll + choice);
item_set_selected(1); item_set_selected(1);
switch (key) { switch (key) {
case 'h':
case '?':
return 2;
case 's': case 's':
return 3;
case 'y': case 'y':
return 3; return 3;
case 'n': case 'n':
...@@ -402,18 +408,12 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -402,18 +408,12 @@ int dialog_menu(const char *title, const char *prompt,
return 6; return 6;
case '/': case '/':
return 7; return 7;
case 'z':
return 8;
case '\n':
return button;
} }
return 0; return 0;
case 'h':
case '?':
button = 2;
case '\n':
*s_scroll = scroll;
delwin(menu);
delwin(dialog);
item_set(scroll + choice);
item_set_selected(1);
return button;
case 'e': case 'e':
case 'x': case 'x':
key = KEY_ESC; key = KEY_ESC;
......
...@@ -67,13 +67,15 @@ static const char mconf_readme[] = N_( ...@@ -67,13 +67,15 @@ static const char mconf_readme[] = N_(
" there is a delayed response which you may find annoying.\n" " there is a delayed response which you may find annoying.\n"
"\n" "\n"
" Also, the <TAB> and cursor keys will cycle between <Select>,\n" " Also, the <TAB> and cursor keys will cycle between <Select>,\n"
" <Exit> and <Help>\n" " <Exit> and <Help>.\n"
"\n" "\n"
"o To get help with an item, use the cursor keys to highlight <Help>\n" "o To get help with an item, use the cursor keys to highlight <Help>\n"
" and Press <ENTER>.\n" " and press <ENTER>.\n"
"\n" "\n"
" Shortcut: Press <H> or <?>.\n" " Shortcut: Press <H> or <?>.\n"
"\n" "\n"
"o To show hidden options, press <Z>.\n"
"\n"
"\n" "\n"
"Radiolists (Choice lists)\n" "Radiolists (Choice lists)\n"
"-----------\n" "-----------\n"
...@@ -272,6 +274,7 @@ static int indent; ...@@ -272,6 +274,7 @@ static int indent;
static struct menu *current_menu; static struct menu *current_menu;
static int child_count; static int child_count;
static int single_menu_mode; static int single_menu_mode;
static int show_all_options;
static void conf(struct menu *menu); static void conf(struct menu *menu);
static void conf_choice(struct menu *menu); static void conf_choice(struct menu *menu);
...@@ -346,8 +349,16 @@ static void build_conf(struct menu *menu) ...@@ -346,8 +349,16 @@ static void build_conf(struct menu *menu)
int type, tmp, doint = 2; int type, tmp, doint = 2;
tristate val; tristate val;
char ch; char ch;
bool visible;
if (!menu_is_visible(menu))
/*
* note: menu_is_visible() has side effect that it will
* recalc the value of the symbol.
*/
visible = menu_is_visible(menu);
if (show_all_options && !menu_has_prompt(menu))
return;
else if (!show_all_options && !visible)
return; return;
sym = menu->sym; sym = menu->sym;
...@@ -606,6 +617,9 @@ static void conf(struct menu *menu) ...@@ -606,6 +617,9 @@ static void conf(struct menu *menu)
case 7: case 7:
search_conf(); search_conf();
break; break;
case 8:
show_all_options = !show_all_options;
break;
} }
} }
} }
......
...@@ -390,6 +390,13 @@ void menu_finalize(struct menu *parent) ...@@ -390,6 +390,13 @@ void menu_finalize(struct menu *parent)
} }
} }
bool menu_has_prompt(struct menu *menu)
{
if (!menu->prompt)
return false;
return true;
}
bool menu_is_visible(struct menu *menu) bool menu_is_visible(struct menu *menu)
{ {
struct menu *child; struct menu *child;
...@@ -398,6 +405,7 @@ bool menu_is_visible(struct menu *menu) ...@@ -398,6 +405,7 @@ bool menu_is_visible(struct menu *menu)
if (!menu->prompt) if (!menu->prompt)
return false; return false;
sym = menu->sym; sym = menu->sym;
if (sym) { if (sym) {
sym_calc_value(sym); sym_calc_value(sym);
...@@ -407,12 +415,14 @@ bool menu_is_visible(struct menu *menu) ...@@ -407,12 +415,14 @@ bool menu_is_visible(struct menu *menu)
if (visible != no) if (visible != no)
return true; return true;
if (!sym || sym_get_tristate_value(menu->sym) == no) if (!sym || sym_get_tristate_value(menu->sym) == no)
return false; return false;
for (child = menu->list; child; child = child->next) for (child = menu->list; child; child = child->next)
if (menu_is_visible(child)) if (menu_is_visible(child))
return true; return true;
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment