Commit edb5ab0e authored by Roman Zippel's avatar Roman Zippel Committed by Ben Collins

[PATCH] front end updates

conf: better choice interface
      don't ask for unchangable symbols

mconf: mark unchangable symbols with '---'
       update exit text (from Sam Ravnborg <sam@ravnborg.org>)

qconf: update debug output
parent f9f0d1c0
...@@ -35,25 +35,6 @@ static struct menu *rootEntry; ...@@ -35,25 +35,6 @@ static struct menu *rootEntry;
static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
static void printo(const char *o)
{
static int sep = 0;
if (!sep) {
putchar('(');
sep = 1;
} else if (o) {
putchar(',');
putchar(' ');
}
if (!o) {
putchar(')');
putchar(' ');
sep = 0;
} else
printf("%s", o);
}
static void strip(char *str) static void strip(char *str)
{ {
char *p = str; char *p = str;
...@@ -71,6 +52,16 @@ static void strip(char *str) ...@@ -71,6 +52,16 @@ static void strip(char *str)
*p-- = 0; *p-- = 0;
} }
static void check_stdin(void)
{
if (!valid_stdin && input_mode == ask_silent) {
printf("aborted!\n\n");
printf("Console input/output is redirected. ");
printf("Run 'make oldconfig' to update configuration.\n\n");
exit(1);
}
}
static void conf_askvalue(struct symbol *sym, const char *def) static void conf_askvalue(struct symbol *sym, const char *def)
{ {
enum symbol_type type = sym_get_type(sym); enum symbol_type type = sym_get_type(sym);
...@@ -89,13 +80,14 @@ static void conf_askvalue(struct symbol *sym, const char *def) ...@@ -89,13 +80,14 @@ static void conf_askvalue(struct symbol *sym, const char *def)
printf("%s\n", def); printf("%s\n", def);
return; return;
} }
if (!valid_stdin && input_mode == ask_silent) { check_stdin();
printf("aborted!\n\n");
printf("Console input/output is redirected. ");
printf("Run 'make oldconfig' to update configuration.\n\n");
exit(1);
}
case ask_all: case ask_all:
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return;
}
fflush(stdout); fflush(stdout);
fgets(line, 128, stdin); fgets(line, 128, stdin);
return; return;
...@@ -275,9 +267,8 @@ static int conf_sym(struct menu *menu) ...@@ -275,9 +267,8 @@ static int conf_sym(struct menu *menu)
static int conf_choice(struct menu *menu) static int conf_choice(struct menu *menu)
{ {
struct symbol *sym, *def_sym; struct symbol *sym, *def_sym;
struct menu *cmenu, *def_menu; struct menu *child;
const char *help; int type;
int type, len;
bool is_new; bool is_new;
sym = menu->sym; sym = menu->sym;
...@@ -303,67 +294,100 @@ static int conf_choice(struct menu *menu) ...@@ -303,67 +294,100 @@ static int conf_choice(struct menu *menu)
} }
while (1) { while (1) {
printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); int cnt, def;
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
def_sym = sym_get_choice_value(sym); def_sym = sym_get_choice_value(sym);
def_menu = NULL; cnt = def = 0;
for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { line[0] = '0';
if (!menu_is_visible(cmenu)) line[1] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue; continue;
printo(menu_get_prompt(cmenu)); if (!child->sym) {
if (cmenu->sym == def_sym) printf("%*c %s\n", indent, '*', menu_get_prompt(child));
def_menu = cmenu; continue;
} }
printo(NULL); cnt++;
if (def_menu) if (child->sym == def_sym) {
printf("[%s] ", menu_get_prompt(def_menu)); def = cnt;
else { printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
printf(" %d. %s", cnt, menu_get_prompt(child));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
printf(" (NEW)");
printf("\n"); printf("\n");
return 1;
} }
printf("%*schoice", indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
}
printf("[1-%d", cnt);
if (sym->help)
printf("?");
printf("]: ");
switch (input_mode) { switch (input_mode) {
case ask_new: case ask_new:
case ask_silent: case ask_silent:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
case ask_all: case ask_all:
if (is_new) fflush(stdout);
sym->flags |= SYMBOL_NEW; fgets(line, 128, stdin);
conf_askvalue(sym, menu_get_prompt(def_menu));
strip(line); strip(line);
break; if (line[0] == '?') {
default: printf("\n%s\n", menu->sym->help ?
line[0] = 0; menu->sym->help : nohelp_text);
printf("\n"); continue;
} }
if (line[0] == '?' && !line[1]) { if (!line[0])
help = nohelp_text; cnt = def;
if (menu->sym->help) else if (isdigit(line[0]))
help = menu->sym->help; cnt = atoi(line);
printf("\n%s\n", help); else
continue; continue;
break;
case set_random:
def = (random() % cnt) + 1;
case set_default:
case set_yes:
case set_mod:
case set_no:
cnt = def;
printf("%d\n", cnt);
break;
} }
if (line[0]) {
len = strlen(line);
line[len] = 0;
def_menu = NULL; conf_childs:
for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { for (child = menu->list; child; child = child->next) {
if (!cmenu->sym || !menu_is_visible(cmenu)) if (!child->sym || !menu_is_visible(child))
continue; continue;
if (!strncasecmp(line, menu_get_prompt(cmenu), len)) { if (!--cnt)
def_menu = cmenu;
break; break;
} }
if (!child)
continue;
if (line[strlen(line) - 1] == '?') {
printf("\n%s\n", child->sym->help ?
child->sym->help : nohelp_text);
continue;
} }
} sym_set_choice_value(sym, child->sym);
if (def_menu) { if (child->list) {
sym_set_choice_value(sym, def_menu->sym);
if (def_menu->list) {
indent += 2; indent += 2;
conf(def_menu->list); conf(child->list);
indent -= 2; indent -= 2;
} }
return 1; return 1;
} }
}
} }
static void conf(struct menu *menu) static void conf(struct menu *menu)
......
...@@ -384,7 +384,10 @@ static void build_conf(struct menu *menu) ...@@ -384,7 +384,10 @@ static void build_conf(struct menu *menu)
switch (type) { switch (type) {
case S_BOOLEAN: case S_BOOLEAN:
cprint("t%p", menu); cprint("t%p", menu);
if (sym_is_changable(sym))
cprint1("[%c]", val == no ? ' ' : '*'); cprint1("[%c]", val == no ? ' ' : '*');
else
cprint1("---");
break; break;
case S_TRISTATE: case S_TRISTATE:
cprint("t%p", menu); cprint("t%p", menu);
...@@ -393,7 +396,10 @@ static void build_conf(struct menu *menu) ...@@ -393,7 +396,10 @@ static void build_conf(struct menu *menu)
case mod: ch = 'M'; break; case mod: ch = 'M'; break;
default: ch = ' '; break; default: ch = ' '; break;
} }
if (sym_is_changable(sym))
cprint1("<%c>", ch); cprint1("<%c>", ch);
else
cprint1("---");
break; break;
default: default:
cprint("s%p", menu); cprint("s%p", menu);
...@@ -402,13 +408,15 @@ static void build_conf(struct menu *menu) ...@@ -402,13 +408,15 @@ static void build_conf(struct menu *menu)
if (tmp < 0) if (tmp < 0)
tmp = 0; tmp = 0;
cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
sym_has_value(sym) ? "" : " (NEW)"); (sym_has_value(sym) || !sym_is_changable(sym)) ?
"" : " (NEW)");
cprint_done(); cprint_done();
goto conf_childs; goto conf_childs;
} }
} }
cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
sym_has_value(sym) ? "" : " (NEW)"); (sym_has_value(sym) || !sym_is_changable(sym)) ?
"" : " (NEW)");
if (menu->prompt->type == P_MENU) { if (menu->prompt->type == P_MENU) {
cprint1(" --->"); cprint1(" --->");
cprint_done(); cprint_done();
...@@ -780,10 +788,12 @@ int main(int ac, char **av) ...@@ -780,10 +788,12 @@ int main(int ac, char **av)
conf_write(NULL); conf_write(NULL);
printf("\n\n" printf("\n\n"
"*** End of Linux kernel configuration.\n" "*** End of Linux kernel configuration.\n"
"*** Check the top-level Makefile for additional configuration.\n" "*** Execute 'make' to build the kernel or try 'make help'."
"*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'.\n\n"); "\n\n");
} else } else
printf("\n\nYour kernel configuration changes were NOT saved.\n\n"); printf("\n\n"
"Your kernel configuration changes were NOT saved."
"\n\n");
return 0; return 0;
} }
...@@ -961,36 +961,54 @@ void ConfigMainWindow::setHelp(QListViewItem* item) ...@@ -961,36 +961,54 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
if (showDebug) { if (showDebug) {
debug += "type: "; debug += "type: ";
debug += print_filter(sym_type_name(sym->type)); debug += print_filter(sym_type_name(sym->type));
if (sym_is_choice(sym))
debug += " (choice)";
debug += "<br>"; debug += "<br>";
if (sym->rev_dep.expr) {
debug += "reverse dep: ";
expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
}
for (struct property *prop = sym->prop; prop; prop = prop->next) { for (struct property *prop = sym->prop; prop; prop = prop->next) {
switch (prop->type) { switch (prop->type) {
case P_PROMPT: case P_PROMPT:
case P_MENU:
debug += "prompt: "; debug += "prompt: ";
debug += print_filter(prop->text); debug += print_filter(prop->text);
debug += "<br>"; debug += "<br>";
if (prop->visible.expr) {
debug += "&nbsp;&nbsp;dep: ";
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
}
break; break;
case P_DEFAULT: case P_DEFAULT:
debug += "default: "; debug += "default: ";
debug += print_filter(prop->def->name); expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>"; debug += "<br>";
if (prop->visible.expr) { break;
debug += "&nbsp;&nbsp;dep: "; case P_CHOICE:
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); if (sym_is_choice(sym)) {
debug += "choice: ";
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>"; debug += "<br>";
} }
break; break;
case P_CHOICE: case P_SELECT:
debug += "select: ";
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
break;
case P_RANGE:
debug += "range: ";
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
break; break;
default: default:
debug += "unknown property: "; debug += "unknown property: ";
debug += prop_get_type_name(prop->type); debug += prop_get_type_name(prop->type);
debug += "<br>"; debug += "<br>";
} }
if (prop->visible.expr) {
debug += "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
}
} }
debug += "<br>"; debug += "<br>";
} }
...@@ -1004,10 +1022,12 @@ void ConfigMainWindow::setHelp(QListViewItem* item) ...@@ -1004,10 +1022,12 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
if (menu->prompt->visible.expr) { if (menu->prompt->visible.expr) {
debug += "&nbsp;&nbsp;dep: "; debug += "&nbsp;&nbsp;dep: ";
expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br>"; debug += "<br><br>";
} }
} }
} }
if (showDebug)
debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
helpText->setText(head + debug + help); helpText->setText(head + debug + help);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment