diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2013-07-12 06:34:42 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2013-07-12 06:34:42 -0400 |
commit | f2006e27396f55276f24434f56e208d86e7f9908 (patch) | |
tree | 71896db916d33888b4286f80117d3cac0da40e6d /scripts/kconfig/lxdialog/util.c | |
parent | e399eb56a6110e13f97e644658648602e2b08de7 (diff) | |
parent | 9903883f1dd6e86f286b7bfa6e4b423f98c1cd9e (diff) |
Merge branch 'linus' into timers/urgent
Get upstream changes so we can apply fixes against them
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'scripts/kconfig/lxdialog/util.c')
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 46 |
1 files changed, 27 insertions, 19 deletions
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 == ' ') ; |