diff options
Diffstat (limited to 'scripts/kconfig/lxdialog')
-rw-r--r-- | scripts/kconfig/lxdialog/checklist.c | 8 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 14 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/inputbox.c | 8 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/menubox.c | 6 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 6 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 46 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/yesno.c | 8 |
7 files changed, 59 insertions, 37 deletions
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index a2eb80fbc896..3b15c08ec1fa 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c | |||
@@ -132,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
132 | } | 132 | } |
133 | 133 | ||
134 | do_resize: | 134 | do_resize: |
135 | if (getmaxy(stdscr) < (height + 6)) | 135 | if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN)) |
136 | return -ERRDISPLAYTOOSMALL; | 136 | return -ERRDISPLAYTOOSMALL; |
137 | if (getmaxx(stdscr) < (width + 6)) | 137 | if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN)) |
138 | return -ERRDISPLAYTOOSMALL; | 138 | return -ERRDISPLAYTOOSMALL; |
139 | 139 | ||
140 | max_choice = MIN(list_height, item_count()); | 140 | max_choice = MIN(list_height, item_count()); |
141 | 141 | ||
142 | /* center dialog box on screen */ | 142 | /* center dialog box on screen */ |
143 | x = (COLS - width) / 2; | 143 | x = (getmaxx(stdscr) - width) / 2; |
144 | y = (LINES - height) / 2; | 144 | y = (getmaxy(stdscr) - height) / 2; |
145 | 145 | ||
146 | draw_shadow(stdscr, y, x, height, width); | 146 | draw_shadow(stdscr, y, x, height, width); |
147 | 147 | ||
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 1099337079b6..b4343d384926 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -200,6 +200,20 @@ int item_is_tag(char tag); | |||
200 | int on_key_esc(WINDOW *win); | 200 | int on_key_esc(WINDOW *win); |
201 | int on_key_resize(void); | 201 | int on_key_resize(void); |
202 | 202 | ||
203 | /* minimum (re)size values */ | ||
204 | #define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */ | ||
205 | #define CHECKLIST_WIDTH_MIN 6 | ||
206 | #define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */ | ||
207 | #define INPUTBOX_WIDTH_MIN 2 | ||
208 | #define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */ | ||
209 | #define MENUBOX_WIDTH_MIN 65 | ||
210 | #define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */ | ||
211 | #define TEXTBOX_WIDTH_MIN 8 | ||
212 | #define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */ | ||
213 | #define YESNO_WIDTH_MIN 4 | ||
214 | #define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */ | ||
215 | #define WINDOW_WIDTH_MIN 80 | ||
216 | |||
203 | int init_dialog(const char *backtitle); | 217 | int init_dialog(const char *backtitle); |
204 | void set_dialog_backtitle(const char *backtitle); | 218 | void set_dialog_backtitle(const char *backtitle); |
205 | void set_dialog_subtitles(struct subtitle_list *subtitles); | 219 | void set_dialog_subtitles(struct subtitle_list *subtitles); |
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 21404a04d7c3..447a582198c9 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
@@ -56,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
56 | strcpy(instr, init); | 56 | strcpy(instr, init); |
57 | 57 | ||
58 | do_resize: | 58 | do_resize: |
59 | if (getmaxy(stdscr) <= (height - 2)) | 59 | if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN)) |
60 | return -ERRDISPLAYTOOSMALL; | 60 | return -ERRDISPLAYTOOSMALL; |
61 | if (getmaxx(stdscr) <= (width - 2)) | 61 | if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN)) |
62 | return -ERRDISPLAYTOOSMALL; | 62 | return -ERRDISPLAYTOOSMALL; |
63 | 63 | ||
64 | /* center dialog box on screen */ | 64 | /* center dialog box on screen */ |
65 | x = (COLS - width) / 2; | 65 | x = (getmaxx(stdscr) - width) / 2; |
66 | y = (LINES - height) / 2; | 66 | y = (getmaxy(stdscr) - height) / 2; |
67 | 67 | ||
68 | draw_shadow(stdscr, y, x, height, width); | 68 | draw_shadow(stdscr, y, x, height, width); |
69 | 69 | ||
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index 38cd69c5660e..c93de0b2faca 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c | |||
@@ -193,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt, | |||
193 | do_resize: | 193 | do_resize: |
194 | height = getmaxy(stdscr); | 194 | height = getmaxy(stdscr); |
195 | width = getmaxx(stdscr); | 195 | width = getmaxx(stdscr); |
196 | if (height < 15 || width < 65) | 196 | if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN) |
197 | return -ERRDISPLAYTOOSMALL; | 197 | return -ERRDISPLAYTOOSMALL; |
198 | 198 | ||
199 | height -= 4; | 199 | height -= 4; |
@@ -203,8 +203,8 @@ do_resize: | |||
203 | max_choice = MIN(menu_height, item_count()); | 203 | max_choice = MIN(menu_height, item_count()); |
204 | 204 | ||
205 | /* center dialog box on screen */ | 205 | /* center dialog box on screen */ |
206 | x = (COLS - width) / 2; | 206 | x = (getmaxx(stdscr) - width) / 2; |
207 | y = (LINES - height) / 2; | 207 | y = (getmaxy(stdscr) - height) / 2; |
208 | 208 | ||
209 | draw_shadow(stdscr, y, x, height, width); | 209 | draw_shadow(stdscr, y, x, height, width); |
210 | 210 | ||
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index a48bb93e0907..1773319b95e7 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c | |||
@@ -80,7 +80,7 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height, | |||
80 | 80 | ||
81 | do_resize: | 81 | do_resize: |
82 | getmaxyx(stdscr, height, width); | 82 | getmaxyx(stdscr, height, width); |
83 | if (height < 8 || width < 8) | 83 | if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN) |
84 | return -ERRDISPLAYTOOSMALL; | 84 | return -ERRDISPLAYTOOSMALL; |
85 | if (initial_height != 0) | 85 | if (initial_height != 0) |
86 | height = initial_height; | 86 | height = initial_height; |
@@ -98,8 +98,8 @@ do_resize: | |||
98 | width = 0; | 98 | width = 0; |
99 | 99 | ||
100 | /* center dialog box on screen */ | 100 | /* center dialog box on screen */ |
101 | x = (COLS - width) / 2; | 101 | x = (getmaxx(stdscr) - width) / 2; |
102 | y = (LINES - height) / 2; | 102 | y = (getmaxy(stdscr) - height) / 2; |
103 | 103 | ||
104 | draw_shadow(stdscr, y, x, height, width); | 104 | draw_shadow(stdscr, y, x, height, width); |
105 | 105 | ||
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index a0e97c299410..58a8289dd650 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c | |||
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr) | |||
254 | 254 | ||
255 | void dialog_clear(void) | 255 | void dialog_clear(void) |
256 | { | 256 | { |
257 | attr_clear(stdscr, LINES, COLS, dlg.screen.atr); | 257 | int lines, columns; |
258 | |||
259 | lines = getmaxy(stdscr); | ||
260 | columns = getmaxx(stdscr); | ||
261 | |||
262 | attr_clear(stdscr, lines, columns, dlg.screen.atr); | ||
258 | /* Display background title if it exists ... - SLH */ | 263 | /* Display background title if it exists ... - SLH */ |
259 | if (dlg.backtitle != NULL) { | 264 | if (dlg.backtitle != NULL) { |
260 | int i, len = 0, skip = 0; | 265 | int i, len = 0, skip = 0; |
@@ -269,10 +274,10 @@ void dialog_clear(void) | |||
269 | } | 274 | } |
270 | 275 | ||
271 | wmove(stdscr, 1, 1); | 276 | wmove(stdscr, 1, 1); |
272 | if (len > COLS - 2) { | 277 | if (len > columns - 2) { |
273 | const char *ellipsis = "[...] "; | 278 | const char *ellipsis = "[...] "; |
274 | waddstr(stdscr, ellipsis); | 279 | waddstr(stdscr, ellipsis); |
275 | skip = len - (COLS - 2 - strlen(ellipsis)); | 280 | skip = len - (columns - 2 - strlen(ellipsis)); |
276 | } | 281 | } |
277 | 282 | ||
278 | for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { | 283 | for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { |
@@ -298,7 +303,7 @@ void dialog_clear(void) | |||
298 | skip--; | 303 | skip--; |
299 | } | 304 | } |
300 | 305 | ||
301 | for (i = len + 1; i < COLS - 1; i++) | 306 | for (i = len + 1; i < columns - 1; i++) |
302 | waddch(stdscr, ACS_HLINE); | 307 | waddch(stdscr, ACS_HLINE); |
303 | } | 308 | } |
304 | wnoutrefresh(stdscr); | 309 | wnoutrefresh(stdscr); |
@@ -317,7 +322,7 @@ int init_dialog(const char *backtitle) | |||
317 | getyx(stdscr, saved_y, saved_x); | 322 | getyx(stdscr, saved_y, saved_x); |
318 | 323 | ||
319 | getmaxyx(stdscr, height, width); | 324 | getmaxyx(stdscr, height, width); |
320 | if (height < 19 || width < 80) { | 325 | if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) { |
321 | endwin(); | 326 | endwin(); |
322 | return -ERRDISPLAYTOOSMALL; | 327 | return -ERRDISPLAYTOOSMALL; |
323 | } | 328 | } |
@@ -371,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width) | |||
371 | /* | 376 | /* |
372 | * Print a string of text in a window, automatically wrap around to the | 377 | * Print a string of text in a window, automatically wrap around to the |
373 | * next line if the string is too long to fit on one line. Newline | 378 | * next line if the string is too long to fit on one line. Newline |
374 | * characters '\n' are replaced by spaces. We start on a new line | 379 | * characters '\n' are propperly processed. We start on a new line |
375 | * if there is no room for at least 4 nonblanks following a double-space. | 380 | * if there is no room for at least 4 nonblanks following a double-space. |
376 | */ | 381 | */ |
377 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) | 382 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) |
378 | { | 383 | { |
379 | int newl, cur_x, cur_y; | 384 | int newl, cur_x, cur_y; |
380 | int i, prompt_len, room, wlen; | 385 | int prompt_len, room, wlen; |
381 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | 386 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0; |
382 | 387 | ||
383 | strcpy(tempstr, prompt); | 388 | strcpy(tempstr, prompt); |
384 | 389 | ||
385 | prompt_len = strlen(tempstr); | 390 | prompt_len = strlen(tempstr); |
386 | 391 | ||
387 | /* | ||
388 | * Remove newlines | ||
389 | */ | ||
390 | for (i = 0; i < prompt_len; i++) { | ||
391 | if (tempstr[i] == '\n') | ||
392 | tempstr[i] = ' '; | ||
393 | } | ||
394 | |||
395 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | 392 | if (prompt_len <= width - x * 2) { /* If prompt is short */ |
396 | wmove(win, y, (width - prompt_len) / 2); | 393 | wmove(win, y, (width - prompt_len) / 2); |
397 | waddstr(win, tempstr); | 394 | waddstr(win, tempstr); |
@@ -401,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) | |||
401 | newl = 1; | 398 | newl = 1; |
402 | word = tempstr; | 399 | word = tempstr; |
403 | while (word && *word) { | 400 | while (word && *word) { |
404 | sp = strchr(word, ' '); | 401 | sp = strpbrk(word, "\n "); |
402 | if (sp && *sp == '\n') | ||
403 | newline_separator = sp; | ||
404 | |||
405 | if (sp) | 405 | if (sp) |
406 | *sp++ = 0; | 406 | *sp++ = 0; |
407 | 407 | ||
@@ -413,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) | |||
413 | if (wlen > room || | 413 | if (wlen > room || |
414 | (newl && wlen < 4 && sp | 414 | (newl && wlen < 4 && sp |
415 | && wlen + 1 + strlen(sp) > room | 415 | && wlen + 1 + strlen(sp) > room |
416 | && (!(sp2 = strchr(sp, ' ')) | 416 | && (!(sp2 = strpbrk(sp, "\n ")) |
417 | || wlen + 1 + (sp2 - sp) > room))) { | 417 | || wlen + 1 + (sp2 - sp) > room))) { |
418 | cur_y++; | 418 | cur_y++; |
419 | cur_x = x; | 419 | cur_x = x; |
@@ -421,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) | |||
421 | wmove(win, cur_y, cur_x); | 421 | wmove(win, cur_y, cur_x); |
422 | waddstr(win, word); | 422 | waddstr(win, word); |
423 | getyx(win, cur_y, cur_x); | 423 | getyx(win, cur_y, cur_x); |
424 | cur_x++; | 424 | |
425 | /* Move to the next line if the word separator was a newline */ | ||
426 | if (newline_separator) { | ||
427 | cur_y++; | ||
428 | cur_x = x; | ||
429 | newline_separator = 0; | ||
430 | } else | ||
431 | cur_x++; | ||
432 | |||
425 | if (sp && *sp == ' ') { | 433 | if (sp && *sp == ' ') { |
426 | cur_x++; /* double space */ | 434 | cur_x++; /* double space */ |
427 | while (*++sp == ' ') ; | 435 | while (*++sp == ' ') ; |
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c index 4e6e8090c20b..676fb2f824a3 100644 --- a/scripts/kconfig/lxdialog/yesno.c +++ b/scripts/kconfig/lxdialog/yesno.c | |||
@@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) | |||
45 | WINDOW *dialog; | 45 | WINDOW *dialog; |
46 | 46 | ||
47 | do_resize: | 47 | do_resize: |
48 | if (getmaxy(stdscr) < (height + 4)) | 48 | if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN)) |
49 | return -ERRDISPLAYTOOSMALL; | 49 | return -ERRDISPLAYTOOSMALL; |
50 | if (getmaxx(stdscr) < (width + 4)) | 50 | if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN)) |
51 | return -ERRDISPLAYTOOSMALL; | 51 | return -ERRDISPLAYTOOSMALL; |
52 | 52 | ||
53 | /* center dialog box on screen */ | 53 | /* center dialog box on screen */ |
54 | x = (COLS - width) / 2; | 54 | x = (getmaxx(stdscr) - width) / 2; |
55 | y = (LINES - height) / 2; | 55 | y = (getmaxy(stdscr) - height) / 2; |
56 | 56 | ||
57 | draw_shadow(stdscr, y, x, height, width); | 57 | draw_shadow(stdscr, y, x, height, width); |
58 | 58 | ||