nconf.c (a6cbfa1e6d38c4b3ab0ce7e3aea4bb4e744f24b8) | nconf.c (694c49a7c01cc87194be40cb26404b58b68c291c) |
---|---|
1/* 2 * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com? 3 * Released under the terms of the GNU GPL v2.0. 4 * 5 * Derived from menuconfig. 6 * 7 */ 8#ifndef _GNU_SOURCE 9#define _GNU_SOURCE 10#endif 11#include <string.h> 12#include <stdlib.h> 13 14#include "lkc.h" 15#include "nconf.h" 16#include <ctype.h> 17 | 1/* 2 * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com? 3 * Released under the terms of the GNU GPL v2.0. 4 * 5 * Derived from menuconfig. 6 * 7 */ 8#ifndef _GNU_SOURCE 9#define _GNU_SOURCE 10#endif 11#include <string.h> 12#include <stdlib.h> 13 14#include "lkc.h" 15#include "nconf.h" 16#include <ctype.h> 17 |
18static const char nconf_global_help[] = N_( | 18static const char nconf_global_help[] = |
19"Help windows\n" 20"------------\n" 21"o Global help: Unless in a data entry window, pressing <F1> will give \n" 22" you the global help window, which you are just reading.\n" 23"\n" 24"o A short version of the global help is available by pressing <F3>.\n" 25"\n" 26"o Local help: To get help related to the current menu entry, use any\n" --- 98 unchanged lines hidden (view full) --- 125"make NCONFIG_MODE=single_menu nconfig\n" 126"\n" 127"<Enter> will then unfold the appropriate category, or fold it if it\n" 128"is already unfolded. Folded menu entries will be designated by a\n" 129"leading \"++>\" and unfolded entries by a leading \"-->\".\n" 130"\n" 131"Note that this mode can eventually be a little more CPU expensive than\n" 132"the default mode, especially with a larger number of unfolded submenus.\n" | 19"Help windows\n" 20"------------\n" 21"o Global help: Unless in a data entry window, pressing <F1> will give \n" 22" you the global help window, which you are just reading.\n" 23"\n" 24"o A short version of the global help is available by pressing <F3>.\n" 25"\n" 26"o Local help: To get help related to the current menu entry, use any\n" --- 98 unchanged lines hidden (view full) --- 125"make NCONFIG_MODE=single_menu nconfig\n" 126"\n" 127"<Enter> will then unfold the appropriate category, or fold it if it\n" 128"is already unfolded. Folded menu entries will be designated by a\n" 129"leading \"++>\" and unfolded entries by a leading \"-->\".\n" 130"\n" 131"Note that this mode can eventually be a little more CPU expensive than\n" 132"the default mode, especially with a larger number of unfolded submenus.\n" |
133"\n"), 134menu_no_f_instructions[] = N_( | 133"\n", 134menu_no_f_instructions[] = |
135"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 136"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" 137"\n" 138"Use the following keys to navigate the menus:\n" 139"Move up or down with <Up> and <Down>.\n" 140"Enter a submenu with <Enter> or <Right>.\n" 141"Exit a submenu to its parent menu with <Esc> or <Left>.\n" 142"Pressing <y> includes, <n> excludes, <m> modularizes features.\n" 143"Pressing <Space> cycles through the available options.\n" 144"To search for menu entries press </>.\n" 145"<Esc> always leaves the current window.\n" 146"\n" 147"You do not have function keys support.\n" 148"Press <1> instead of <F1>, <2> instead of <F2>, etc.\n" 149"For verbose global help use key <1>.\n" | 135"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 136"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" 137"\n" 138"Use the following keys to navigate the menus:\n" 139"Move up or down with <Up> and <Down>.\n" 140"Enter a submenu with <Enter> or <Right>.\n" 141"Exit a submenu to its parent menu with <Esc> or <Left>.\n" 142"Pressing <y> includes, <n> excludes, <m> modularizes features.\n" 143"Pressing <Space> cycles through the available options.\n" 144"To search for menu entries press </>.\n" 145"<Esc> always leaves the current window.\n" 146"\n" 147"You do not have function keys support.\n" 148"Press <1> instead of <F1>, <2> instead of <F2>, etc.\n" 149"For verbose global help use key <1>.\n" |
150"For help related to the current menu entry press <?> or <h>.\n"), 151menu_instructions[] = N_( | 150"For help related to the current menu entry press <?> or <h>.\n", 151menu_instructions[] = |
152"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 153"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" 154"\n" 155"Use the following keys to navigate the menus:\n" 156"Move up or down with <Up> or <Down>.\n" 157"Enter a submenu with <Enter> or <Right>.\n" 158"Exit a submenu to its parent menu with <Esc> or <Left>.\n" 159"Pressing <y> includes, <n> excludes, <m> modularizes features.\n" 160"Pressing <Space> cycles through the available options.\n" 161"To search for menu entries press </>.\n" 162"<Esc> always leaves the current window.\n" 163"\n" 164"Pressing <1> may be used instead of <F1>, <2> instead of <F2>, etc.\n" 165"For verbose global help press <F1>.\n" | 152"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 153"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" 154"\n" 155"Use the following keys to navigate the menus:\n" 156"Move up or down with <Up> or <Down>.\n" 157"Enter a submenu with <Enter> or <Right>.\n" 158"Exit a submenu to its parent menu with <Esc> or <Left>.\n" 159"Pressing <y> includes, <n> excludes, <m> modularizes features.\n" 160"Pressing <Space> cycles through the available options.\n" 161"To search for menu entries press </>.\n" 162"<Esc> always leaves the current window.\n" 163"\n" 164"Pressing <1> may be used instead of <F1>, <2> instead of <F2>, etc.\n" 165"For verbose global help press <F1>.\n" |
166"For help related to the current menu entry press <?> or <h>.\n"), 167radiolist_instructions[] = N_( | 166"For help related to the current menu entry press <?> or <h>.\n", 167radiolist_instructions[] = |
168"Press <Up>, <Down>, <Home> or <End> to navigate a radiolist, select\n" 169"with <Space>.\n" 170"For help related to the current entry press <?> or <h>.\n" | 168"Press <Up>, <Down>, <Home> or <End> to navigate a radiolist, select\n" 169"with <Space>.\n" 170"For help related to the current entry press <?> or <h>.\n" |
171"For global help press <F1>.\n"), 172inputbox_instructions_int[] = N_( | 171"For global help press <F1>.\n", 172inputbox_instructions_int[] = |
173"Please enter a decimal value.\n" 174"Fractions will not be accepted.\n" | 173"Please enter a decimal value.\n" 174"Fractions will not be accepted.\n" |
175"Press <Enter> to apply, <Esc> to cancel."), 176inputbox_instructions_hex[] = N_( | 175"Press <Enter> to apply, <Esc> to cancel.", 176inputbox_instructions_hex[] = |
177"Please enter a hexadecimal value.\n" | 177"Please enter a hexadecimal value.\n" |
178"Press <Enter> to apply, <Esc> to cancel."), 179inputbox_instructions_string[] = N_( | 178"Press <Enter> to apply, <Esc> to cancel.", 179inputbox_instructions_string[] = |
180"Please enter a string value.\n" | 180"Please enter a string value.\n" |
181"Press <Enter> to apply, <Esc> to cancel."), 182setmod_text[] = N_( | 181"Press <Enter> to apply, <Esc> to cancel.", 182setmod_text[] = |
183"This feature depends on another feature which has been configured as a\n" | 183"This feature depends on another feature which has been configured as a\n" |
184"module. As a result, the current feature will be built as a module too."), 185load_config_text[] = N_( | 184"module. As a result, the current feature will be built as a module too.", 185load_config_text[] = |
186"Enter the name of the configuration file you wish to load.\n" 187"Accept the name shown to restore the configuration you last\n" | 186"Enter the name of the configuration file you wish to load.\n" 187"Accept the name shown to restore the configuration you last\n" |
188"retrieved. Leave empty to abort."), 189load_config_help[] = N_( | 188"retrieved. Leave empty to abort.", 189load_config_help[] = |
190"For various reasons, one may wish to keep several different\n" 191"configurations available on a single machine.\n" 192"\n" 193"If you have saved a previous configuration in a file other than the\n" 194"default one, entering its name here will allow you to load and modify\n" 195"that configuration.\n" 196"\n" | 190"For various reasons, one may wish to keep several different\n" 191"configurations available on a single machine.\n" 192"\n" 193"If you have saved a previous configuration in a file other than the\n" 194"default one, entering its name here will allow you to load and modify\n" 195"that configuration.\n" 196"\n" |
197"Leave empty to abort.\n"), 198save_config_text[] = N_( | 197"Leave empty to abort.\n", 198save_config_text[] = |
199"Enter a filename to which this configuration should be saved\n" | 199"Enter a filename to which this configuration should be saved\n" |
200"as an alternate. Leave empty to abort."), 201save_config_help[] = N_( | 200"as an alternate. Leave empty to abort.", 201save_config_help[] = |
202"For various reasons, one may wish to keep several different\n" 203"configurations available on a single machine.\n" 204"\n" 205"Entering a file name here will allow you to later retrieve, modify\n" 206"and use the current configuration as an alternate to whatever\n" 207"configuration options you have selected at that time.\n" 208"\n" | 202"For various reasons, one may wish to keep several different\n" 203"configurations available on a single machine.\n" 204"\n" 205"Entering a file name here will allow you to later retrieve, modify\n" 206"and use the current configuration as an alternate to whatever\n" 207"configuration options you have selected at that time.\n" 208"\n" |
209"Leave empty to abort.\n"), 210search_help[] = N_( | 209"Leave empty to abort.\n", 210search_help[] = |
211"Search for symbols (configuration variable names CONFIG_*) and display\n" 212"their relations. Regular expressions are supported.\n" 213"Example: Search for \"^FOO\".\n" 214"Result:\n" 215"-----------------------------------------------------------------\n" 216"Symbol: FOO [ = m]\n" 217"Prompt: Foo bus is used to drive the bar HW\n" 218"Defined at drivers/pci/Kconfig:47\n" --- 20 unchanged lines hidden (view full) --- 239"o The 'Selected by' line tells what symbol has selected this symbol.\n" 240"\n" 241"Only relevant lines are shown.\n" 242"\n\n" 243"Search examples:\n" 244"USB => find all symbols containing USB\n" 245"^USB => find all symbols starting with USB\n" 246"USB$ => find all symbols ending with USB\n" | 211"Search for symbols (configuration variable names CONFIG_*) and display\n" 212"their relations. Regular expressions are supported.\n" 213"Example: Search for \"^FOO\".\n" 214"Result:\n" 215"-----------------------------------------------------------------\n" 216"Symbol: FOO [ = m]\n" 217"Prompt: Foo bus is used to drive the bar HW\n" 218"Defined at drivers/pci/Kconfig:47\n" --- 20 unchanged lines hidden (view full) --- 239"o The 'Selected by' line tells what symbol has selected this symbol.\n" 240"\n" 241"Only relevant lines are shown.\n" 242"\n\n" 243"Search examples:\n" 244"USB => find all symbols containing USB\n" 245"^USB => find all symbols starting with USB\n" 246"USB$ => find all symbols ending with USB\n" |
247"\n"); | 247"\n"; |
248 249struct mitem { 250 char str[256]; 251 char tag; 252 void *usrptr; 253 int is_visible; 254}; 255 --- 127 unchanged lines hidden (view full) --- 383 } 384 (void) wattrset(main_window, attributes[NORMAL]); 385} 386 387/* help */ 388static void handle_f1(int *key, struct menu *current_item) 389{ 390 show_scroll_win(main_window, | 248 249struct mitem { 250 char str[256]; 251 char tag; 252 void *usrptr; 253 int is_visible; 254}; 255 --- 127 unchanged lines hidden (view full) --- 383 } 384 (void) wattrset(main_window, attributes[NORMAL]); 385} 386 387/* help */ 388static void handle_f1(int *key, struct menu *current_item) 389{ 390 show_scroll_win(main_window, |
391 _("Global help"), _(nconf_global_help)); | 391 "Global help", nconf_global_help); |
392 return; 393} 394 395/* symbole help */ 396static void handle_f2(int *key, struct menu *current_item) 397{ 398 show_help(current_item); 399 return; 400} 401 402/* instructions */ 403static void handle_f3(int *key, struct menu *current_item) 404{ 405 show_scroll_win(main_window, | 392 return; 393} 394 395/* symbole help */ 396static void handle_f2(int *key, struct menu *current_item) 397{ 398 show_help(current_item); 399 return; 400} 401 402/* instructions */ 403static void handle_f3(int *key, struct menu *current_item) 404{ 405 show_scroll_win(main_window, |
406 _("Short help"), 407 _(current_instructions)); | 406 "Short help", 407 current_instructions); |
408 return; 409} 410 411/* config */ 412static void handle_f4(int *key, struct menu *current_item) 413{ 414 int res = btn_dialog(main_window, | 408 return; 409} 410 411/* config */ 412static void handle_f4(int *key, struct menu *current_item) 413{ 414 int res = btn_dialog(main_window, |
415 _("Show all symbols?"), | 415 "Show all symbols?", |
416 2, 417 " <Show All> ", 418 "<Don't show all>"); 419 if (res == 0) 420 show_all_items = 1; 421 else if (res == 1) 422 show_all_items = 0; 423 --- 224 unchanged lines hidden (view full) --- 648static int do_exit(void) 649{ 650 int res; 651 if (!conf_get_changed()) { 652 global_exit = 1; 653 return 0; 654 } 655 res = btn_dialog(main_window, | 416 2, 417 " <Show All> ", 418 "<Don't show all>"); 419 if (res == 0) 420 show_all_items = 1; 421 else if (res == 1) 422 show_all_items = 0; 423 --- 224 unchanged lines hidden (view full) --- 648static int do_exit(void) 649{ 650 int res; 651 if (!conf_get_changed()) { 652 global_exit = 1; 653 return 0; 654 } 655 res = btn_dialog(main_window, |
656 _("Do you wish to save your new configuration?\n" 657 "<ESC> to cancel and resume nconfig."), | 656 "Do you wish to save your new configuration?\n" 657 "<ESC> to cancel and resume nconfig.", |
658 2, 659 " <save> ", 660 "<don't save>"); 661 if (res == KEY_EXIT) { 662 global_exit = 0; 663 return -1; 664 } 665 666 /* if we got here, the user really wants to exit */ 667 switch (res) { 668 case 0: 669 res = conf_write(filename); 670 if (res) 671 btn_dialog( 672 main_window, | 658 2, 659 " <save> ", 660 "<don't save>"); 661 if (res == KEY_EXIT) { 662 global_exit = 0; 663 return -1; 664 } 665 666 /* if we got here, the user really wants to exit */ 667 switch (res) { 668 case 0: 669 res = conf_write(filename); 670 if (res) 671 btn_dialog( 672 main_window, |
673 _("Error during writing of configuration.\n" 674 "Your configuration changes were NOT saved."), | 673 "Error during writing of configuration.\n" 674 "Your configuration changes were NOT saved.", |
675 1, 676 "<OK>"); 677 break; 678 default: 679 btn_dialog( 680 main_window, | 675 1, 676 "<OK>"); 677 break; 678 default: 679 btn_dialog( 680 main_window, |
681 _("Your configuration changes were NOT saved."), | 681 "Your configuration changes were NOT saved.", |
682 1, 683 "<OK>"); 684 break; 685 } 686 global_exit = 1; 687 return 0; 688} 689 690 691static void search_conf(void) 692{ 693 struct symbol **sym_arr; 694 struct gstr res; 695 struct gstr title; 696 char *dialog_input; 697 int dres; 698 699 title = str_new(); | 682 1, 683 "<OK>"); 684 break; 685 } 686 global_exit = 1; 687 return 0; 688} 689 690 691static void search_conf(void) 692{ 693 struct symbol **sym_arr; 694 struct gstr res; 695 struct gstr title; 696 char *dialog_input; 697 int dres; 698 699 title = str_new(); |
700 str_printf( &title, _("Enter (sub)string or regexp to search for " 701 "(with or without \"%s\")"), CONFIG_); | 700 str_printf( &title, "Enter (sub)string or regexp to search for " 701 "(with or without \"%s\")", CONFIG_); |
702 703again: 704 dres = dialog_inputbox(main_window, | 702 703again: 704 dres = dialog_inputbox(main_window, |
705 _("Search Configuration Parameter"), | 705 "Search Configuration Parameter", |
706 str_get(&title), 707 "", &dialog_input_result, &dialog_input_result_len); 708 switch (dres) { 709 case 0: 710 break; 711 case 1: 712 show_scroll_win(main_window, | 706 str_get(&title), 707 "", &dialog_input_result, &dialog_input_result_len); 708 switch (dres) { 709 case 0: 710 break; 711 case 1: 712 show_scroll_win(main_window, |
713 _("Search Configuration"), search_help); | 713 "Search Configuration", search_help); |
714 goto again; 715 default: 716 str_free(&title); 717 return; 718 } 719 720 /* strip the prefix if necessary */ 721 dialog_input = dialog_input_result; 722 if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) 723 dialog_input += strlen(CONFIG_); 724 725 sym_arr = sym_re_search(dialog_input); 726 res = get_relations_str(sym_arr, NULL); 727 free(sym_arr); 728 show_scroll_win(main_window, | 714 goto again; 715 default: 716 str_free(&title); 717 return; 718 } 719 720 /* strip the prefix if necessary */ 721 dialog_input = dialog_input_result; 722 if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) 723 dialog_input += strlen(CONFIG_); 724 725 sym_arr = sym_re_search(dialog_input); 726 res = get_relations_str(sym_arr, NULL); 727 free(sym_arr); 728 show_scroll_win(main_window, |
729 _("Search Results"), str_get(&res)); | 729 "Search Results", str_get(&res)); |
730 str_free(&res); 731 str_free(&title); 732} 733 734 735static void build_conf(struct menu *menu) 736{ 737 struct symbol *sym; --- 11 unchanged lines hidden (view full) --- 749 if (!sym) { 750 if (prop && menu != current_menu) { 751 const char *prompt = menu_get_prompt(menu); 752 enum prop_type ptype; 753 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 754 switch (ptype) { 755 case P_MENU: 756 child_count++; | 730 str_free(&res); 731 str_free(&title); 732} 733 734 735static void build_conf(struct menu *menu) 736{ 737 struct symbol *sym; --- 11 unchanged lines hidden (view full) --- 749 if (!sym) { 750 if (prop && menu != current_menu) { 751 const char *prompt = menu_get_prompt(menu); 752 enum prop_type ptype; 753 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 754 switch (ptype) { 755 case P_MENU: 756 child_count++; |
757 prompt = _(prompt); | 757 prompt = prompt; |
758 if (single_menu_mode) { 759 item_make(menu, 'm', 760 "%s%*c%s", 761 menu->data ? "-->" : "++>", 762 indent + 1, ' ', prompt); 763 } else 764 item_make(menu, 'm', 765 " %*c%s %s", --- 4 unchanged lines hidden (view full) --- 770 goto conf_childs; 771 return; 772 case P_COMMENT: 773 if (prompt) { 774 child_count++; 775 item_make(menu, ':', 776 " %*c*** %s ***", 777 indent + 1, ' ', | 758 if (single_menu_mode) { 759 item_make(menu, 'm', 760 "%s%*c%s", 761 menu->data ? "-->" : "++>", 762 indent + 1, ' ', prompt); 763 } else 764 item_make(menu, 'm', 765 " %*c%s %s", --- 4 unchanged lines hidden (view full) --- 770 goto conf_childs; 771 return; 772 case P_COMMENT: 773 if (prompt) { 774 child_count++; 775 item_make(menu, ':', 776 " %*c*** %s ***", 777 indent + 1, ' ', |
778 _(prompt)); | 778 prompt); |
779 } 780 break; 781 default: 782 if (prompt) { 783 child_count++; 784 item_make(menu, ':', "---%*c%s", 785 indent + 1, ' ', | 779 } 780 break; 781 default: 782 if (prompt) { 783 child_count++; 784 item_make(menu, ':', "---%*c%s", 785 indent + 1, ' ', |
786 _(prompt)); | 786 prompt); |
787 } 788 } 789 } else 790 doint = 0; 791 goto conf_childs; 792 } 793 794 type = sym_get_type(sym); --- 29 unchanged lines hidden (view full) --- 824 item_make(menu, 't', "<%c>", ch); 825 break; 826 } 827 } else { 828 item_make(menu, def_menu ? 't' : ':', " "); 829 } 830 831 item_add_str("%*c%s", indent + 1, | 787 } 788 } 789 } else 790 doint = 0; 791 goto conf_childs; 792 } 793 794 type = sym_get_type(sym); --- 29 unchanged lines hidden (view full) --- 824 item_make(menu, 't', "<%c>", ch); 825 break; 826 } 827 } else { 828 item_make(menu, def_menu ? 't' : ':', " "); 829 } 830 831 item_add_str("%*c%s", indent + 1, |
832 ' ', _(menu_get_prompt(menu))); | 832 ' ', menu_get_prompt(menu)); |
833 if (val == yes) { 834 if (def_menu) { 835 item_add_str(" (%s)", | 833 if (val == yes) { 834 if (def_menu) { 835 item_add_str(" (%s)", |
836 _(menu_get_prompt(def_menu))); | 836 menu_get_prompt(def_menu)); |
837 item_add_str(" --->"); 838 if (def_menu->list) { 839 indent += 2; 840 build_conf(def_menu); 841 indent -= 2; 842 } 843 } 844 return; 845 } 846 } else { 847 if (menu == current_menu) { 848 item_make(menu, ':', 849 "---%*c%s", indent + 1, | 837 item_add_str(" --->"); 838 if (def_menu->list) { 839 indent += 2; 840 build_conf(def_menu); 841 indent -= 2; 842 } 843 } 844 return; 845 } 846 } else { 847 if (menu == current_menu) { 848 item_make(menu, ':', 849 "---%*c%s", indent + 1, |
850 ' ', _(menu_get_prompt(menu))); | 850 ' ', menu_get_prompt(menu)); |
851 goto conf_childs; 852 } 853 child_count++; 854 val = sym_get_tristate_value(sym); 855 if (sym_is_choice_value(sym) && val == yes) { 856 item_make(menu, ':', " "); 857 } else { 858 switch (type) { --- 30 unchanged lines hidden (view full) --- 889 default: 890 tmp = 2 + strlen(sym_get_string_value(sym)); 891 item_make(menu, 's', " (%s)", 892 sym_get_string_value(sym)); 893 tmp = indent - tmp + 4; 894 if (tmp < 0) 895 tmp = 0; 896 item_add_str("%*c%s%s", tmp, ' ', | 851 goto conf_childs; 852 } 853 child_count++; 854 val = sym_get_tristate_value(sym); 855 if (sym_is_choice_value(sym) && val == yes) { 856 item_make(menu, ':', " "); 857 } else { 858 switch (type) { --- 30 unchanged lines hidden (view full) --- 889 default: 890 tmp = 2 + strlen(sym_get_string_value(sym)); 891 item_make(menu, 's', " (%s)", 892 sym_get_string_value(sym)); 893 tmp = indent - tmp + 4; 894 if (tmp < 0) 895 tmp = 0; 896 item_add_str("%*c%s%s", tmp, ' ', |
897 _(menu_get_prompt(menu)), | 897 menu_get_prompt(menu), |
898 (sym_has_value(sym) || 899 !sym_is_changable(sym)) ? "" : | 898 (sym_has_value(sym) || 899 !sym_is_changable(sym)) ? "" : |
900 _(" (NEW)")); | 900 " (NEW)"); |
901 goto conf_childs; 902 } 903 } 904 item_add_str("%*c%s%s", indent + 1, ' ', | 901 goto conf_childs; 902 } 903 } 904 item_add_str("%*c%s%s", indent + 1, ' ', |
905 _(menu_get_prompt(menu)), | 905 menu_get_prompt(menu), |
906 (sym_has_value(sym) || !sym_is_changable(sym)) ? | 906 (sym_has_value(sym) || !sym_is_changable(sym)) ? |
907 "" : _(" (NEW)")); | 907 "" : " (NEW)"); |
908 if (menu->prompt && menu->prompt->type == P_MENU) { 909 item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); 910 return; 911 } 912 } 913 914conf_childs: 915 indent += doint; --- 165 unchanged lines hidden (view full) --- 1081 1082 while (!global_exit) { 1083 reset_menu(); 1084 current_menu = menu; 1085 build_conf(menu); 1086 if (!child_count) 1087 break; 1088 | 908 if (menu->prompt && menu->prompt->type == P_MENU) { 909 item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); 910 return; 911 } 912 } 913 914conf_childs: 915 indent += doint; --- 165 unchanged lines hidden (view full) --- 1081 1082 while (!global_exit) { 1083 reset_menu(); 1084 current_menu = menu; 1085 build_conf(menu); 1086 if (!child_count) 1087 break; 1088 |
1089 show_menu(prompt ? _(prompt) : _("Main Menu"), 1090 _(menu_instructions), | 1089 show_menu(prompt ? prompt : "Main Menu", 1090 menu_instructions, |
1091 current_index, &last_top_row); 1092 keypad((menu_win(curses_menu)), TRUE); 1093 while (!global_exit) { 1094 if (match_state.in_search) { 1095 mvprintw(0, 0, 1096 "searching: %s", match_state.pattern); 1097 clrtoeol(); 1098 } --- 123 unchanged lines hidden (view full) --- 1222{ 1223 struct gstr help; 1224 1225 if (!menu) 1226 return; 1227 1228 help = str_new(); 1229 menu_get_ext_help(menu, &help); | 1091 current_index, &last_top_row); 1092 keypad((menu_win(curses_menu)), TRUE); 1093 while (!global_exit) { 1094 if (match_state.in_search) { 1095 mvprintw(0, 0, 1096 "searching: %s", match_state.pattern); 1097 clrtoeol(); 1098 } --- 123 unchanged lines hidden (view full) --- 1222{ 1223 struct gstr help; 1224 1225 if (!menu) 1226 return; 1227 1228 help = str_new(); 1229 menu_get_ext_help(menu, &help); |
1230 show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help)); | 1230 show_scroll_win(main_window, menu_get_prompt(menu), str_get(&help)); |
1231 str_free(&help); 1232} 1233 1234static void conf_choice(struct menu *menu) 1235{ | 1231 str_free(&help); 1232} 1233 1234static void conf_choice(struct menu *menu) 1235{ |
1236 const char *prompt = _(menu_get_prompt(menu)); | 1236 const char *prompt = menu_get_prompt(menu); |
1237 struct menu *child = NULL; 1238 struct symbol *active; 1239 int selected_index = 0; 1240 int last_top_row = 0; 1241 int res, i = 0; 1242 struct match_state match_state = { 1243 .in_search = 0, 1244 .match_direction = MATCH_TINKER_PATTERN_DOWN, --- 6 unchanged lines hidden (view full) --- 1251 reset_menu(); 1252 1253 for (i = 0, child = menu->list; child; child = child->next) { 1254 if (!show_all_items && !menu_is_visible(child)) 1255 continue; 1256 1257 if (child->sym == sym_get_choice_value(menu->sym)) 1258 item_make(child, ':', "<X> %s", | 1237 struct menu *child = NULL; 1238 struct symbol *active; 1239 int selected_index = 0; 1240 int last_top_row = 0; 1241 int res, i = 0; 1242 struct match_state match_state = { 1243 .in_search = 0, 1244 .match_direction = MATCH_TINKER_PATTERN_DOWN, --- 6 unchanged lines hidden (view full) --- 1251 reset_menu(); 1252 1253 for (i = 0, child = menu->list; child; child = child->next) { 1254 if (!show_all_items && !menu_is_visible(child)) 1255 continue; 1256 1257 if (child->sym == sym_get_choice_value(menu->sym)) 1258 item_make(child, ':', "<X> %s", |
1259 _(menu_get_prompt(child))); | 1259 menu_get_prompt(child)); |
1260 else if (child->sym) 1261 item_make(child, ':', " %s", | 1260 else if (child->sym) 1261 item_make(child, ':', " %s", |
1262 _(menu_get_prompt(child))); | 1262 menu_get_prompt(child)); |
1263 else 1264 item_make(child, ':', "*** %s ***", | 1263 else 1264 item_make(child, ':', "*** %s ***", |
1265 _(menu_get_prompt(child))); | 1265 menu_get_prompt(child)); |
1266 1267 if (child->sym == active){ 1268 last_top_row = top_row(curses_menu); 1269 selected_index = i; 1270 } 1271 i++; 1272 } | 1266 1267 if (child->sym == active){ 1268 last_top_row = top_row(curses_menu); 1269 selected_index = i; 1270 } 1271 i++; 1272 } |
1273 show_menu(prompt ? _(prompt) : _("Choice Menu"), 1274 _(radiolist_instructions), | 1273 show_menu(prompt ? prompt : "Choice Menu", 1274 radiolist_instructions, |
1275 selected_index, 1276 &last_top_row); 1277 while (!global_exit) { 1278 if (match_state.in_search) { 1279 mvprintw(0, 0, "searching: %s", 1280 match_state.pattern); 1281 clrtoeol(); 1282 } --- 70 unchanged lines hidden (view full) --- 1353 const char *prompt = menu_get_prompt(menu); 1354 1355 while (1) { 1356 int res; 1357 const char *heading; 1358 1359 switch (sym_get_type(menu->sym)) { 1360 case S_INT: | 1275 selected_index, 1276 &last_top_row); 1277 while (!global_exit) { 1278 if (match_state.in_search) { 1279 mvprintw(0, 0, "searching: %s", 1280 match_state.pattern); 1281 clrtoeol(); 1282 } --- 70 unchanged lines hidden (view full) --- 1353 const char *prompt = menu_get_prompt(menu); 1354 1355 while (1) { 1356 int res; 1357 const char *heading; 1358 1359 switch (sym_get_type(menu->sym)) { 1360 case S_INT: |
1361 heading = _(inputbox_instructions_int); | 1361 heading = inputbox_instructions_int; |
1362 break; 1363 case S_HEX: | 1362 break; 1363 case S_HEX: |
1364 heading = _(inputbox_instructions_hex); | 1364 heading = inputbox_instructions_hex; |
1365 break; 1366 case S_STRING: | 1365 break; 1366 case S_STRING: |
1367 heading = _(inputbox_instructions_string); | 1367 heading = inputbox_instructions_string; |
1368 break; 1369 default: | 1368 break; 1369 default: |
1370 heading = _("Internal nconf error!"); | 1370 heading = "Internal nconf error!"; |
1371 } 1372 res = dialog_inputbox(main_window, | 1371 } 1372 res = dialog_inputbox(main_window, |
1373 prompt ? _(prompt) : _("Main Menu"), | 1373 prompt ? prompt : "Main Menu", |
1374 heading, 1375 sym_get_string_value(menu->sym), 1376 &dialog_input_result, 1377 &dialog_input_result_len); 1378 switch (res) { 1379 case 0: 1380 if (sym_set_string_value(menu->sym, 1381 dialog_input_result)) 1382 return; 1383 btn_dialog(main_window, | 1374 heading, 1375 sym_get_string_value(menu->sym), 1376 &dialog_input_result, 1377 &dialog_input_result_len); 1378 switch (res) { 1379 case 0: 1380 if (sym_set_string_value(menu->sym, 1381 dialog_input_result)) 1382 return; 1383 btn_dialog(main_window, |
1384 _("You have made an invalid entry."), 0); | 1384 "You have made an invalid entry.", 0); |
1385 break; 1386 case 1: 1387 show_help(menu); 1388 break; 1389 case KEY_EXIT: 1390 return; 1391 } 1392 } --- 12 unchanged lines hidden (view full) --- 1405 case 0: 1406 if (!dialog_input_result[0]) 1407 return; 1408 if (!conf_read(dialog_input_result)) { 1409 set_config_filename(dialog_input_result); 1410 sym_set_change_count(1); 1411 return; 1412 } | 1385 break; 1386 case 1: 1387 show_help(menu); 1388 break; 1389 case KEY_EXIT: 1390 return; 1391 } 1392 } --- 12 unchanged lines hidden (view full) --- 1405 case 0: 1406 if (!dialog_input_result[0]) 1407 return; 1408 if (!conf_read(dialog_input_result)) { 1409 set_config_filename(dialog_input_result); 1410 sym_set_change_count(1); 1411 return; 1412 } |
1413 btn_dialog(main_window, _("File does not exist!"), 0); | 1413 btn_dialog(main_window, "File does not exist!", 0); |
1414 break; 1415 case 1: 1416 show_scroll_win(main_window, | 1414 break; 1415 case 1: 1416 show_scroll_win(main_window, |
1417 _("Load Alternate Configuration"), | 1417 "Load Alternate Configuration", |
1418 load_config_help); 1419 break; 1420 case KEY_EXIT: 1421 return; 1422 } 1423 } 1424} 1425 --- 10 unchanged lines hidden (view full) --- 1436 case 0: 1437 if (!dialog_input_result[0]) 1438 return; 1439 res = conf_write(dialog_input_result); 1440 if (!res) { 1441 set_config_filename(dialog_input_result); 1442 return; 1443 } | 1418 load_config_help); 1419 break; 1420 case KEY_EXIT: 1421 return; 1422 } 1423 } 1424} 1425 --- 10 unchanged lines hidden (view full) --- 1436 case 0: 1437 if (!dialog_input_result[0]) 1438 return; 1439 res = conf_write(dialog_input_result); 1440 if (!res) { 1441 set_config_filename(dialog_input_result); 1442 return; 1443 } |
1444 btn_dialog(main_window, _("Can't create file! " 1445 "Probably a nonexistent directory."), | 1444 btn_dialog(main_window, "Can't create file! " 1445 "Probably a nonexistent directory.", |
1446 1, "<OK>"); 1447 break; 1448 case 1: 1449 show_scroll_win(main_window, | 1446 1, "<OK>"); 1447 break; 1448 case 1: 1449 show_scroll_win(main_window, |
1450 _("Save Alternate Configuration"), | 1450 "Save Alternate Configuration", |
1451 save_config_help); 1452 break; 1453 case KEY_EXIT: 1454 return; 1455 } 1456 } 1457} 1458 --- 16 unchanged lines hidden (view full) --- 1475 new_panel(main_window); 1476} 1477 1478int main(int ac, char **av) 1479{ 1480 int lines, columns; 1481 char *mode; 1482 | 1451 save_config_help); 1452 break; 1453 case KEY_EXIT: 1454 return; 1455 } 1456 } 1457} 1458 --- 16 unchanged lines hidden (view full) --- 1475 new_panel(main_window); 1476} 1477 1478int main(int ac, char **av) 1479{ 1480 int lines, columns; 1481 char *mode; 1482 |
1483 setlocale(LC_ALL, ""); 1484 bindtextdomain(PACKAGE, LOCALEDIR); 1485 textdomain(PACKAGE); 1486 | |
1487 if (ac > 1 && strcmp(av[1], "-s") == 0) { 1488 /* Silence conf_read() until the real callback is set up */ 1489 conf_set_message_callback(NULL); 1490 av++; 1491 } 1492 conf_parse(av[1]); 1493 conf_read(NULL); 1494 --- 41 unchanged lines hidden (view full) --- 1536 set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]); 1537 1538 set_config_filename(conf_get_configname()); 1539 setup_windows(); 1540 1541 /* check for KEY_FUNC(1) */ 1542 if (has_key(KEY_F(1)) == FALSE) { 1543 show_scroll_win(main_window, | 1483 if (ac > 1 && strcmp(av[1], "-s") == 0) { 1484 /* Silence conf_read() until the real callback is set up */ 1485 conf_set_message_callback(NULL); 1486 av++; 1487 } 1488 conf_parse(av[1]); 1489 conf_read(NULL); 1490 --- 41 unchanged lines hidden (view full) --- 1532 set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]); 1533 1534 set_config_filename(conf_get_configname()); 1535 setup_windows(); 1536 1537 /* check for KEY_FUNC(1) */ 1538 if (has_key(KEY_F(1)) == FALSE) { 1539 show_scroll_win(main_window, |
1544 _("Instructions"), 1545 _(menu_no_f_instructions)); | 1540 "Instructions", 1541 menu_no_f_instructions); |
1546 } 1547 1548 conf_set_message_callback(conf_message_callback); 1549 /* do the work */ 1550 while (!global_exit) { 1551 conf(&rootmenu); 1552 if (!global_exit && do_exit() == 0) 1553 break; 1554 } 1555 /* ok, we are done */ 1556 unpost_menu(curses_menu); 1557 free_menu(curses_menu); 1558 delwin(main_window); 1559 clear(); 1560 refresh(); 1561 endwin(); 1562 return 0; 1563} | 1542 } 1543 1544 conf_set_message_callback(conf_message_callback); 1545 /* do the work */ 1546 while (!global_exit) { 1547 conf(&rootmenu); 1548 if (!global_exit && do_exit() == 0) 1549 break; 1550 } 1551 /* ok, we are done */ 1552 unpost_menu(curses_menu); 1553 free_menu(curses_menu); 1554 delwin(main_window); 1555 clear(); 1556 refresh(); 1557 endwin(); 1558 return 0; 1559} |