@@ -38,6 +38,31 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
wrefresh(dialog);
}
+static void dialog_input_clean(void)
+{
+ char *instr = dialog_input_result;
+ int l, s, e;
+
+ l = strlen(instr);
+ if (l == 0)
+ return;
+ for (s = 0; s < l; s++) {
+ if (instr[s] != ' ')
+ break;
+ instr[s] = '\0';
+ }
+ if (s == l)
+ return;
+ for (e = l - 1; e > 0; e--) {
+ if (instr[e] != ' ')
+ break;
+ instr[e] = '\0';
+ }
+ if (s == 0)
+ return;
+ memmove(instr, instr + s, e - s + 2);
+}
+
/*
* Display a dialog box for inputing a string
*/
@@ -234,6 +259,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
case 'O':
case 'o':
delwin(dialog);
+ dialog_input_clean();
return 0;
case 'H':
case 'h':
@@ -281,6 +307,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
case ' ':
case '\n':
delwin(dialog);
+ dialog_input_clean();
return (button == -1 ? 0 : button);
case 'X':
case 'x':