diff options
Diffstat (limited to 'scripts/kconfig/menu.c')
| -rw-r--r-- | scripts/kconfig/menu.c | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 8c2a97e60faf..a3cade659f89 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 void get_prompt_str(struct gstr *r, struct property *prop, |
| 511 | struct jk_head *head) | ||
| 511 | { | 512 | { |
| 512 | int i, j; | 513 | int i, j; |
| 513 | struct menu *submenu[8], *menu; | 514 | struct menu *submenu[8], *menu, *location = NULL; |
| 515 | struct jump_key *jump; | ||
| 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,43 @@ 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 (head && location) { | ||
| 534 | jump = malloc(sizeof(struct jump_key)); | ||
| 535 | |||
| 536 | if (menu_is_visible(prop->menu)) { | ||
| 537 | /* | ||
| 538 | * There is not enough room to put the hint at the | ||
| 539 | * beginning of the "Prompt" line. Put the hint on the | ||
| 540 | * last "Location" line even when it would belong on | ||
| 541 | * the former. | ||
| 542 | */ | ||
| 543 | jump->target = prop->menu; | ||
| 544 | } else | ||
| 545 | jump->target = location; | ||
| 546 | |||
| 547 | if (CIRCLEQ_EMPTY(head)) | ||
| 548 | jump->index = 0; | ||
| 549 | else | ||
| 550 | jump->index = CIRCLEQ_LAST(head)->index + 1; | ||
| 551 | |||
| 552 | CIRCLEQ_INSERT_TAIL(head, jump, entries); | ||
| 553 | } | ||
| 554 | |||
| 526 | if (i > 0) { | 555 | if (i > 0) { |
| 527 | str_printf(r, _(" Location:\n")); | 556 | str_printf(r, _(" Location:\n")); |
| 528 | for (j = 4; --i >= 0; j += 2) { | 557 | for (j = 4; --i >= 0; j += 2) { |
| 529 | menu = submenu[i]; | 558 | menu = submenu[i]; |
| 530 | str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); | 559 | if (head && location && menu == location) |
| 560 | jump->offset = r->len - 1; | ||
| 561 | str_printf(r, "%*c-> %s", j, ' ', | ||
| 562 | _(menu_get_prompt(menu))); | ||
| 531 | if (menu->sym) { | 563 | if (menu->sym) { |
| 532 | str_printf(r, " (%s [=%s])", menu->sym->name ? | 564 | str_printf(r, " (%s [=%s])", menu->sym->name ? |
| 533 | menu->sym->name : _("<choice>"), | 565 | menu->sym->name : _("<choice>"), |
| @@ -538,7 +570,10 @@ static void get_prompt_str(struct gstr *r, struct property *prop) | |||
| 538 | } | 570 | } |
| 539 | } | 571 | } |
| 540 | 572 | ||
| 541 | void get_symbol_str(struct gstr *r, struct symbol *sym) | 573 | /* |
| 574 | * head is optional and may be NULL | ||
| 575 | */ | ||
| 576 | void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) | ||
| 542 | { | 577 | { |
| 543 | bool hit; | 578 | bool hit; |
| 544 | struct property *prop; | 579 | struct property *prop; |
| @@ -557,7 +592,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) | |||
| 557 | } | 592 | } |
| 558 | } | 593 | } |
| 559 | for_all_prompts(sym, prop) | 594 | for_all_prompts(sym, prop) |
| 560 | get_prompt_str(r, prop); | 595 | get_prompt_str(r, prop, head); |
| 561 | hit = false; | 596 | hit = false; |
| 562 | for_all_properties(sym, prop, P_SELECT) { | 597 | for_all_properties(sym, prop, P_SELECT) { |
| 563 | if (!hit) { | 598 | if (!hit) { |
| @@ -577,14 +612,14 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) | |||
| 577 | str_append(r, "\n\n"); | 612 | str_append(r, "\n\n"); |
| 578 | } | 613 | } |
| 579 | 614 | ||
| 580 | struct gstr get_relations_str(struct symbol **sym_arr) | 615 | struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) |
| 581 | { | 616 | { |
| 582 | struct symbol *sym; | 617 | struct symbol *sym; |
| 583 | struct gstr res = str_new(); | 618 | struct gstr res = str_new(); |
| 584 | int i; | 619 | int i; |
| 585 | 620 | ||
| 586 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | 621 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) |
| 587 | get_symbol_str(&res, sym); | 622 | get_symbol_str(&res, sym, head); |
| 588 | if (!i) | 623 | if (!i) |
| 589 | str_append(&res, _("No matches found.\n")); | 624 | str_append(&res, _("No matches found.\n")); |
| 590 | return res; | 625 | return res; |
| @@ -603,5 +638,5 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) | |||
| 603 | } | 638 | } |
| 604 | str_printf(help, "%s\n", _(help_text)); | 639 | str_printf(help, "%s\n", _(help_text)); |
| 605 | if (sym) | 640 | if (sym) |
| 606 | get_symbol_str(help, sym); | 641 | get_symbol_str(help, sym, NULL); |
| 607 | } | 642 | } |
