diff options
author | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-07-29 16:48:57 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@neptun.ravnborg.org> | 2006-09-30 05:19:20 -0400 |
commit | c8dc68ad0fbd934e78e913b8a8d7b45945db4930 (patch) | |
tree | 62169927ce5ca83e3f280e6bbe06053989462968 /scripts/kconfig/lxdialog/inputbox.c | |
parent | f3cbcdc955d0d2c8b4c52d6b73fc536b01b68c64 (diff) |
kconfig/lxdialog: support resize
In all dialogs now properly catch KEY_RESIZE and take proper action.
In mconf try to behave sensibly when a dialog routine returns
-ERRDISPLAYTOOSMALL.
The original check for a screnn size of 80x19 is kept for now.
It may make sense to remove it later, but thats anyway what
much text is adjusted for.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/lxdialog/inputbox.c')
-rw-r--r-- | scripts/kconfig/lxdialog/inputbox.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index edb7975dbaa2..05e72066b359 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
@@ -49,6 +49,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
49 | char *instr = dialog_input_result; | 49 | char *instr = dialog_input_result; |
50 | WINDOW *dialog; | 50 | WINDOW *dialog; |
51 | 51 | ||
52 | if (!init) | ||
53 | instr[0] = '\0'; | ||
54 | else | ||
55 | strcpy(instr, init); | ||
56 | |||
57 | do_resize: | ||
58 | if (getmaxy(stdscr) <= (height - 2)) | ||
59 | return -ERRDISPLAYTOOSMALL; | ||
60 | if (getmaxx(stdscr) <= (width - 2)) | ||
61 | return -ERRDISPLAYTOOSMALL; | ||
62 | |||
52 | /* center dialog box on screen */ | 63 | /* center dialog box on screen */ |
53 | x = (COLS - width) / 2; | 64 | x = (COLS - width) / 2; |
54 | y = (LINES - height) / 2; | 65 | y = (LINES - height) / 2; |
@@ -86,11 +97,6 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
86 | wmove(dialog, box_y, box_x); | 97 | wmove(dialog, box_y, box_x); |
87 | wattrset(dialog, dlg.inputbox.atr); | 98 | wattrset(dialog, dlg.inputbox.atr); |
88 | 99 | ||
89 | if (!init) | ||
90 | instr[0] = '\0'; | ||
91 | else | ||
92 | strcpy(instr, init); | ||
93 | |||
94 | input_x = strlen(instr); | 100 | input_x = strlen(instr); |
95 | 101 | ||
96 | if (input_x >= box_width) { | 102 | if (input_x >= box_width) { |
@@ -220,6 +226,10 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
220 | case KEY_ESC: | 226 | case KEY_ESC: |
221 | key = on_key_esc(dialog); | 227 | key = on_key_esc(dialog); |
222 | break; | 228 | break; |
229 | case KEY_RESIZE: | ||
230 | delwin(dialog); | ||
231 | on_key_resize(); | ||
232 | goto do_resize; | ||
223 | } | 233 | } |
224 | } | 234 | } |
225 | 235 | ||