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
140140 max_choice = MIN(list_height, item_count());
141141
142142 /* 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;
145145
146146 draw_shadow(stdscr, y, x, height, width);
147147
scripts/kconfig/lxdialog/inputbox.c+2−2
@@ -62,8 +62,8 @@ do_resize: · 61 unmodified lines
6262 return -ERRDISPLAYTOOSMALL;
6363
6464 /* 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;
6767
6868 draw_shadow(stdscr, y, x, height, width);
6969
scripts/kconfig/lxdialog/menubox.c+2−2
@@ -203,8 +203,8 @@ do_resize: · 202 unmodified lines
203203 max_choice = MIN(menu_height, item_count());
204204
205205 /* 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;
208208
209209 draw_shadow(stdscr, y, x, height, width);
210210
scripts/kconfig/lxdialog/textbox.c+2−2
@@ -98,8 +98,8 @@ do_resize: · 97 unmodified lines
9898 width = 0;
9999
100100 /* 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;
103103
104104 draw_shadow(stdscr, y, x, height, width);
105105
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
254254
255255 void dialog_clear(void)
256256 {
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);
258263 /* Display background title if it exists ... - SLH */
259264 if (dlg.backtitle != NULL) {
260265 int i, len = 0, skip = 0;
@@ -269,10 +274,10 @@ void dialog_clear(void) · 8 unmodified lines
269274 }
270275
271276 wmove(stdscr, 1, 1);
272− if (len > COLS - 2) {
277+ if (len > columns - 2) {
273278 const char *ellipsis = "[...] ";
274279 waddstr(stdscr, ellipsis);
275− skip = len - (COLS - 2 - strlen(ellipsis));
280+ skip = len - (columns - 2 - strlen(ellipsis));
276281 }
277282
278283 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
@@ -298,7 +303,7 @@ void dialog_clear(void) · 19 unmodified lines
298303 skip--;
299304 }
300305
301− for (i = len + 1; i < COLS - 1; i++)
306+ for (i = len + 1; i < columns - 1; i++)
302307 waddch(stdscr, ACS_HLINE);
303308 }
304309 wnoutrefresh(stdscr);
scripts/kconfig/lxdialog/yesno.c+2−2
@@ -51,8 +51,8 @@ do_resize: · 50 unmodified lines
5151 return -ERRDISPLAYTOOSMALL;
5252
5353 /* 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;
5656
5757 draw_shadow(stdscr, y, x, height, width);
5858

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