]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mconf: use function calls instead of ncurses' variables LINES and COLS
authorDirk Gouders <dirk@gouders.net>
Sun, 12 May 2013 10:30:49 +0000 (12:30 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Tue, 18 Jun 2013 21:58:58 +0000 (23:58 +0200)
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 to get
window dimensions.

init_dialog() could make use of the variables, but for the sake of
consistency we do not change it's current use of the macro getmaxyx().

[1] ncurses(3X)

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
scripts/kconfig/lxdialog/checklist.c
scripts/kconfig/lxdialog/inputbox.c
scripts/kconfig/lxdialog/menubox.c
scripts/kconfig/lxdialog/textbox.c
scripts/kconfig/lxdialog/util.c
scripts/kconfig/lxdialog/yesno.c

index 30340571190e2af5adc3f24b8a7d298b8b368a0c..3b15c08ec1fac369f9b6e0b01c738e46fa3efb2d 100644 (file)
@@ -140,8 +140,8 @@ int dialog_checklist(const char *title, const char *prompt, int height,
        max_choice = MIN(list_height, item_count());
 
        /* center dialog box on screen */
-       x = (COLS - width) / 2;
-       y = (LINES - height) / 2;
+       x = (getmaxx(stdscr) - width) / 2;
+       y = (getmaxy(stdscr) - height) / 2;
 
        draw_shadow(stdscr, y, x, height, width);
 
index 7b01add415a89f959b0f7889a326e32e97c3014d..447a582198c9bc70c37c4d2d034b128b5a62080d 100644 (file)
@@ -62,8 +62,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
                return -ERRDISPLAYTOOSMALL;
 
        /* center dialog box on screen */
-       x = (COLS - width) / 2;
-       y = (LINES - height) / 2;
+       x = (getmaxx(stdscr) - width) / 2;
+       y = (getmaxy(stdscr) - height) / 2;
 
        draw_shadow(stdscr, y, x, height, width);
 
index 00d28410adc92f489b25fc7cb0d92136c439224d..92b89a6cb35addb31e1330b67787ecfe248bbbc6 100644 (file)
@@ -203,8 +203,8 @@ int dialog_menu(const char *title, const char *prompt,
        max_choice = MIN(menu_height, item_count());
 
        /* center dialog box on screen */
-       x = (COLS - width) / 2;
-       y = (LINES - height) / 2;
+       x = (getmaxx(stdscr) - width) / 2;
+       y = (getmaxy(stdscr) - height) / 2;
 
        draw_shadow(stdscr, y, x, height, width);
 
index 907cdcb397c1dce72077adf9d249944ff639c479..1773319b95e74f68ee2c618654e8ee00c96b1b37 100644 (file)
@@ -98,8 +98,8 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height,
                        width = 0;
 
        /* center dialog box on screen */
-       x = (COLS - width) / 2;
-       y = (LINES - height) / 2;
+       x = (getmaxx(stdscr) - width) / 2;
+       y = (getmaxy(stdscr) - height) / 2;
 
        draw_shadow(stdscr, y, x, height, width);
 
index 0fa567eb68c6f4fd8066add22bc164031500224e..58a8289dd650281c29f8e34827c153e9b4d4ac74 100644 (file)
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
 
 void dialog_clear(void)
 {
-       attr_clear(stdscr, LINES, COLS, dlg.screen.atr);
+       int lines, columns;
+
+       lines = getmaxy(stdscr);
+       columns = getmaxx(stdscr);
+
+       attr_clear(stdscr, lines, columns, dlg.screen.atr);
        /* Display background title if it exists ... - SLH */
        if (dlg.backtitle != NULL) {
                int i, len = 0, skip = 0;
@@ -269,10 +274,10 @@ void dialog_clear(void)
                }
 
                wmove(stdscr, 1, 1);
-               if (len > COLS - 2) {
+               if (len > columns - 2) {
                        const char *ellipsis = "[...] ";
                        waddstr(stdscr, ellipsis);
-                       skip = len - (COLS - 2 - strlen(ellipsis));
+                       skip = len - (columns - 2 - strlen(ellipsis));
                }
 
                for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
@@ -298,7 +303,7 @@ void dialog_clear(void)
                                skip--;
                }
 
-               for (i = len + 1; i < COLS - 1; i++)
+               for (i = len + 1; i < columns - 1; i++)
                        waddch(stdscr, ACS_HLINE);
        }
        wnoutrefresh(stdscr);
index abb0c392e01b9172b614150f7f9f2ec986e35912..676fb2f824a3d41c81ef5348a4efc3630155cb14 100644 (file)
@@ -51,8 +51,8 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
                return -ERRDISPLAYTOOSMALL;
 
        /* center dialog box on screen */
-       x = (COLS - width) / 2;
-       y = (LINES - height) / 2;
+       x = (getmaxx(stdscr) - width) / 2;
+       y = (getmaxy(stdscr) - height) / 2;
 
        draw_shadow(stdscr, y, x, height, width);