diff options
-rw-r--r-- | scripts/kconfig/nconf.gui.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 8275f0e55106..4b2f44c20caf 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c | |||
@@ -364,12 +364,14 @@ int dialog_inputbox(WINDOW *main_window, | |||
364 | WINDOW *prompt_win; | 364 | WINDOW *prompt_win; |
365 | WINDOW *form_win; | 365 | WINDOW *form_win; |
366 | PANEL *panel; | 366 | PANEL *panel; |
367 | int i, x, y; | 367 | int i, x, y, lines, columns, win_lines, win_cols; |
368 | int res = -1; | 368 | int res = -1; |
369 | int cursor_position = strlen(init); | 369 | int cursor_position = strlen(init); |
370 | int cursor_form_win; | 370 | int cursor_form_win; |
371 | char *result = *resultp; | 371 | char *result = *resultp; |
372 | 372 | ||
373 | getmaxyx(stdscr, lines, columns); | ||
374 | |||
373 | if (strlen(init)+1 > *result_len) { | 375 | if (strlen(init)+1 > *result_len) { |
374 | *result_len = strlen(init)+1; | 376 | *result_len = strlen(init)+1; |
375 | *resultp = result = realloc(result, *result_len); | 377 | *resultp = result = realloc(result, *result_len); |
@@ -386,14 +388,19 @@ int dialog_inputbox(WINDOW *main_window, | |||
386 | if (title) | 388 | if (title) |
387 | prompt_width = max(prompt_width, strlen(title)); | 389 | prompt_width = max(prompt_width, strlen(title)); |
388 | 390 | ||
391 | win_lines = min(prompt_lines+6, lines-2); | ||
392 | win_cols = min(prompt_width+7, columns-2); | ||
393 | prompt_lines = max(win_lines-6, 0); | ||
394 | prompt_width = max(win_cols-7, 0); | ||
395 | |||
389 | /* place dialog in middle of screen */ | 396 | /* place dialog in middle of screen */ |
390 | y = (getmaxy(stdscr)-(prompt_lines+4))/2; | 397 | y = (lines-win_lines)/2; |
391 | x = (getmaxx(stdscr)-(prompt_width+4))/2; | 398 | x = (columns-win_cols)/2; |
392 | 399 | ||
393 | strncpy(result, init, *result_len); | 400 | strncpy(result, init, *result_len); |
394 | 401 | ||
395 | /* create the windows */ | 402 | /* create the windows */ |
396 | win = newwin(prompt_lines+6, prompt_width+7, y, x); | 403 | win = newwin(win_lines, win_cols, y, x); |
397 | prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2); | 404 | prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2); |
398 | form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); | 405 | form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); |
399 | keypad(form_win, TRUE); | 406 | keypad(form_win, TRUE); |