diff options
author | Wang YanQing <udknight@gmail.com> | 2012-12-18 20:50:58 -0500 |
---|---|---|
committer | Yann E. MORIN <yann.morin.1998@free.fr> | 2013-01-15 18:00:34 -0500 |
commit | 6364fd0cb1e4c7f72b974613e0cf5744ae4d2cb2 (patch) | |
tree | 82ddce27af13bb046b75b89470bb505908affb2b /scripts/kconfig/mconf.c | |
parent | 87727d453b4677a21312712c8a4bb5dcd81a1ebe (diff) |
menuconfig: Add Save/Load buttons
If menuconfig have Save/Load button like alternative
.config editors, xconfig, nconfig, etc.We will have
a obvious benefit when use menuconfig just like
when we use others, we can Save/Load our .config quickly
and conveniently.
This patch add the Save/Load button for menuconfig.
[remove trailing space while at it for below line:
"*) Formerly when I used Page Down and Page Up, the cursor would be set"
]
Changes:
V1-V2:
1:use PATH_MAX instead of hard code suggested by Yann E. MORIN
2:drop the spurious empty-line removal suggested by Yann E. MORIN
V2-V3:
1:ajust buttons position well centered reported by Yann E. MORIN
Signed-off-by: Wang YanQing <udknight@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
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 | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 5f29618d1845..88e806857dc3 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -280,6 +280,7 @@ static struct menu *current_menu; | |||
280 | static int child_count; | 280 | static int child_count; |
281 | static int single_menu_mode; | 281 | static int single_menu_mode; |
282 | static int show_all_options; | 282 | static int show_all_options; |
283 | static int save_and_exit; | ||
283 | 284 | ||
284 | static void conf(struct menu *menu, struct menu *active_menu); | 285 | static void conf(struct menu *menu, struct menu *active_menu); |
285 | static void conf_choice(struct menu *menu); | 286 | static void conf_choice(struct menu *menu); |
@@ -657,6 +658,12 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
657 | show_helptext(_("README"), _(mconf_readme)); | 658 | show_helptext(_("README"), _(mconf_readme)); |
658 | break; | 659 | break; |
659 | case 3: | 660 | case 3: |
661 | conf_save(); | ||
662 | break; | ||
663 | case 4: | ||
664 | conf_load(); | ||
665 | break; | ||
666 | case 5: | ||
660 | if (item_is_tag('t')) { | 667 | if (item_is_tag('t')) { |
661 | if (sym_set_tristate_value(sym, yes)) | 668 | if (sym_set_tristate_value(sym, yes)) |
662 | break; | 669 | break; |
@@ -664,24 +671,24 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
664 | show_textbox(NULL, setmod_text, 6, 74); | 671 | show_textbox(NULL, setmod_text, 6, 74); |
665 | } | 672 | } |
666 | break; | 673 | break; |
667 | case 4: | 674 | case 6: |
668 | if (item_is_tag('t')) | 675 | if (item_is_tag('t')) |
669 | sym_set_tristate_value(sym, no); | 676 | sym_set_tristate_value(sym, no); |
670 | break; | 677 | break; |
671 | case 5: | 678 | case 7: |
672 | if (item_is_tag('t')) | 679 | if (item_is_tag('t')) |
673 | sym_set_tristate_value(sym, mod); | 680 | sym_set_tristate_value(sym, mod); |
674 | break; | 681 | break; |
675 | case 6: | 682 | case 8: |
676 | if (item_is_tag('t')) | 683 | if (item_is_tag('t')) |
677 | sym_toggle_tristate_value(sym); | 684 | sym_toggle_tristate_value(sym); |
678 | else if (item_is_tag('m')) | 685 | else if (item_is_tag('m')) |
679 | conf(submenu, NULL); | 686 | conf(submenu, NULL); |
680 | break; | 687 | break; |
681 | case 7: | 688 | case 9: |
682 | search_conf(); | 689 | search_conf(); |
683 | break; | 690 | break; |
684 | case 8: | 691 | case 10: |
685 | show_all_options = !show_all_options; | 692 | show_all_options = !show_all_options; |
686 | break; | 693 | break; |
687 | } | 694 | } |
@@ -708,6 +715,17 @@ static void show_helptext(const char *title, const char *text) | |||
708 | show_textbox(title, text, 0, 0); | 715 | show_textbox(title, text, 0, 0); |
709 | } | 716 | } |
710 | 717 | ||
718 | static void conf_message_callback(const char *fmt, va_list ap) | ||
719 | { | ||
720 | char buf[PATH_MAX+1]; | ||
721 | |||
722 | vsnprintf(buf, sizeof(buf), fmt, ap); | ||
723 | if (save_and_exit) | ||
724 | printf("%s", buf); | ||
725 | else | ||
726 | show_textbox(NULL, buf, 6, 60); | ||
727 | } | ||
728 | |||
711 | static void show_help(struct menu *menu) | 729 | static void show_help(struct menu *menu) |
712 | { | 730 | { |
713 | struct gstr help = str_new(); | 731 | struct gstr help = str_new(); |
@@ -876,6 +894,7 @@ static int handle_exit(void) | |||
876 | { | 894 | { |
877 | int res; | 895 | int res; |
878 | 896 | ||
897 | save_and_exit = 1; | ||
879 | dialog_clear(); | 898 | dialog_clear(); |
880 | if (conf_get_changed()) | 899 | if (conf_get_changed()) |
881 | res = dialog_yesno(NULL, | 900 | res = dialog_yesno(NULL, |
@@ -947,6 +966,7 @@ int main(int ac, char **av) | |||
947 | } | 966 | } |
948 | 967 | ||
949 | set_config_filename(conf_get_configname()); | 968 | set_config_filename(conf_get_configname()); |
969 | conf_set_message_callback(conf_message_callback); | ||
950 | do { | 970 | do { |
951 | conf(&rootmenu, NULL); | 971 | conf(&rootmenu, NULL); |
952 | res = handle_exit(); | 972 | res = handle_exit(); |