aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/menu.c
diff options
context:
space:
mode:
authorBenjamin Poirier <bpoirier@suse.de>2012-08-23 14:55:08 -0400
committerMichal Marek <mmarek@suse.cz>2012-09-27 12:09:24 -0400
commit95ac9b3b585d20df116c5bea1511d9eb5758ac81 (patch)
treec106d3003823ecbda997f295c75974385d560b9e /scripts/kconfig/menu.c
parent1a374ae6191e9c440f1953a264a94d38173737be (diff)
menuconfig: Assign jump keys per-page instead of globally
At the moment, keys 1-9 are assigned to the first 9 search results. This patch makes them assigned to the first 9 results per-page instead. We are much less likely to run out of keys that way. Signed-off-by: Benjamin Poirier <bpoirier@suse.de> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/kconfig/menu.c')
-rw-r--r--scripts/kconfig/menu.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index a5241859326a..a3cade659f89 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -507,12 +507,12 @@ const char *menu_get_help(struct menu *menu)
507 return ""; 507 return "";
508} 508}
509 509
510static int get_prompt_str(struct gstr *r, struct property *prop, struct menu 510static void get_prompt_str(struct gstr *r, struct property *prop,
511 **jumps, int jump_nb) 511 struct jk_head *head)
512{ 512{
513 int i, j; 513 int i, j;
514 char header[4];
515 struct menu *submenu[8], *menu, *location = NULL; 514 struct menu *submenu[8], *menu, *location = NULL;
515 struct jump_key *jump;
516 516
517 str_printf(r, _("Prompt: %s\n"), _(prop->text)); 517 str_printf(r, _("Prompt: %s\n"), _(prop->text));
518 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,
@@ -530,7 +530,9 @@ static int get_prompt_str(struct gstr *r, struct property *prop, struct menu
530 if (location == NULL && accessible) 530 if (location == NULL && accessible)
531 location = menu; 531 location = menu;
532 } 532 }
533 if (jumps && jump_nb < JUMP_NB && location) { 533 if (head && location) {
534 jump = malloc(sizeof(struct jump_key));
535
534 if (menu_is_visible(prop->menu)) { 536 if (menu_is_visible(prop->menu)) {
535 /* 537 /*
536 * There is not enough room to put the hint at the 538 * There is not enough room to put the hint at the
@@ -538,19 +540,26 @@ static int get_prompt_str(struct gstr *r, struct property *prop, struct menu
538 * last "Location" line even when it would belong on 540 * last "Location" line even when it would belong on
539 * the former. 541 * the former.
540 */ 542 */
541 jumps[jump_nb] = prop->menu; 543 jump->target = prop->menu;
542 } else 544 } else
543 jumps[jump_nb] = location; 545 jump->target = location;
544 snprintf(header, 4, "(%d)", jump_nb + 1); 546
545 } else 547 if (CIRCLEQ_EMPTY(head))
546 location = NULL; 548 jump->index = 0;
549 else
550 jump->index = CIRCLEQ_LAST(head)->index + 1;
551
552 CIRCLEQ_INSERT_TAIL(head, jump, entries);
553 }
547 554
548 if (i > 0) { 555 if (i > 0) {
549 str_printf(r, _(" Location:\n")); 556 str_printf(r, _(" Location:\n"));
550 for (j = 1; --i >= 0; j += 2) { 557 for (j = 4; --i >= 0; j += 2) {
551 menu = submenu[i]; 558 menu = submenu[i];
552 str_printf(r, "%s%*c-> %s", menu == location ? header 559 if (head && location && menu == location)
553 : " ", j, ' ', _(menu_get_prompt(menu))); 560 jump->offset = r->len - 1;
561 str_printf(r, "%*c-> %s", j, ' ',
562 _(menu_get_prompt(menu)));
554 if (menu->sym) { 563 if (menu->sym) {
555 str_printf(r, " (%s [=%s])", menu->sym->name ? 564 str_printf(r, " (%s [=%s])", menu->sym->name ?
556 menu->sym->name : _("<choice>"), 565 menu->sym->name : _("<choice>"),
@@ -559,20 +568,15 @@ static int get_prompt_str(struct gstr *r, struct property *prop, struct menu
559 str_append(r, "\n"); 568 str_append(r, "\n");
560 } 569 }
561 } 570 }
562
563 return location ? 1 : 0;
564} 571}
565 572
566/* 573/*
567 * jumps is optional and may be NULL 574 * head is optional and may be NULL
568 * returns the number of jumps inserted
569 */ 575 */
570int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps, 576void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
571 int jump_nb)
572{ 577{
573 bool hit; 578 bool hit;
574 struct property *prop; 579 struct property *prop;
575 int i = 0;
576 580
577 if (sym && sym->name) { 581 if (sym && sym->name) {
578 str_printf(r, "Symbol: %s [=%s]\n", sym->name, 582 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
@@ -588,7 +592,7 @@ int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps,
588 } 592 }
589 } 593 }
590 for_all_prompts(sym, prop) 594 for_all_prompts(sym, prop)
591 i += get_prompt_str(r, prop, jumps, jump_nb + i); 595 get_prompt_str(r, prop, head);
592 hit = false; 596 hit = false;
593 for_all_properties(sym, prop, P_SELECT) { 597 for_all_properties(sym, prop, P_SELECT) {
594 if (!hit) { 598 if (!hit) {
@@ -606,18 +610,16 @@ int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps,
606 str_append(r, "\n"); 610 str_append(r, "\n");
607 } 611 }
608 str_append(r, "\n\n"); 612 str_append(r, "\n\n");
609
610 return i;
611} 613}
612 614
613struct gstr get_relations_str(struct symbol **sym_arr, struct menu **jumps) 615struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head)
614{ 616{
615 struct symbol *sym; 617 struct symbol *sym;
616 struct gstr res = str_new(); 618 struct gstr res = str_new();
617 int i, jump_nb = 0; 619 int i;
618 620
619 for (i = 0; sym_arr && (sym = sym_arr[i]); i++) 621 for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
620 jump_nb += get_symbol_str(&res, sym, jumps, jump_nb); 622 get_symbol_str(&res, sym, head);
621 if (!i) 623 if (!i)
622 str_append(&res, _("No matches found.\n")); 624 str_append(&res, _("No matches found.\n"));
623 return res; 625 return res;
@@ -636,5 +638,5 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help)
636 } 638 }
637 str_printf(help, "%s\n", _(help_text)); 639 str_printf(help, "%s\n", _(help_text));
638 if (sym) 640 if (sym)
639 get_symbol_str(help, sym, NULL, 0); 641 get_symbol_str(help, sym, NULL);
640} 642}