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 | |
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')
-rw-r--r-- | scripts/kconfig/lxdialog/menubox.c | 20 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 30 |
2 files changed, 36 insertions, 14 deletions
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index 1d604738fa13..48d382e7e374 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * | 26 | * |
27 | * *) A bugfix for the Page-Down problem | 27 | * *) A bugfix for the Page-Down problem |
28 | * | 28 | * |
29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set | 29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set |
30 | * to the first position in the menu box. Now lxdialog is a bit | 30 | * to the first position in the menu box. Now lxdialog is a bit |
31 | * smarter and works more like other menu systems (just have a look at | 31 | * smarter and works more like other menu systems (just have a look at |
32 | * it). | 32 | * it). |
@@ -154,12 +154,14 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, | |||
154 | */ | 154 | */ |
155 | static void print_buttons(WINDOW * win, int height, int width, int selected) | 155 | static void print_buttons(WINDOW * win, int height, int width, int selected) |
156 | { | 156 | { |
157 | int x = width / 2 - 16; | 157 | int x = width / 2 - 28; |
158 | int y = height - 2; | 158 | int y = height - 2; |
159 | 159 | ||
160 | print_button(win, gettext("Select"), y, x, selected == 0); | 160 | print_button(win, gettext("Select"), y, x, selected == 0); |
161 | print_button(win, gettext(" Exit "), y, x + 12, selected == 1); | 161 | print_button(win, gettext(" Exit "), y, x + 12, selected == 1); |
162 | print_button(win, gettext(" Help "), y, x + 24, selected == 2); | 162 | print_button(win, gettext(" Help "), y, x + 24, selected == 2); |
163 | print_button(win, gettext(" Save "), y, x + 36, selected == 3); | ||
164 | print_button(win, gettext(" Load "), y, x + 48, selected == 4); | ||
163 | 165 | ||
164 | wmove(win, y, x + 1 + 12 * selected); | 166 | wmove(win, y, x + 1 + 12 * selected); |
165 | wrefresh(win); | 167 | wrefresh(win); |
@@ -372,7 +374,7 @@ do_resize: | |||
372 | case TAB: | 374 | case TAB: |
373 | case KEY_RIGHT: | 375 | case KEY_RIGHT: |
374 | button = ((key == KEY_LEFT ? --button : ++button) < 0) | 376 | button = ((key == KEY_LEFT ? --button : ++button) < 0) |
375 | ? 2 : (button > 2 ? 0 : button); | 377 | ? 4 : (button > 4 ? 0 : button); |
376 | 378 | ||
377 | print_buttons(dialog, height, width, button); | 379 | print_buttons(dialog, height, width, button); |
378 | wrefresh(menu); | 380 | wrefresh(menu); |
@@ -399,17 +401,17 @@ do_resize: | |||
399 | return 2; | 401 | return 2; |
400 | case 's': | 402 | case 's': |
401 | case 'y': | 403 | case 'y': |
402 | return 3; | 404 | return 5; |
403 | case 'n': | 405 | case 'n': |
404 | return 4; | 406 | return 6; |
405 | case 'm': | 407 | case 'm': |
406 | return 5; | 408 | return 7; |
407 | case ' ': | 409 | case ' ': |
408 | return 6; | 410 | return 8; |
409 | case '/': | 411 | case '/': |
410 | return 7; | 412 | return 9; |
411 | case 'z': | 413 | case 'z': |
412 | return 8; | 414 | return 10; |
413 | case '\n': | 415 | case '\n': |
414 | return button; | 416 | return button; |
415 | } | 417 | } |
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(); |