aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/nconf.c
diff options
context:
space:
mode:
authorDirk Gouders <dirk@gouders.net>2013-05-13 05:23:58 -0400
committerYann E. MORIN <yann.morin.1998@free.fr>2013-06-18 17:58:58 -0400
commite0b42605e685a0833303e1d4dde277c99d9e17b5 (patch)
treeb6f1c8101c404a11d2dccfabfd2141b3e3e6799f /scripts/kconfig/nconf.c
parent4f2de3e19983dafca264b672152b36e4962ca1c3 (diff)
nconf: use function calls instead of ncurses' variables LINES and COLS
According to the documentation [1], LINES and COLS are initialized by initscr(); it does not say anything about the behavior when windows are resized. Do not rely on the current implementation of ncurses that updates these variables on resize, but use the propper function calls or macros to get window dimensions. The use of the variables in main() was OK, but for the sake of consistency it was modified to use the macro getmaxyx(). [1] ncurses(3X) Signed-off-by: Dirk Gouders <dirk@gouders.net> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> [yann.morin.1998@free.fr: declare 'lines' and 'columns' on a single line] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Diffstat (limited to 'scripts/kconfig/nconf.c')
-rw-r--r--scripts/kconfig/nconf.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index dbf31edd22b2..aac85d37b69b 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -365,15 +365,16 @@ static void print_function_line(void)
365 int i; 365 int i;
366 int offset = 1; 366 int offset = 1;
367 const int skip = 1; 367 const int skip = 1;
368 int lines = getmaxy(stdscr);
368 369
369 for (i = 0; i < function_keys_num; i++) { 370 for (i = 0; i < function_keys_num; i++) {
370 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); 371 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
371 mvwprintw(main_window, LINES-3, offset, 372 mvwprintw(main_window, lines-3, offset,
372 "%s", 373 "%s",
373 function_keys[i].key_str); 374 function_keys[i].key_str);
374 (void) wattrset(main_window, attributes[FUNCTION_TEXT]); 375 (void) wattrset(main_window, attributes[FUNCTION_TEXT]);
375 offset += strlen(function_keys[i].key_str); 376 offset += strlen(function_keys[i].key_str);
376 mvwprintw(main_window, LINES-3, 377 mvwprintw(main_window, lines-3,
377 offset, "%s", 378 offset, "%s",
378 function_keys[i].func); 379 function_keys[i].func);
379 offset += strlen(function_keys[i].func) + skip; 380 offset += strlen(function_keys[i].func) + skip;
@@ -954,7 +955,7 @@ static void show_menu(const char *prompt, const char *instructions,
954 955
955 clear(); 956 clear();
956 (void) wattrset(main_window, attributes[NORMAL]); 957 (void) wattrset(main_window, attributes[NORMAL]);
957 print_in_middle(stdscr, 1, 0, COLS, 958 print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
958 menu_backtitle, 959 menu_backtitle,
959 attributes[MAIN_HEADING]); 960 attributes[MAIN_HEADING]);
960 961
@@ -1455,14 +1456,18 @@ static void conf_save(void)
1455 1456
1456void setup_windows(void) 1457void setup_windows(void)
1457{ 1458{
1459 int lines, columns;
1460
1461 getmaxyx(stdscr, lines, columns);
1462
1458 if (main_window != NULL) 1463 if (main_window != NULL)
1459 delwin(main_window); 1464 delwin(main_window);
1460 1465
1461 /* set up the menu and menu window */ 1466 /* set up the menu and menu window */
1462 main_window = newwin(LINES-2, COLS-2, 2, 1); 1467 main_window = newwin(lines-2, columns-2, 2, 1);
1463 keypad(main_window, TRUE); 1468 keypad(main_window, TRUE);
1464 mwin_max_lines = LINES-7; 1469 mwin_max_lines = lines-7;
1465 mwin_max_cols = COLS-6; 1470 mwin_max_cols = columns-6;
1466 1471
1467 /* panels order is from bottom to top */ 1472 /* panels order is from bottom to top */
1468 new_panel(main_window); 1473 new_panel(main_window);
@@ -1470,6 +1475,7 @@ void setup_windows(void)
1470 1475
1471int main(int ac, char **av) 1476int main(int ac, char **av)
1472{ 1477{
1478 int lines, columns;
1473 char *mode; 1479 char *mode;
1474 1480
1475 setlocale(LC_ALL, ""); 1481 setlocale(LC_ALL, "");
@@ -1495,7 +1501,8 @@ int main(int ac, char **av)
1495 keypad(stdscr, TRUE); 1501 keypad(stdscr, TRUE);
1496 curs_set(0); 1502 curs_set(0);
1497 1503
1498 if (COLS < 75 || LINES < 20) { 1504 getmaxyx(stdscr, lines, columns);
1505 if (columns < 75 || lines < 20) {
1499 endwin(); 1506 endwin();
1500 printf("Your terminal should have at " 1507 printf("Your terminal should have at "
1501 "least 20 lines and 75 columns\n"); 1508 "least 20 lines and 75 columns\n");