aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/lxdialog/inputbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/lxdialog/inputbox.c')
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 779503726b0a..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
57do_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;
@@ -58,17 +69,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
58 dialog = newwin(height, width, y, x); 69 dialog = newwin(height, width, y, x);
59 keypad(dialog, TRUE); 70 keypad(dialog, TRUE);
60 71
61 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); 72 draw_box(dialog, 0, 0, height, width,
62 wattrset(dialog, border_attr); 73 dlg.dialog.atr, dlg.border.atr);
74 wattrset(dialog, dlg.border.atr);
63 mvwaddch(dialog, height - 3, 0, ACS_LTEE); 75 mvwaddch(dialog, height - 3, 0, ACS_LTEE);
64 for (i = 0; i < width - 2; i++) 76 for (i = 0; i < width - 2; i++)
65 waddch(dialog, ACS_HLINE); 77 waddch(dialog, ACS_HLINE);
66 wattrset(dialog, dialog_attr); 78 wattrset(dialog, dlg.dialog.atr);
67 waddch(dialog, ACS_RTEE); 79 waddch(dialog, ACS_RTEE);
68 80
69 print_title(dialog, title, width); 81 print_title(dialog, title, width);
70 82
71 wattrset(dialog, dialog_attr); 83 wattrset(dialog, dlg.dialog.atr);
72 print_autowrap(dialog, prompt, width - 2, 1, 3); 84 print_autowrap(dialog, prompt, width - 2, 1, 3);
73 85
74 /* Draw the input field box */ 86 /* Draw the input field box */
@@ -76,18 +88,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
76 getyx(dialog, y, x); 88 getyx(dialog, y, x);
77 box_y = y + 2; 89 box_y = y + 2;
78 box_x = (width - box_width) / 2; 90 box_x = (width - box_width) / 2;
79 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); 91 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
92 dlg.border.atr, dlg.dialog.atr);
80 93
81 print_buttons(dialog, height, width, 0); 94 print_buttons(dialog, height, width, 0);
82 95
83 /* Set up the initial value */ 96 /* Set up the initial value */
84 wmove(dialog, box_y, box_x); 97 wmove(dialog, box_y, box_x);
85 wattrset(dialog, inputbox_attr); 98 wattrset(dialog, dlg.inputbox.atr);
86
87 if (!init)
88 instr[0] = '\0';
89 else
90 strcpy(instr, init);
91 99
92 input_x = strlen(instr); 100 input_x = strlen(instr);
93 101
@@ -104,7 +112,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
104 112
105 wrefresh(dialog); 113 wrefresh(dialog);
106 114
107 while (key != ESC) { 115 while (key != KEY_ESC) {
108 key = wgetch(dialog); 116 key = wgetch(dialog);
109 117
110 if (button == -1) { /* Input box selected */ 118 if (button == -1) { /* Input box selected */
@@ -120,7 +128,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
120 case KEY_BACKSPACE: 128 case KEY_BACKSPACE:
121 case 127: 129 case 127:
122 if (input_x || scroll) { 130 if (input_x || scroll) {
123 wattrset(dialog, inputbox_attr); 131 wattrset(dialog, dlg.inputbox.atr);
124 if (!input_x) { 132 if (!input_x) {
125 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); 133 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
126 wmove(dialog, box_y, box_x); 134 wmove(dialog, box_y, box_x);
@@ -140,7 +148,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
140 default: 148 default:
141 if (key < 0x100 && isprint(key)) { 149 if (key < 0x100 && isprint(key)) {
142 if (scroll + input_x < MAX_LEN) { 150 if (scroll + input_x < MAX_LEN) {
143 wattrset(dialog, inputbox_attr); 151 wattrset(dialog, dlg.inputbox.atr);
144 instr[scroll + input_x] = key; 152 instr[scroll + input_x] = key;
145 instr[scroll + input_x + 1] = '\0'; 153 instr[scroll + input_x + 1] = '\0';
146 if (input_x == box_width - 1) { 154 if (input_x == box_width - 1) {
@@ -213,12 +221,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
213 return (button == -1 ? 0 : button); 221 return (button == -1 ? 0 : button);
214 case 'X': 222 case 'X':
215 case 'x': 223 case 'x':
216 key = ESC; 224 key = KEY_ESC;
217 case ESC: 225 break;
226 case KEY_ESC:
227 key = on_key_esc(dialog);
218 break; 228 break;
229 case KEY_RESIZE:
230 delwin(dialog);
231 on_key_resize();
232 goto do_resize;
219 } 233 }
220 } 234 }
221 235
222 delwin(dialog); 236 delwin(dialog);
223 return -1; /* ESC pressed */ 237 return KEY_ESC; /* ESC pressed */
224} 238}