aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDirk Gouders <dirk@gouders.net>2013-05-12 06:30:49 -0400
committerYann E. MORIN <yann.morin.1998@free.fr>2013-06-18 17:58:58 -0400
commit4f2de3e19983dafca264b672152b36e4962ca1c3 (patch)
tree8d4b6fac4d7a4f4c7220918ee93f175ae4a01ff0 /scripts
parent1376391621654cc369c5e8b60497f7c184f0ed47 (diff)
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: 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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/lxdialog/checklist.c4
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c4
-rw-r--r--scripts/kconfig/lxdialog/menubox.c4
-rw-r--r--scripts/kconfig/lxdialog/textbox.c4
-rw-r--r--scripts/kconfig/lxdialog/util.c13
-rw-r--r--scripts/kconfig/lxdialog/yesno.c4
6 files changed, 19 insertions, 14 deletions
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
index 30340571190e..3b15c08ec1fa 100644
--- a/scripts/kconfig/lxdialog/checklist.c
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -140,8 +140,8 @@ do_resize:
140 max_choice = MIN(list_height, item_count()); 140 max_choice = MIN(list_height, item_count());
141 141
142 /* center dialog box on screen */ 142 /* center dialog box on screen */
143 x = (COLS - width) / 2; 143 x = (getmaxx(stdscr) - width) / 2;
144 y = (LINES - height) / 2; 144 y = (getmaxy(stdscr) - height) / 2;
145 145
146 draw_shadow(stdscr, y, x, height, width); 146 draw_shadow(stdscr, y, x, height, width);
147 147
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 7b01add415a8..447a582198c9 100644
--- a/scripts/kconfig/lxdialog/inputbox.c
+++ b/scripts/kconfig/lxdialog/inputbox.c
@@ -62,8 +62,8 @@ do_resize:
62 return -ERRDISPLAYTOOSMALL; 62 return -ERRDISPLAYTOOSMALL;
63 63
64 /* center dialog box on screen */ 64 /* center dialog box on screen */
65 x = (COLS - width) / 2; 65 x = (getmaxx(stdscr) - width) / 2;
66 y = (LINES - height) / 2; 66 y = (getmaxy(stdscr) - height) / 2;
67 67
68 draw_shadow(stdscr, y, x, height, width); 68 draw_shadow(stdscr, y, x, height, width);
69 69
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 00d28410adc9..92b89a6cb35a 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -203,8 +203,8 @@ do_resize:
203 max_choice = MIN(menu_height, item_count()); 203 max_choice = MIN(menu_height, item_count());
204 204
205 /* center dialog box on screen */ 205 /* center dialog box on screen */
206 x = (COLS - width) / 2; 206 x = (getmaxx(stdscr) - width) / 2;
207 y = (LINES - height) / 2; 207 y = (getmaxy(stdscr) - height) / 2;
208 208
209 draw_shadow(stdscr, y, x, height, width); 209 draw_shadow(stdscr, y, x, height, width);
210 210
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
index 907cdcb397c1..1773319b95e7 100644
--- a/scripts/kconfig/lxdialog/textbox.c
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -98,8 +98,8 @@ do_resize:
98 width = 0; 98 width = 0;
99 99
100 /* center dialog box on screen */ 100 /* center dialog box on screen */
101 x = (COLS - width) / 2; 101 x = (getmaxx(stdscr) - width) / 2;
102 y = (LINES - height) / 2; 102 y = (getmaxy(stdscr) - height) / 2;
103 103
104 draw_shadow(stdscr, y, x, height, width); 104 draw_shadow(stdscr, y, x, height, width);
105 105
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index 0fa567eb68c6..58a8289dd650 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
254 254
255void dialog_clear(void) 255void 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 /* Display background title if it exists ... - SLH */ 263 /* Display background title if it exists ... - SLH */
259 if (dlg.backtitle != NULL) { 264 if (dlg.backtitle != NULL) {
260 int i, len = 0, skip = 0; 265 int i, len = 0, skip = 0;
@@ -269,10 +274,10 @@ void dialog_clear(void)
269 } 274 }
270 275
271 wmove(stdscr, 1, 1); 276 wmove(stdscr, 1, 1);
272 if (len > COLS - 2) { 277 if (len > columns - 2) {
273 const char *ellipsis = "[...] "; 278 const char *ellipsis = "[...] ";
274 waddstr(stdscr, ellipsis); 279 waddstr(stdscr, ellipsis);
275 skip = len - (COLS - 2 - strlen(ellipsis)); 280 skip = len - (columns - 2 - strlen(ellipsis));
276 } 281 }
277 282
278 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { 283 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
@@ -298,7 +303,7 @@ void dialog_clear(void)
298 skip--; 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 waddch(stdscr, ACS_HLINE); 307 waddch(stdscr, ACS_HLINE);
303 } 308 }
304 wnoutrefresh(stdscr); 309 wnoutrefresh(stdscr);
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c
index abb0c392e01b..676fb2f824a3 100644
--- a/scripts/kconfig/lxdialog/yesno.c
+++ b/scripts/kconfig/lxdialog/yesno.c
@@ -51,8 +51,8 @@ do_resize:
51 return -ERRDISPLAYTOOSMALL; 51 return -ERRDISPLAYTOOSMALL;
52 52
53 /* center dialog box on screen */ 53 /* center dialog box on screen */
54 x = (COLS - width) / 2; 54 x = (getmaxx(stdscr) - width) / 2;
55 y = (LINES - height) / 2; 55 y = (getmaxy(stdscr) - height) / 2;
56 56
57 draw_shadow(stdscr, y, x, height, width); 57 draw_shadow(stdscr, y, x, height, width);
58 58