static void conf_save(void) { int stat; while (1) { cprint_init(); cprint("--inputbox"); cprint(save_config_text); cprint("11"); cprint("55"); cprint("%s", filename); stat = exec_conf(); switch(stat) { case 0: if (!input_buf[0]) return; if (!conf_write(input_buf)) return; show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: show_helptext(_("Save Alternate Configuration"), save_config_help); break; case 255: return; } } }
static void conf_load(void) { while (1) { int res; dialog_clear(); res = dialog_inputbox(NULL, load_config_text, 11, 55, filename); switch(res) { case 0: if (!dialog_input_result[0]) return; if (!conf_read(dialog_input_result)) { set_config_filename(dialog_input_result); return; } show_textbox(NULL, _("File does not exist!"), 5, 38); break; case 1: show_helptext(_("Load Alternate Configuration"), load_config_help); break; case KEY_ESC: return; } } }
static void conf_save(void) { while (1) { int res; dialog_clear(); res = dialog_inputbox(NULL, save_config_text, 11, 55, filename); switch(res) { case 0: if (!dialog_input_result[0]) return; if (!conf_write(dialog_input_result)) { set_config_filename(dialog_input_result); return; } show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: show_helptext(_("Save Alternate Configuration"), save_config_help); break; case KEY_ESC: return; } } }
static void search_conf(void) { struct symbol **sym_arr; struct gstr res; char *dialog_input; int dres; again: dialog_clear(); dres = dialog_inputbox(_("Search Configuration Parameter"), _("Enter " CONFIG_ " (sub)string to search for " "(with or without \"" CONFIG_ "\")"), 10, 75, ""); switch (dres) { case 0: break; case 1: show_helptext(_("Search Configuration"), search_help); goto again; default: return; } /* strip the prefix if necessary */ dialog_input = dialog_input_result; if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) dialog_input += strlen(CONFIG_); sym_arr = sym_re_search(dialog_input); res = get_relations_str(sym_arr); free(sym_arr); show_textbox(_("Search Results"), str_get(&res), 0, 0); str_free(&res); }
static void search_conf(void) { struct symbol **sym_arr; struct gstr res; int dres; again: dialog_clear(); dres = dialog_inputbox(_("Search Configuration Parameter"), _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"), 10, 75, ""); switch (dres) { case 0: break; case 1: show_helptext(_("Search Configuration"), search_help); goto again; default: return; } sym_arr = sym_re_search(dialog_input_result); res = get_relations_str(sym_arr); free(sym_arr); show_textbox(_("Search Results"), str_get(&res), 0, 0); str_free(&res); }
static void conf_load(void) { int stat; while (1) { cprint_init(); cprint("--inputbox"); cprint(load_config_text); cprint("11"); cprint("55"); cprint("%s", filename); stat = exec_conf(); switch(stat) { case 0: if (!input_buf[0]) return; if (!conf_read(input_buf)) return; show_textbox(NULL, _("File does not exist!"), 5, 38); break; case 1: show_helptext(_("Load Alternate Configuration"), load_config_help); break; case 255: return; } } }
static void search_conf(void) { struct symbol **sym_arr; int stat; struct gstr res; again: cprint_init(); cprint("--title"); cprint(_("Search Configuration Parameter")); cprint("--inputbox"); cprint(_("Enter CONFIG_ (sub)string to search for (omit CONFIG_)")); cprint("10"); cprint("75"); cprint(""); stat = exec_conf(); if (stat < 0) goto again; switch (stat) { case 0: break; case 1: show_helptext(_("Search Configuration"), search_help); goto again; default: return; } sym_arr = sym_re_search(input_buf); res = get_relations_str(sym_arr); free(sym_arr); show_textbox(_("Search Results"), str_get(&res), 0, 0); str_free(&res); }
static void show_help(struct menu *menu) { const char *help; char *helptext; struct symbol *sym = menu->sym; 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); }
static void show_help(struct menu *menu) { struct gstr help = str_new(); menu_get_ext_help(menu, &help); show_helptext(_(menu_get_prompt(menu)), str_get(&help)); str_free(&help); }
static void show_help(struct menu *menu) { struct gstr help = str_new(); help.max_width = getmaxx(stdscr) - 10; menu_get_ext_help(menu, &help); show_helptext(_(menu_get_prompt(menu)), str_get(&help)); str_free(&help); }
static void show_help(struct menu *menu) { struct gstr help = str_new(); struct symbol *sym = menu->sym; if (sym->help) { if (sym->name) { str_printf(&help, "%s:\n\n", sym->name); str_append(&help, sym->help); str_append(&help, "\n"); } } else { str_append(&help, nohelp_text); } get_symbol_str(&help, sym); show_helptext(menu_get_prompt(menu), str_get(&help)); str_free(&help); }
static void conf_save(void) { while (1) { switch (dialog_inputbox(NULL, save_config_text, 11, 55, filename)) { case 0: if (!dialog_input_result[0]) return; if (!conf_write(dialog_input_result)) return; show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); break; case 1: show_helptext("Save Alternate Configuration", save_config_help); break; case 255: return; } } }
static void conf_load(void) { while (1) { switch (dialog_inputbox(NULL, load_config_text, 11, 55, filename)) { case 0: if (!dialog_input_result[0]) return; if (!conf_read(dialog_input_result)) return; show_textbox(NULL, "File does not exist!", 5, 38); break; case 1: show_helptext("Load Alternate Configuration", load_config_help); break; case 255: return; } } }
static void search_conf(void) { struct symbol **sym_arr; struct gstr res; again: switch (dialog_inputbox("Search Configuration Parameter", "Enter Keyword", 10, 75, NULL)) { case 0: break; case 1: show_helptext("Search Configuration", search_help); goto again; default: return; } sym_arr = sym_re_search(dialog_input_result); res = get_relations_str(sym_arr); free(sym_arr); show_textbox("Search Results", str_get(&res), 0, 0); str_free(&res); }
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 conf(struct menu *menu) { struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; char active_entry[40]; int stat, type, i; unlink("lxdialog.scrltmp"); active_entry[0] = 0; while (1) { cprint_init(); cprint("--title"); cprint("%s", prompt ? prompt : _("Main Menu")); cprint("--menu"); cprint(_(menu_instructions)); cprint("%d", rows); cprint("%d", cols); cprint("%d", rows - 10); cprint("%s", active_entry); current_menu = menu; build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { cprint(":"); cprint("--- "); cprint("L"); cprint(_(" Load an Alternate Configuration File")); cprint("S"); cprint(_(" Save Configuration to an Alternate File")); } stat = exec_conf(); if (stat < 0) continue; if (stat == 1 || stat == 255) break; type = input_buf[0]; if (!type) continue; for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) ; if (i >= sizeof(active_entry)) i = sizeof(active_entry) - 1; input_buf[i] = 0; strcpy(active_entry, input_buf); sym = NULL; submenu = NULL; if (sscanf(input_buf + 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 conf(struct menu *menu) { struct menu *submenu; const char *prompt = menu_get_prompt(menu); struct symbol *sym; struct menu *active_menu = NULL; int res; int s_scroll = 0; while (1) { item_reset(); current_menu = menu; build_conf(menu); if (!child_count) break; if (menu == &rootmenu) { item_make("--- "); item_set_tag(':'); item_make(_(" Load an Alternate Configuration File")); item_set_tag('L'); item_make(_(" Save an Alternate Configuration File")); item_set_tag('S'); } dialog_clear(); res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), _(menu_instructions), active_menu, &s_scroll); if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) break; if (!item_activate_selected()) continue; if (!item_tag()) continue; submenu = item_data(); active_menu = item_data(); if (submenu) sym = submenu->sym; else sym = NULL; switch (res) { case 0: switch (item_tag()) { 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 (item_is_tag('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 (item_is_tag('t')) sym_set_tristate_value(sym, no); break; case 5: if (item_is_tag('t')) sym_set_tristate_value(sym, mod); break; case 6: if (item_is_tag('t')) sym_toggle_tristate_value(sym); else if (item_is_tag('m')) conf(submenu); break; case 7: search_conf(); break; } } }
static void show_readme(void) { show_helptext("Help", top_menu_help); }