From a601ca9cda3fba0dc0ae27be73e061283f4787f4 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Thu, 8 Dec 2005 16:33:39 +0000 Subject: [PATCH] win->_maxx etc. is not standard, and is defined differently in PDCurses vs. ncurses (off by one), so use getmaxyx() instead. Sadly, getmaxy() isn't standard either, which means undoing a warning cleanup. --- demos/newdemo.c | 11 ++++------- demos/ptest.c | 9 +++++---- demos/testcurs.c | 6 +++--- demos/tui.c | 23 ++++++++++++++++------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/demos/newdemo.c b/demos/newdemo.c index 3ef04256..66efaa03 100644 --- a/demos/newdemo.c +++ b/demos/newdemo.c @@ -39,7 +39,7 @@ #endif #ifdef PDCDEBUG -char *rcsid_newdemo = "$Id: newdemo.c,v 1.12 2005/12/07 01:37:43 wmcbrine Exp $"; +char *rcsid_newdemo = "$Id: newdemo.c,v 1.13 2005/12/08 16:33:39 wmcbrine Exp $"; #endif #if defined(HAVE_PROTO) && !defined(__STDC__) @@ -127,10 +127,8 @@ WINDOW *win; WINDOW *swin1, *swin2, *swin3; wattrset(win, 0); - w = win->_maxx; - h = win->_maxy; - bx = win->_begx; - by = win->_begy; + getmaxyx(win, h, w); + getbegyx(win, by, bx); sw = w / 3; sh = h / 3; if ((swin1 = derwin(win, sh, sw, 3, 5)) == NULL) @@ -188,8 +186,7 @@ WINDOW *win; wbkgd( win, COLOR_PAIR(1) ); wrefresh(win); - w = win->_maxx; - h = win->_maxy; + getmaxyx(win, h, w); x1 = 2 + rand() % (w - 4); y1 = 2 + rand() % (h - 4); x2 = 2 + rand() % (w - 4); diff --git a/demos/ptest.c b/demos/ptest.c index b5422f8b..1cfcf65d 100644 --- a/demos/ptest.c +++ b/demos/ptest.c @@ -26,7 +26,7 @@ #endif #ifdef PDCDEBUG -char *rcsid_ptest = "$Id: ptest.c,v 1.8 2005/12/07 01:37:43 wmcbrine Exp $"; +char *rcsid_ptest = "$Id: ptest.c,v 1.9 2005/12/08 16:33:39 wmcbrine Exp $"; #endif #include @@ -171,14 +171,15 @@ PANEL *pan; { WINDOW *win = pan->win; char num = *((char *)pan->user + 1); -int y,x; +int y,x,maxy,maxx; box(win, 0, 0); wmove(win,1,1); wprintw(win,"-pan%c-",num); - for(y = 2; y < getmaxy(win) - 1; y++) + getmaxyx(win,maxy,maxx); + for(y = 2; y < maxy - 1; y++) { - for(x = 1; x < getmaxx(win) - 1; x++) + for(x = 1; x < maxx - 1; x++) { wmove(win,y,x); waddch(win,num); diff --git a/demos/testcurs.c b/demos/testcurs.c index e4fdca68..96694707 100644 --- a/demos/testcurs.c +++ b/demos/testcurs.c @@ -34,7 +34,7 @@ #ifdef PDCDEBUG # define CURSES_LIBRARY /* needed for the prototype of PDC_debug */ -char *rcsid_testcurs = "$Id: testcurs.c,v 1.24 2005/12/08 08:12:31 wmcbrine Exp $"; +char *rcsid_testcurs = "$Id: testcurs.c,v 1.25 2005/12/08 16:33:39 wmcbrine Exp $"; #endif #include @@ -269,7 +269,7 @@ WINDOW *win; #endif { int i; - int OldY; + int OldY, OldX; /* disable typeahead checking */ @@ -287,7 +287,7 @@ WINDOW *win; wrefresh (win); }; - OldY = getmaxy (win); + getmaxyx (win, OldY, OldX); mvwprintw (win, 6, 1, "The top of the window will scroll"); wmove (win, 1, 1); wsetscrreg (win, 0, 4); diff --git a/demos/tui.c b/demos/tui.c index 3847cf1c..f13f770c 100644 --- a/demos/tui.c +++ b/demos/tui.c @@ -45,7 +45,7 @@ int waitforkey Args((void)); void rmerror Args((void)); #ifdef PDCDEBUG -char *rcsid_tui = "$Id: tui.c,v 1.8 2005/12/07 01:37:43 wmcbrine Exp $"; +char *rcsid_tui = "$Id: tui.c,v 1.9 2005/12/08 16:33:39 wmcbrine Exp $"; #endif #if defined(__unix) && !defined(__DJGPP__) @@ -185,6 +185,7 @@ chtype color; int hasbox; #endif { + int maxy, maxx; chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */ setcolor (win, color); @@ -192,12 +193,14 @@ int hasbox; if (has_colors()) wbkgd (win, COLOR_PAIR(color & A_CHARTEXT) | (attr & ~A_REVERSE)); else - wbkgd (win, color); -#else - wbkgd (win, color); #endif + wbkgd (win, color); + werase (win); - if (hasbox && win->_maxy > 2) box (win, 0, 0); + + getmaxyx (win, maxy, maxx); + + if (hasbox && (maxy > 2)) box (win, 0, 0); touchwin (win); wrefresh (win); } @@ -439,7 +442,10 @@ void clsbody Args((void)) int bodylen Args((void)) { - return wbody->_maxy; + int maxy, maxx; + + getmaxyx (wbody, maxy, maxx); + return maxy; } WINDOW *bodywin Args((void)) @@ -691,7 +697,10 @@ int x; char *buf; #endif { - werase (win); mvwprintw (win, 0, 0, "%s", padstr (buf, win->_maxx)); + int maxy, maxx; + + getmaxyx (win, maxy, maxx); + werase (win); mvwprintw (win, 0, 0, "%s", padstr (buf, maxx)); wmove (win, 0, x); wrefresh (win); }