History

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)

Dirk Gouders committed 13 years ago

Commit 4f2de3e1 parent 13763916 files · +19 −14Browse files

Unified · Split

6 files
  1. scripts/kconfig/lxdialog/checklist.c +2 −2
  2. scripts/kconfig/lxdialog/inputbox.c +2 −2
  3. scripts/kconfig/lxdialog/menubox.c +2 −2
  4. scripts/kconfig/lxdialog/textbox.c +2 −2
  5. scripts/kconfig/lxdialog/util.c +9 −4
  6. scripts/kconfig/lxdialog/yesno.c +2 −2
scripts/kconfig/lxdialog/checklist.c+2−2
@@ -140,8 +140,8 @@ do_resize: · 139 unmodified lines
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
scripts/kconfig/lxdialog/inputbox.c+2−2
@@ -62,8 +62,8 @@ do_resize: · 61 unmodified lines
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
scripts/kconfig/lxdialog/menubox.c+2−2
@@ -203,8 +203,8 @@ do_resize: · 202 unmodified lines
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
scripts/kconfig/lxdialog/textbox.c+2−2
@@ -98,8 +98,8 @@ do_resize: · 97 unmodified lines
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
scripts/kconfig/lxdialog/util.c+9−4
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr) · 253 unmodified lines
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) · 8 unmodified lines
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) · 19 unmodified lines
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);
scripts/kconfig/lxdialog/yesno.c+2−2
@@ -51,8 +51,8 @@ do_resize: · 50 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t