diff options
author | Benjamin Poirier <bpoirier@suse.de> | 2013-04-16 10:07:23 -0400 |
---|---|---|
committer | Yann E. MORIN <yann.morin.1998@free.fr> | 2013-04-16 16:00:31 -0400 |
commit | 9a69abf80edf2ea0dac058cab156879d29362788 (patch) | |
tree | b94e9a202805b4de9afce670e17ba720592d2cc5 /scripts/kconfig/mconf.c | |
parent | edb749f4390b3c1604233dc7c4fb0361f472e712 (diff) |
menuconfig: Add "breadcrumbs" navigation aid
Displays a trail of the menu entries used to get to the current menu.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[yann.morin.1998@free.fr: small, trivial code re-ordering]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r-- | scripts/kconfig/mconf.c | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index c5418d622a05..387dc8daf7b2 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -311,6 +311,50 @@ static void set_config_filename(const char *config_filename) | |||
311 | filename[sizeof(filename)-1] = '\0'; | 311 | filename[sizeof(filename)-1] = '\0'; |
312 | } | 312 | } |
313 | 313 | ||
314 | struct subtitle_part { | ||
315 | struct list_head entries; | ||
316 | const char *text; | ||
317 | }; | ||
318 | static LIST_HEAD(trail); | ||
319 | |||
320 | static struct subtitle_list *subtitles; | ||
321 | static void set_subtitle(void) | ||
322 | { | ||
323 | struct subtitle_part *sp; | ||
324 | struct subtitle_list *pos, *tmp; | ||
325 | |||
326 | for (pos = subtitles; pos != NULL; pos = tmp) { | ||
327 | tmp = pos->next; | ||
328 | free(pos); | ||
329 | } | ||
330 | |||
331 | subtitles = NULL; | ||
332 | list_for_each_entry(sp, &trail, entries) { | ||
333 | if (sp->text) { | ||
334 | if (pos) { | ||
335 | pos->next = xcalloc(sizeof(*pos), 1); | ||
336 | pos = pos->next; | ||
337 | } else { | ||
338 | subtitles = pos = xcalloc(sizeof(*pos), 1); | ||
339 | } | ||
340 | pos->text = sp->text; | ||
341 | } | ||
342 | } | ||
343 | |||
344 | set_dialog_subtitles(subtitles); | ||
345 | } | ||
346 | |||
347 | static void reset_subtitle(void) | ||
348 | { | ||
349 | struct subtitle_list *pos, *tmp; | ||
350 | |||
351 | for (pos = subtitles; pos != NULL; pos = tmp) { | ||
352 | tmp = pos->next; | ||
353 | free(pos); | ||
354 | } | ||
355 | subtitles = NULL; | ||
356 | set_dialog_subtitles(subtitles); | ||
357 | } | ||
314 | 358 | ||
315 | struct search_data { | 359 | struct search_data { |
316 | struct list_head *head; | 360 | struct list_head *head; |
@@ -353,6 +397,8 @@ static void search_conf(void) | |||
353 | char *dialog_input; | 397 | char *dialog_input; |
354 | int dres, vscroll = 0, hscroll = 0; | 398 | int dres, vscroll = 0, hscroll = 0; |
355 | bool again; | 399 | bool again; |
400 | struct gstr sttext; | ||
401 | struct subtitle_part stpart; | ||
356 | 402 | ||
357 | title = str_new(); | 403 | title = str_new(); |
358 | str_printf( &title, _("Enter %s (sub)string to search for " | 404 | str_printf( &title, _("Enter %s (sub)string to search for " |
@@ -379,6 +425,11 @@ again: | |||
379 | if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) | 425 | if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) |
380 | dialog_input += strlen(CONFIG_); | 426 | dialog_input += strlen(CONFIG_); |
381 | 427 | ||
428 | sttext = str_new(); | ||
429 | str_printf(&sttext, "Search (%s)", dialog_input_result); | ||
430 | stpart.text = str_get(&sttext); | ||
431 | list_add_tail(&stpart.entries, &trail); | ||
432 | |||
382 | sym_arr = sym_re_search(dialog_input); | 433 | sym_arr = sym_re_search(dialog_input); |
383 | do { | 434 | do { |
384 | LIST_HEAD(head); | 435 | LIST_HEAD(head); |
@@ -392,6 +443,7 @@ again: | |||
392 | struct jump_key *pos, *tmp; | 443 | struct jump_key *pos, *tmp; |
393 | 444 | ||
394 | res = get_relations_str(sym_arr, &head); | 445 | res = get_relations_str(sym_arr, &head); |
446 | set_subtitle(); | ||
395 | dres = show_textbox_ext(_("Search Results"), (char *) | 447 | dres = show_textbox_ext(_("Search Results"), (char *) |
396 | str_get(&res), 0, 0, keys, &vscroll, | 448 | str_get(&res), 0, 0, keys, &vscroll, |
397 | &hscroll, &update_text, (void *) | 449 | &hscroll, &update_text, (void *) |
@@ -408,6 +460,8 @@ again: | |||
408 | } while (again); | 460 | } while (again); |
409 | free(sym_arr); | 461 | free(sym_arr); |
410 | str_free(&title); | 462 | str_free(&title); |
463 | list_del(trail.prev); | ||
464 | str_free(&sttext); | ||
411 | } | 465 | } |
412 | 466 | ||
413 | static void build_conf(struct menu *menu) | 467 | static void build_conf(struct menu *menu) |
@@ -592,16 +646,24 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
592 | { | 646 | { |
593 | struct menu *submenu; | 647 | struct menu *submenu; |
594 | const char *prompt = menu_get_prompt(menu); | 648 | const char *prompt = menu_get_prompt(menu); |
649 | struct subtitle_part stpart; | ||
595 | struct symbol *sym; | 650 | struct symbol *sym; |
596 | int res; | 651 | int res; |
597 | int s_scroll = 0; | 652 | int s_scroll = 0; |
598 | 653 | ||
654 | if (menu != &rootmenu) | ||
655 | stpart.text = menu_get_prompt(menu); | ||
656 | else | ||
657 | stpart.text = NULL; | ||
658 | list_add_tail(&stpart.entries, &trail); | ||
659 | |||
599 | while (1) { | 660 | while (1) { |
600 | item_reset(); | 661 | item_reset(); |
601 | current_menu = menu; | 662 | current_menu = menu; |
602 | build_conf(menu); | 663 | build_conf(menu); |
603 | if (!child_count) | 664 | if (!child_count) |
604 | break; | 665 | break; |
666 | set_subtitle(); | ||
605 | dialog_clear(); | 667 | dialog_clear(); |
606 | res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), | 668 | res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), |
607 | _(menu_instructions), | 669 | _(menu_instructions), |
@@ -643,13 +705,17 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
643 | case 2: | 705 | case 2: |
644 | if (sym) | 706 | if (sym) |
645 | show_help(submenu); | 707 | show_help(submenu); |
646 | else | 708 | else { |
709 | reset_subtitle(); | ||
647 | show_helptext(_("README"), _(mconf_readme)); | 710 | show_helptext(_("README"), _(mconf_readme)); |
711 | } | ||
648 | break; | 712 | break; |
649 | case 3: | 713 | case 3: |
714 | reset_subtitle(); | ||
650 | conf_save(); | 715 | conf_save(); |
651 | break; | 716 | break; |
652 | case 4: | 717 | case 4: |
718 | reset_subtitle(); | ||
653 | conf_load(); | 719 | conf_load(); |
654 | break; | 720 | break; |
655 | case 5: | 721 | case 5: |
@@ -682,6 +748,8 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
682 | break; | 748 | break; |
683 | } | 749 | } |
684 | } | 750 | } |
751 | |||
752 | list_del(trail.prev); | ||
685 | } | 753 | } |
686 | 754 | ||
687 | static int show_textbox_ext(const char *title, char *text, int r, int c, int | 755 | static int show_textbox_ext(const char *title, char *text, int r, int c, int |
@@ -884,6 +952,7 @@ static int handle_exit(void) | |||
884 | int res; | 952 | int res; |
885 | 953 | ||
886 | save_and_exit = 1; | 954 | save_and_exit = 1; |
955 | reset_subtitle(); | ||
887 | dialog_clear(); | 956 | dialog_clear(); |
888 | if (conf_get_changed()) | 957 | if (conf_get_changed()) |
889 | res = dialog_yesno(NULL, | 958 | res = dialog_yesno(NULL, |