int conf_string(struct menu *menu) { struct symbol *sym = menu->sym; const char *def; while (1) { printf("%*s%s ", indent - 1, "", menu->prompt->text); printf("(%s) ", sym->name); def = sym_get_string_value(sym); if (sym_get_string_value(sym)) printf("[%s] ", def); conf_askvalue(sym, def); switch (line[0]) { case '\n': break; case '?': /* print help */ if (line[1] == '\n') { printf("\n%s\n", menu->sym->help ? menu->sym->help : nohelp_text); def = NULL; break; } default: line[strlen(line)-1] = 0; def = line; } if (def && sym_set_string_value(sym, def)) return 0; } }
/* Change hex/int/string value in the cell */ static void renderer_edited(GtkCellRendererText * cell, const gchar * path_string, const gchar * new_text, gpointer user_data) { GtkTreePath *path = gtk_tree_path_new_from_string(path_string); GtkTreeIter iter; const char *old_def, *new_def; struct menu *menu; struct symbol *sym; if (!gtk_tree_model_get_iter(model2, &iter, path)) return; gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); sym = menu->sym; gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1); new_def = new_text; sym_set_string_value(sym, new_def); update_tree(&rootmenu, NULL); gtk_tree_path_free(path); }
static void conf_string(struct menu *menu) { const char *prompt = menu_get_prompt(menu); int stat; while (1) { cprint_init(); cprint("--title"); cprint("%s", prompt ? prompt : "Main Menu"); cprint("--inputbox"); switch (sym_get_type(menu->sym)) { case S_INT: cprint(inputbox_instructions_int); break; case S_HEX: cprint(inputbox_instructions_hex); break; case S_STRING: cprint(inputbox_instructions_string); break; default: /* panic? */; } cprint("10"); cprint("75"); cprint("%s", sym_get_string_value(menu->sym)); stat = exec_conf(); switch (stat) { case 0: if (sym_set_string_value(menu->sym, input_buf)) return; show_textbox(NULL, "You have made an invalid entry.", 5, 43); break; case 1: show_help(menu); break; case 255: return; } } }
static void conf_string(struct menu *menu) { const char *prompt = menu_get_prompt(menu); while (1) { int res; const char *heading; switch (sym_get_type(menu->sym)) { case S_INT: heading = _(inputbox_instructions_int); break; case S_HEX: heading = _(inputbox_instructions_hex); break; case S_STRING: heading = _(inputbox_instructions_string); break; default: heading = _("Internal mconf error!"); } dialog_clear(); res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), heading, 10, 75, sym_get_string_value(menu->sym)); switch (res) { case 0: if (sym_set_string_value(menu->sym, dialog_input_result)) return; show_textbox(NULL, _("You have made an invalid entry."), 5, 43); break; case 1: show_help(menu); break; case KEY_ESC: return; } } }
static void conf_string(struct menu *menu) { const char *prompt = menu_get_prompt(menu); while (1) { char *heading; switch (sym_get_type(menu->sym)) { case S_INT: heading = (char *) inputbox_instructions_int; break; case S_HEX: heading = (char *) inputbox_instructions_hex; break; case S_STRING: heading = (char *) inputbox_instructions_string; break; default: heading = "Internal mconf error!"; /* panic? */; } switch (dialog_inputbox(prompt ? prompt : "Main Menu", heading, 10, 75, sym_get_string_value(menu->sym))) { case 0: if (sym_set_string_value(menu->sym, dialog_input_result)) return; show_textbox(NULL, "You have made an invalid entry.", 5, 43); break; case 1: show_help(menu); break; case 255: return; } } }