Commit 4f2de3e1 authored by Dirk Gouders's avatar Dirk Gouders Committed by Yann E. MORIN

mconf: 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 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: default avatarDirk Gouders <dirk@gouders.net>
Tested-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: default avatarYann E. MORIN <yann.morin.1998@free.fr>
parent 13763916
...@@ -140,8 +140,8 @@ int dialog_checklist(const char *title, const char *prompt, int height, ...@@ -140,8 +140,8 @@ int dialog_checklist(const char *title, const char *prompt, int height,
max_choice = MIN(list_height, item_count()); max_choice = MIN(list_height, item_count());
/* center dialog box on screen */ /* center dialog box on screen */
x = (COLS - width) / 2; x = (getmaxx(stdscr) - width) / 2;
y = (LINES - height) / 2; y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width); draw_shadow(stdscr, y, x, height, width);
......
...@@ -62,8 +62,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -62,8 +62,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
return -ERRDISPLAYTOOSMALL; return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */ /* center dialog box on screen */
x = (COLS - width) / 2; x = (getmaxx(stdscr) - width) / 2;
y = (LINES - height) / 2; y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width); draw_shadow(stdscr, y, x, height, width);
......
...@@ -203,8 +203,8 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -203,8 +203,8 @@ int dialog_menu(const char *title, const char *prompt,
max_choice = MIN(menu_height, item_count()); max_choice = MIN(menu_height, item_count());
/* center dialog box on screen */ /* center dialog box on screen */
x = (COLS - width) / 2; x = (getmaxx(stdscr) - width) / 2;
y = (LINES - height) / 2; y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width); draw_shadow(stdscr, y, x, height, width);
......
...@@ -98,8 +98,8 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height, ...@@ -98,8 +98,8 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height,
width = 0; width = 0;
/* center dialog box on screen */ /* center dialog box on screen */
x = (COLS - width) / 2; x = (getmaxx(stdscr) - width) / 2;
y = (LINES - height) / 2; y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width); draw_shadow(stdscr, y, x, height, width);
......
...@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr) ...@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
void dialog_clear(void) 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 */ /* Display background title if it exists ... - SLH */
if (dlg.backtitle != NULL) { if (dlg.backtitle != NULL) {
int i, len = 0, skip = 0; int i, len = 0, skip = 0;
...@@ -269,10 +274,10 @@ void dialog_clear(void) ...@@ -269,10 +274,10 @@ void dialog_clear(void)
} }
wmove(stdscr, 1, 1); wmove(stdscr, 1, 1);
if (len > COLS - 2) { if (len > columns - 2) {
const char *ellipsis = "[...] "; const char *ellipsis = "[...] ";
waddstr(stdscr, 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) { for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
...@@ -298,7 +303,7 @@ void dialog_clear(void) ...@@ -298,7 +303,7 @@ void dialog_clear(void)
skip--; skip--;
} }
for (i = len + 1; i < COLS - 1; i++) for (i = len + 1; i < columns - 1; i++)
waddch(stdscr, ACS_HLINE); waddch(stdscr, ACS_HLINE);
} }
wnoutrefresh(stdscr); wnoutrefresh(stdscr);
......
...@@ -51,8 +51,8 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) ...@@ -51,8 +51,8 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
return -ERRDISPLAYTOOSMALL; return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */ /* center dialog box on screen */
x = (COLS - width) / 2; x = (getmaxx(stdscr) - width) / 2;
y = (LINES - height) / 2; y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width); draw_shadow(stdscr, y, x, height, width);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment