aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/menu.c')
-rw-r--r--scripts/kconfig/menu.c55
1 files changed, 44 insertions, 11 deletions
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
510static void get_prompt_str(struct gstr *r, struct property *prop) 510static 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
541void 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 */
570int 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
580struct gstr get_relations_str(struct symbol **sym_arr) 613struct 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}