static void conf_choice(struct menu *menu) { const char *prompt = menu_get_prompt(menu); struct menu *child; struct symbol *active; while (1) { current_menu = menu; active = sym_get_choice_value(menu->sym); cdone(); cinit(); for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; cmake(); cprint_tag("%p", child); cprint_name("%s", menu_get_prompt(child)); items[item_no - 1]->selected = (child->sym == active); } switch (dialog_checklist(prompt ? prompt : "Main Menu", radiolist_instructions, 15, 70, 6, item_no, items, FLAG_RADIO)) { case 0: if (sscanf(first_sel_item(item_no, items)->tag, "%p", &menu) != 1) break; sym_set_tristate_value(menu->sym, yes); return; case 1: show_help(menu); break; case 255: return; } } }
static void conf(struct menu *menu) { struct dialog_list_item *active_item = NULL; struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; char active_entry[40]; int stat, type; unlink("lxdialog.scrltmp"); active_entry[0] = 0; while (1) { indent = 0; child_count = 0; current_menu = menu; cdone(); cinit(); build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { cmake(); cprint_tag(":"); cprint_name("--- "); cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); } dialog_clear(); stat = dialog_menu(prompt ? prompt : "Main Menu", menu_instructions, rows, cols, rows - 10, active_entry, item_no, items); if (stat < 0) return; if (stat == 1 || stat == 255) break; active_item = first_sel_item(item_no, items); if (!active_item) continue; active_item->selected = 0; strncpy(active_entry, active_item->tag, sizeof(active_entry)); active_entry[sizeof(active_entry)-1] = 0; type = active_entry[0]; if (!type) continue; sym = NULL; submenu = NULL; if (sscanf(active_entry + 1, "%p", &submenu) == 1) sym = submenu->sym; switch (stat) { case 0: switch (type) { case 'm': if (single_menu_mode) submenu->data = (void *) (long) !submenu->data; else conf(submenu); break; case 't': if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) conf_choice(submenu); else if (submenu->prompt->type == P_MENU) conf(submenu); break; case 's': conf_string(submenu); break; case 'L': conf_load(); break; case 'S': conf_save(); break; } break; case 2: if (sym) show_help(submenu); else show_helptext("README", mconf_readme); break; case 3: if (type == 't') { if (sym_set_tristate_value(sym, yes)) break; if (sym_set_tristate_value(sym, mod)) show_textbox(NULL, setmod_text, 6, 74); } break; case 4: if (type == 't') sym_set_tristate_value(sym, no); break; case 5: if (type == 't') sym_set_tristate_value(sym, mod); break; case 6: if (type == 't') sym_toggle_tristate_value(sym); else if (type == 'm') conf(submenu); break; case 7: search_conf(); break; } } }
static void build_conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; int type, tmp, doint = 2; tristate val; char ch; if (!menu_is_visible(menu)) return; sym = menu->sym; prop = menu->prompt; if (!sym) { if (prop && menu != current_menu) { const char *prompt = menu_get_prompt(menu); switch (prop->type) { case P_MENU: child_count++; cmake(); cprint_tag("m%p", menu); if (single_menu_mode) { cprint_name("%s%*c%s", menu->data ? "-->" : "++>", indent + 1, ' ', prompt); } else { cprint_name(" %*c%s --->", indent + 1, ' ', prompt); } if (single_menu_mode && menu->data) goto conf_childs; return; default: if (prompt) { child_count++; cmake(); cprint_tag(":%p", menu); cprint_name("---%*c%s", indent + 1, ' ', prompt); } } } else doint = 0; goto conf_childs; } cmake(); type = sym_get_type(sym); if (sym_is_choice(sym)) { struct symbol *def_sym = sym_get_choice_value(sym); struct menu *def_menu = NULL; child_count++; for (child = menu->list; child; child = child->next) { if (menu_is_visible(child) && child->sym == def_sym) def_menu = child; } val = sym_get_tristate_value(sym); if (sym_is_changable(sym)) { cprint_tag("t%p", menu); switch (type) { case S_BOOLEAN: cprint_name("[%c]", val == no ? ' ' : '*'); break; case S_TRISTATE: switch (val) { case yes: ch = '*'; break; case mod: ch = 'M'; break; default: ch = ' '; break; } cprint_name("<%c>", ch); break; } } else { cprint_tag("%c%p", def_menu ? 't' : ':', menu); cprint_name(" "); } cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); if (val == yes) { if (def_menu) { cprint_name(" (%s)", menu_get_prompt(def_menu)); cprint_name(" --->"); if (def_menu->list) { indent += 2; build_conf(def_menu); indent -= 2; } } return; } } else { if (menu == current_menu) { cprint_tag(":%p", menu); cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); goto conf_childs; } child_count++; val = sym_get_tristate_value(sym); if (sym_is_choice_value(sym) && val == yes) { cprint_tag(":%p", menu); cprint_name(" "); } else { switch (type) { case S_BOOLEAN: cprint_tag("t%p", menu); if (sym_is_changable(sym)) cprint_name("[%c]", val == no ? ' ' : '*'); else cprint_name("---"); break; case S_TRISTATE: cprint_tag("t%p", menu); switch (val) { case yes: ch = '*'; break; case mod: ch = 'M'; break; default: ch = ' '; break; } if (sym_is_changable(sym)) cprint_name("<%c>", ch); else cprint_name("---"); break; default: cprint_tag("s%p", menu); tmp = cprint_name("(%s)", sym_get_string_value(sym)); tmp = indent - tmp + 4; if (tmp < 0) tmp = 0; cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), (sym_has_value(sym) || !sym_is_changable(sym)) ? "" : " (NEW)"); goto conf_childs; } } cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), (sym_has_value(sym) || !sym_is_changable(sym)) ? "" : " (NEW)"); if (menu->prompt->type == P_MENU) { cprint_name(" --->"); return; } } conf_childs: indent += doint; for (child = menu->list; child; child = child->next) build_conf(child); indent -= doint; }