-rw-r--r-- | scripts/kconfig/mconf.c | 91 |
1 files changed, 80 insertions, 11 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index dec8603..eba5ff7 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -2,4 +2,7 @@ * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. + * + * Introduced single menu mode (show all sub-menus in one large tree). + * 2002-11-06 Petr Baudis <pasky@ucw.cz> */ @@ -9,8 +12,10 @@ #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <signal.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> +#include <termios.h> #include <unistd.h> @@ -45,5 +50,5 @@ setmod_text[] = "As a result, this feature will be built as a module.", nohelp_text[] = - "There is no help available for this option.\n", + "There is no help available for this kernel option.\n", load_config_text[] = "Enter the name of the configuration file you wish to load. " @@ -52,9 +57,9 @@ load_config_text[] = load_config_help[] = "\n" - "For various reasons, one may wish to keep several different\n" + "For various reasons, one may wish to keep several different kernel\n" "configurations available on a single machine.\n" "\n" "If you have saved a previous configuration in a file other than the\n" - "default, entering the name of the file here will allow you\n" + "kernel's default, entering the name of the file here will allow you\n" "to modify that configuration.\n" "\n" @@ -66,5 +71,5 @@ save_config_text[] = save_config_help[] = "\n" - "For various reasons, one may wish to keep different\n" + "For various reasons, one may wish to keep different kernel\n" "configurations available on a single machine.\n" "\n" @@ -79,10 +84,13 @@ save_config_help[] = static char buf[4096], *bufptr = buf; static char input_buf[4096]; +static char filename[PATH_MAX+1] = ".config"; static char *args[1024], **argptr = args; static int indent = 0; +static struct termios ios_org; static int rows, cols; static struct menu *current_menu; static int child_count; static int do_resize; +static int single_menu_mode; static void conf(struct menu *menu); @@ -104,4 +112,5 @@ static void init_wsize(void) { struct winsize ws; + char *env; if (ioctl(1, TIOCGWINSZ, &ws) == -1) { @@ -111,4 +120,18 @@ static void init_wsize(void) rows = ws.ws_row; cols = ws.ws_col; + if (!rows) { + env = getenv("LINES"); + if (env) + rows = atoi(env); + if (!rows) + rows = 24; + } + if (!cols) { + env = getenv("COLUMNS"); + if (env) + cols = atoi(env); + if (!cols) + cols = 80; + } } @@ -275,8 +298,18 @@ static void build_conf(struct menu *menu) child_count++; cprint("m%p", menu); + + if (single_menu_mode) { + cprint1("%s%*c%s", + menu->data ? "-->" : "++>", + indent + 1, ' ', prompt); + } else { if (menu->parent != &rootmenu) cprint1(" %*c", indent + 1, ' '); cprint1("%s --->", prompt); + } + cprint_done(); + if (single_menu_mode && menu->data) + goto conf_childs; return; default: @@ -393,4 +426,5 @@ static void conf(struct menu *menu) int stat, type, i; + unlink("lxdialog.scrltmp"); active_entry[0] = 0; while (1) { @@ -443,4 +477,7 @@ static void conf(struct menu *menu) switch (type) { case 'm': + if (single_menu_mode) + submenu->data = (void *) !submenu->data; + else conf(submenu); break; @@ -485,4 +522,6 @@ static void conf(struct menu *menu) if (type == 't') sym_toggle_tristate_value(sym); + else if (type == 'm') + conf(submenu); break; } @@ -519,8 +558,16 @@ static void show_help(struct menu *menu) { const char *help; + char *helptext; + struct symbol *sym = menu->sym; - help = menu->sym->help; + help = sym->help; if (!help) help = nohelp_text; + if (sym->name) { + helptext = malloc(strlen(sym->name) + strlen(help) + 16); + sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help); + show_helptext(menu_get_prompt(menu), helptext); + free(helptext); + } else show_helptext(menu_get_prompt(menu), help); } @@ -632,5 +679,5 @@ static void conf_load(void) cprint("11"); cprint("55"); - cprint("%s", conf_filename); + cprint("%s", filename); stat = exec_conf(); switch(stat) { @@ -661,5 +708,5 @@ static void conf_save(void) cprint("11"); cprint("55"); - cprint("%s", conf_filename); + cprint("%s", filename); stat = exec_conf(); switch(stat) { @@ -680,12 +727,33 @@ static void conf_save(void) } +static void conf_cleanup(void) +{ + tcsetattr(1, TCSAFLUSH, &ios_org); + unlink(".help.tmp"); + unlink("lxdialog.scrltmp"); +} + int main(int ac, char **av) { + struct symbol *sym; + char *mode; int stat; + conf_parse(av[1]); conf_read(NULL); - sprintf(menu_backtitle, "Configuration"); + sym = sym_lookup("KERNELRELEASE", 0); + sym_calc_value(sym); + sprintf(menu_backtitle, "Linux Kernel v%s Configuration", + sym_get_string_value(sym)); + + mode = getenv("MENUCONFIG_MODE"); + if (mode) { + if (!strcasecmp(mode, "single_menu")) + single_menu_mode = 1; + } + tcgetattr(1, &ios_org); + atexit(conf_cleanup); init_wsize(); conf(&rootmenu); @@ -703,8 +771,9 @@ int main(int ac, char **av) conf_write(NULL); printf("\n\n" - "*** End of configuration.\n" - "*** Check the top-level Makefile for additional configuration.\n"); + "*** End of Linux kernel configuration.\n" + "*** Check the top-level Makefile for additional configuration.\n" + "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'.\n\n"); } else - printf("\n\nYour configuration changes were NOT saved.\n\n"); + printf("\n\nYour kernel configuration changes were NOT saved.\n\n"); return 0; |