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)
Unified · Split
| @@ -140,8 +140,8 @@ do_resize: · 139 unmodified lines | ||
| 140 | 140 | max_choice = MIN(list_height, item_count()); |
| 141 | 141 | |
| 142 | 142 | /* center dialog box on screen */ |
| 143 | − x = (COLS - width) / 2; | |
| 144 | − y = (LINES - height) / 2; | |
| 143 | + x = (getmaxx(stdscr) - width) / 2; | |
| 144 | + y = (getmaxy(stdscr) - height) / 2; | |
| 145 | 145 | |
| 146 | 146 | draw_shadow(stdscr, y, x, height, width); |
| 147 | 147 | |
| @@ -62,8 +62,8 @@ do_resize: · 61 unmodified lines | ||
| 62 | 62 | return -ERRDISPLAYTOOSMALL; |
| 63 | 63 | |
| 64 | 64 | /* center dialog box on screen */ |
| 65 | − x = (COLS - width) / 2; | |
| 66 | − y = (LINES - height) / 2; | |
| 65 | + x = (getmaxx(stdscr) - width) / 2; | |
| 66 | + y = (getmaxy(stdscr) - height) / 2; | |
| 67 | 67 | |
| 68 | 68 | draw_shadow(stdscr, y, x, height, width); |
| 69 | 69 | |
| @@ -203,8 +203,8 @@ do_resize: · 202 unmodified lines | ||
| 203 | 203 | max_choice = MIN(menu_height, item_count()); |
| 204 | 204 | |
| 205 | 205 | /* center dialog box on screen */ |
| 206 | − x = (COLS - width) / 2; | |
| 207 | − y = (LINES - height) / 2; | |
| 206 | + x = (getmaxx(stdscr) - width) / 2; | |
| 207 | + y = (getmaxy(stdscr) - height) / 2; | |
| 208 | 208 | |
| 209 | 209 | draw_shadow(stdscr, y, x, height, width); |
| 210 | 210 | |
| @@ -98,8 +98,8 @@ do_resize: · 97 unmodified lines | ||
| 98 | 98 | width = 0; |
| 99 | 99 | |
| 100 | 100 | /* center dialog box on screen */ |
| 101 | − x = (COLS - width) / 2; | |
| 102 | − y = (LINES - height) / 2; | |
| 101 | + x = (getmaxx(stdscr) - width) / 2; | |
| 102 | + y = (getmaxy(stdscr) - height) / 2; | |
| 103 | 103 | |
| 104 | 104 | draw_shadow(stdscr, y, x, height, width); |
| 105 | 105 | |
| @@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr) · 253 unmodified lines | ||
| 254 | 254 | |
| 255 | 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 | 263 | /* Display background title if it exists ... - SLH */ |
| 259 | 264 | if (dlg.backtitle != NULL) { |
| 260 | 265 | int i, len = 0, skip = 0; |
| @@ -269,10 +274,10 @@ void dialog_clear(void) · 8 unmodified lines | ||
| 269 | 274 | } |
| 270 | 275 | |
| 271 | 276 | wmove(stdscr, 1, 1); |
| 272 | − if (len > COLS - 2) { | |
| 277 | + if (len > columns - 2) { | |
| 273 | 278 | const char *ellipsis = "[...] "; |
| 274 | 279 | waddstr(stdscr, ellipsis); |
| 275 | − skip = len - (COLS - 2 - strlen(ellipsis)); | |
| 280 | + skip = len - (columns - 2 - strlen(ellipsis)); | |
| 276 | 281 | } |
| 277 | 282 | |
| 278 | 283 | for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { |
| @@ -298,7 +303,7 @@ void dialog_clear(void) · 19 unmodified lines | ||
| 298 | 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 | 307 | waddch(stdscr, ACS_HLINE); |
| 303 | 308 | } |
| 304 | 309 | wnoutrefresh(stdscr); |
| @@ -51,8 +51,8 @@ do_resize: · 50 unmodified lines | ||
| 51 | 51 | return -ERRDISPLAYTOOSMALL; |
| 52 | 52 | |
| 53 | 53 | /* center dialog box on screen */ |
| 54 | − x = (COLS - width) / 2; | |
| 55 | − y = (LINES - height) / 2; | |
| 54 | + x = (getmaxx(stdscr) - width) / 2; | |
| 55 | + y = (getmaxy(stdscr) - height) / 2; | |
| 56 | 56 | |
| 57 | 57 | draw_shadow(stdscr, y, x, height, width); |
| 58 | 58 | |