diff options
author | Benjamin Poirier <bpoirier@suse.de> | 2012-08-23 14:55:06 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2012-09-27 12:09:24 -0400 |
commit | 5e609addb1bd963ce1a1929f2012c8dd04ca8620 (patch) | |
tree | 6ec819fc7af3de4bfcddb3f42c2a2c0121ed2653 /scripts/kconfig | |
parent | 1d1e2caebbf1f4f25ad473e90650cdc9291fdd22 (diff) |
menuconfig: Add jump keys to search results
makes it possible to jump directly to the menu for a configuration entry after
having searched for it with '/'. If this menu is not currently accessible we
jump to the nearest accessible parent instead. After exiting this menu, the
user is returned to the search results where he may jump further in or
elsewhere.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/expr.h | 2 | ||||
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 6 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 64 | ||||
-rw-r--r-- | scripts/kconfig/menu.c | 55 | ||||
-rw-r--r-- | scripts/kconfig/nconf.c | 2 |
5 files changed, 94 insertions, 35 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index d4ecce8bc3a6..52f4246bd34d 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -173,6 +173,8 @@ struct menu { | |||
173 | #define MENU_CHANGED 0x0001 | 173 | #define MENU_CHANGED 0x0001 |
174 | #define MENU_ROOT 0x0002 | 174 | #define MENU_ROOT 0x0002 |
175 | 175 | ||
176 | #define JUMP_NB 9 | ||
177 | |||
176 | extern struct file *file_list; | 178 | extern struct file *file_list; |
177 | extern struct file *current_file; | 179 | extern struct file *current_file; |
178 | struct file *lookup_file(const char *name); | 180 | struct file *lookup_file(const char *name); |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 47fe9c340f9a..946c2cb367f9 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -21,8 +21,10 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); | |||
21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | 21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); |
22 | P(menu_has_help,bool,(struct menu *menu)); | 22 | P(menu_has_help,bool,(struct menu *menu)); |
23 | P(menu_get_help,const char *,(struct menu *menu)); | 23 | P(menu_get_help,const char *,(struct menu *menu)); |
24 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym)); | 24 | P(get_symbol_str, int, (struct gstr *r, struct symbol *sym, struct menu |
25 | P(get_relations_str, struct gstr, (struct symbol **sym_arr)); | 25 | **jumps, int jump_nb)); |
26 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct menu | ||
27 | **jumps)); | ||
26 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); | 28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); |
27 | 29 | ||
28 | /* symbol.c */ | 30 | /* symbol.c */ |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index b3a37c2b16ae..6f409745b373 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -236,16 +236,19 @@ search_help[] = N_( | |||
236 | "Result:\n" | 236 | "Result:\n" |
237 | "-----------------------------------------------------------------\n" | 237 | "-----------------------------------------------------------------\n" |
238 | "Symbol: FOO [=m]\n" | 238 | "Symbol: FOO [=m]\n" |
239 | "Type : tristate\n" | ||
239 | "Prompt: Foo bus is used to drive the bar HW\n" | 240 | "Prompt: Foo bus is used to drive the bar HW\n" |
240 | "Defined at drivers/pci/Kconfig:47\n" | 241 | " Defined at drivers/pci/Kconfig:47\n" |
241 | "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" | 242 | " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" |
242 | "Location:\n" | 243 | " Location:\n" |
243 | " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" | 244 | " -> Bus options (PCI, PCMCIA, EISA, ISA)\n" |
244 | " -> PCI support (PCI [=y])\n" | 245 | " -> PCI support (PCI [=y])\n" |
245 | " -> PCI access mode (<choice> [=y])\n" | 246 | "(1) -> PCI access mode (<choice> [=y])\n" |
246 | "Selects: LIBCRC32\n" | 247 | " Selects: LIBCRC32\n" |
247 | "Selected by: BAR\n" | 248 | " Selected by: BAR\n" |
248 | "-----------------------------------------------------------------\n" | 249 | "-----------------------------------------------------------------\n" |
250 | "o The line 'Type:' shows the type of the configuration option for\n" | ||
251 | " this symbol (boolean, tristate, string, ...)\n" | ||
249 | "o The line 'Prompt:' shows the text used in the menu structure for\n" | 252 | "o The line 'Prompt:' shows the text used in the menu structure for\n" |
250 | " this symbol\n" | 253 | " this symbol\n" |
251 | "o The 'Defined at' line tell at what file / line number the symbol\n" | 254 | "o The 'Defined at' line tell at what file / line number the symbol\n" |
@@ -254,8 +257,12 @@ search_help[] = N_( | |||
254 | " this symbol to be visible in the menu (selectable)\n" | 257 | " this symbol to be visible in the menu (selectable)\n" |
255 | "o The 'Location:' lines tell where in the menu structure this symbol\n" | 258 | "o The 'Location:' lines tell where in the menu structure this symbol\n" |
256 | " is located\n" | 259 | " is located\n" |
257 | " A location followed by a [=y] indicate that this is a selectable\n" | 260 | " A location followed by a [=y] indicates that this is a\n" |
258 | " menu item - and current value is displayed inside brackets.\n" | 261 | " selectable menu item - and the current value is displayed inside\n" |
262 | " brackets.\n" | ||
263 | " Press the key in the (#) prefix to jump directly to that\n" | ||
264 | " location. You will be returned to the current search results\n" | ||
265 | " after exiting this new menu.\n" | ||
259 | "o The 'Selects:' line tell what symbol will be automatically\n" | 266 | "o The 'Selects:' line tell what symbol will be automatically\n" |
260 | " selected if this symbol is selected (y or m)\n" | 267 | " selected if this symbol is selected (y or m)\n" |
261 | "o The 'Selected by' line tell what symbol has selected this symbol\n" | 268 | "o The 'Selected by' line tell what symbol has selected this symbol\n" |
@@ -274,7 +281,7 @@ static int child_count; | |||
274 | static int single_menu_mode; | 281 | static int single_menu_mode; |
275 | static int show_all_options; | 282 | static int show_all_options; |
276 | 283 | ||
277 | static void conf(struct menu *menu); | 284 | static void conf(struct menu *menu, struct menu *active_menu); |
278 | static void conf_choice(struct menu *menu); | 285 | static void conf_choice(struct menu *menu); |
279 | static void conf_string(struct menu *menu); | 286 | static void conf_string(struct menu *menu); |
280 | static void conf_load(void); | 287 | static void conf_load(void); |
@@ -308,7 +315,9 @@ static void search_conf(void) | |||
308 | struct symbol **sym_arr; | 315 | struct symbol **sym_arr; |
309 | struct gstr res; | 316 | struct gstr res; |
310 | char *dialog_input; | 317 | char *dialog_input; |
311 | int dres; | 318 | int dres, vscroll = 0, hscroll = 0; |
319 | bool again; | ||
320 | |||
312 | again: | 321 | again: |
313 | dialog_clear(); | 322 | dialog_clear(); |
314 | dres = dialog_inputbox(_("Search Configuration Parameter"), | 323 | dres = dialog_inputbox(_("Search Configuration Parameter"), |
@@ -331,10 +340,24 @@ again: | |||
331 | dialog_input += strlen(CONFIG_); | 340 | dialog_input += strlen(CONFIG_); |
332 | 341 | ||
333 | sym_arr = sym_re_search(dialog_input); | 342 | sym_arr = sym_re_search(dialog_input); |
334 | res = get_relations_str(sym_arr); | 343 | do { |
344 | struct menu *jumps[JUMP_NB] = {0}; | ||
345 | int keys[JUMP_NB + 1] = {0}, i; | ||
346 | |||
347 | res = get_relations_str(sym_arr, jumps); | ||
348 | for (i = 0; i < JUMP_NB && jumps[i]; i++) | ||
349 | keys[i] = '1' + i; | ||
350 | dres = show_textbox_ext(_("Search Results"), str_get(&res), 0, | ||
351 | 0, keys, &vscroll, &hscroll); | ||
352 | again = false; | ||
353 | for (i = 0; i < JUMP_NB && jumps[i]; i++) | ||
354 | if (dres == keys[i]) { | ||
355 | conf(jumps[i]->parent, jumps[i]); | ||
356 | again = true; | ||
357 | } | ||
358 | str_free(&res); | ||
359 | } while (again); | ||
335 | free(sym_arr); | 360 | free(sym_arr); |
336 | show_textbox(_("Search Results"), str_get(&res), 0, 0); | ||
337 | str_free(&res); | ||
338 | } | 361 | } |
339 | 362 | ||
340 | static void build_conf(struct menu *menu) | 363 | static void build_conf(struct menu *menu) |
@@ -515,12 +538,11 @@ conf_childs: | |||
515 | indent -= doint; | 538 | indent -= doint; |
516 | } | 539 | } |
517 | 540 | ||
518 | static void conf(struct menu *menu) | 541 | static void conf(struct menu *menu, struct menu *active_menu) |
519 | { | 542 | { |
520 | struct menu *submenu; | 543 | struct menu *submenu; |
521 | const char *prompt = menu_get_prompt(menu); | 544 | const char *prompt = menu_get_prompt(menu); |
522 | struct symbol *sym; | 545 | struct symbol *sym; |
523 | struct menu *active_menu = NULL; | ||
524 | int res; | 546 | int res; |
525 | int s_scroll = 0; | 547 | int s_scroll = 0; |
526 | 548 | ||
@@ -563,13 +585,13 @@ static void conf(struct menu *menu) | |||
563 | if (single_menu_mode) | 585 | if (single_menu_mode) |
564 | submenu->data = (void *) (long) !submenu->data; | 586 | submenu->data = (void *) (long) !submenu->data; |
565 | else | 587 | else |
566 | conf(submenu); | 588 | conf(submenu, NULL); |
567 | break; | 589 | break; |
568 | case 't': | 590 | case 't': |
569 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) | 591 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) |
570 | conf_choice(submenu); | 592 | conf_choice(submenu); |
571 | else if (submenu->prompt->type == P_MENU) | 593 | else if (submenu->prompt->type == P_MENU) |
572 | conf(submenu); | 594 | conf(submenu, NULL); |
573 | break; | 595 | break; |
574 | case 's': | 596 | case 's': |
575 | conf_string(submenu); | 597 | conf_string(submenu); |
@@ -608,7 +630,7 @@ static void conf(struct menu *menu) | |||
608 | if (item_is_tag('t')) | 630 | if (item_is_tag('t')) |
609 | sym_toggle_tristate_value(sym); | 631 | sym_toggle_tristate_value(sym); |
610 | else if (item_is_tag('m')) | 632 | else if (item_is_tag('m')) |
611 | conf(submenu); | 633 | conf(submenu, NULL); |
612 | break; | 634 | break; |
613 | case 7: | 635 | case 7: |
614 | search_conf(); | 636 | search_conf(); |
@@ -877,7 +899,7 @@ int main(int ac, char **av) | |||
877 | 899 | ||
878 | set_config_filename(conf_get_configname()); | 900 | set_config_filename(conf_get_configname()); |
879 | do { | 901 | do { |
880 | conf(&rootmenu); | 902 | conf(&rootmenu, NULL); |
881 | res = handle_exit(); | 903 | res = handle_exit(); |
882 | } while (res == KEY_ESC); | 904 | } while (res == KEY_ESC); |
883 | 905 | ||
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 8c2a97e60faf..a5241859326a 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -507,10 +507,12 @@ const char *menu_get_help(struct menu *menu) | |||
507 | return ""; | 507 | return ""; |
508 | } | 508 | } |
509 | 509 | ||
510 | static void get_prompt_str(struct gstr *r, struct property *prop) | 510 | static int get_prompt_str(struct gstr *r, struct property *prop, struct menu |
511 | **jumps, int jump_nb) | ||
511 | { | 512 | { |
512 | int i, j; | 513 | int i, j; |
513 | struct menu *submenu[8], *menu; | 514 | char header[4]; |
515 | struct menu *submenu[8], *menu, *location = NULL; | ||
514 | 516 | ||
515 | str_printf(r, _("Prompt: %s\n"), _(prop->text)); | 517 | str_printf(r, _("Prompt: %s\n"), _(prop->text)); |
516 | str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, | 518 | str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, |
@@ -521,13 +523,34 @@ static void get_prompt_str(struct gstr *r, struct property *prop) | |||
521 | str_append(r, "\n"); | 523 | str_append(r, "\n"); |
522 | } | 524 | } |
523 | menu = prop->menu->parent; | 525 | menu = prop->menu->parent; |
524 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) | 526 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { |
527 | bool accessible = menu_is_visible(menu); | ||
528 | |||
525 | submenu[i++] = menu; | 529 | submenu[i++] = menu; |
530 | if (location == NULL && accessible) | ||
531 | location = menu; | ||
532 | } | ||
533 | if (jumps && jump_nb < JUMP_NB && location) { | ||
534 | if (menu_is_visible(prop->menu)) { | ||
535 | /* | ||
536 | * There is not enough room to put the hint at the | ||
537 | * beginning of the "Prompt" line. Put the hint on the | ||
538 | * last "Location" line even when it would belong on | ||
539 | * the former. | ||
540 | */ | ||
541 | jumps[jump_nb] = prop->menu; | ||
542 | } else | ||
543 | jumps[jump_nb] = location; | ||
544 | snprintf(header, 4, "(%d)", jump_nb + 1); | ||
545 | } else | ||
546 | location = NULL; | ||
547 | |||
526 | if (i > 0) { | 548 | if (i > 0) { |
527 | str_printf(r, _(" Location:\n")); | 549 | str_printf(r, _(" Location:\n")); |
528 | for (j = 4; --i >= 0; j += 2) { | 550 | for (j = 1; --i >= 0; j += 2) { |
529 | menu = submenu[i]; | 551 | menu = submenu[i]; |
530 | str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); | 552 | str_printf(r, "%s%*c-> %s", menu == location ? header |
553 | : " ", j, ' ', _(menu_get_prompt(menu))); | ||
531 | if (menu->sym) { | 554 | if (menu->sym) { |
532 | str_printf(r, " (%s [=%s])", menu->sym->name ? | 555 | str_printf(r, " (%s [=%s])", menu->sym->name ? |
533 | menu->sym->name : _("<choice>"), | 556 | menu->sym->name : _("<choice>"), |
@@ -536,12 +559,20 @@ static void get_prompt_str(struct gstr *r, struct property *prop) | |||
536 | str_append(r, "\n"); | 559 | str_append(r, "\n"); |
537 | } | 560 | } |
538 | } | 561 | } |
562 | |||
563 | return location ? 1 : 0; | ||
539 | } | 564 | } |
540 | 565 | ||
541 | void get_symbol_str(struct gstr *r, struct symbol *sym) | 566 | /* |
567 | * jumps is optional and may be NULL | ||
568 | * returns the number of jumps inserted | ||
569 | */ | ||
570 | int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps, | ||
571 | int jump_nb) | ||
542 | { | 572 | { |
543 | bool hit; | 573 | bool hit; |
544 | struct property *prop; | 574 | struct property *prop; |
575 | int i = 0; | ||
545 | 576 | ||
546 | if (sym && sym->name) { | 577 | if (sym && sym->name) { |
547 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, | 578 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, |
@@ -557,7 +588,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) | |||
557 | } | 588 | } |
558 | } | 589 | } |
559 | for_all_prompts(sym, prop) | 590 | for_all_prompts(sym, prop) |
560 | get_prompt_str(r, prop); | 591 | i += get_prompt_str(r, prop, jumps, jump_nb + i); |
561 | hit = false; | 592 | hit = false; |
562 | for_all_properties(sym, prop, P_SELECT) { | 593 | for_all_properties(sym, prop, P_SELECT) { |
563 | if (!hit) { | 594 | if (!hit) { |
@@ -575,16 +606,18 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) | |||
575 | str_append(r, "\n"); | 606 | str_append(r, "\n"); |
576 | } | 607 | } |
577 | str_append(r, "\n\n"); | 608 | str_append(r, "\n\n"); |
609 | |||
610 | return i; | ||
578 | } | 611 | } |
579 | 612 | ||
580 | struct gstr get_relations_str(struct symbol **sym_arr) | 613 | struct gstr get_relations_str(struct symbol **sym_arr, struct menu **jumps) |
581 | { | 614 | { |
582 | struct symbol *sym; | 615 | struct symbol *sym; |
583 | struct gstr res = str_new(); | 616 | struct gstr res = str_new(); |
584 | int i; | 617 | int i, jump_nb = 0; |
585 | 618 | ||
586 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | 619 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) |
587 | get_symbol_str(&res, sym); | 620 | jump_nb += get_symbol_str(&res, sym, jumps, jump_nb); |
588 | if (!i) | 621 | if (!i) |
589 | str_append(&res, _("No matches found.\n")); | 622 | str_append(&res, _("No matches found.\n")); |
590 | return res; | 623 | return res; |
@@ -603,5 +636,5 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) | |||
603 | } | 636 | } |
604 | str_printf(help, "%s\n", _(help_text)); | 637 | str_printf(help, "%s\n", _(help_text)); |
605 | if (sym) | 638 | if (sym) |
606 | get_symbol_str(help, sym); | 639 | get_symbol_str(help, sym, NULL, 0); |
607 | } | 640 | } |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 1704a8562a5d..87d4b15da951 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -721,7 +721,7 @@ again: | |||
721 | dialog_input += strlen(CONFIG_); | 721 | dialog_input += strlen(CONFIG_); |
722 | 722 | ||
723 | sym_arr = sym_re_search(dialog_input); | 723 | sym_arr = sym_re_search(dialog_input); |
724 | res = get_relations_str(sym_arr); | 724 | res = get_relations_str(sym_arr, NULL); |
725 | free(sym_arr); | 725 | free(sym_arr); |
726 | show_scroll_win(main_window, | 726 | show_scroll_win(main_window, |
727 | _("Search Results"), str_get(&res)); | 727 | _("Search Results"), str_get(&res)); |