From 1d2712bcac37d15353eaa81d4496155d78332abd Mon Sep 17 00:00:00 2001 From: William McBrine Date: Thu, 21 Jun 2007 05:38:07 +0000 Subject: [PATCH] Refashioned wchgat() after whline(). However, as I read the X/Open spec for wchgat(), it's actually supposed to allow changing multiple lines... which neither ncurses nor Solaris do, either. To Do? --- pdcurses/attr.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/pdcurses/attr.c b/pdcurses/attr.c index 11ff05c5..0696eb57 100644 --- a/pdcurses/attr.c +++ b/pdcurses/attr.c @@ -13,7 +13,7 @@ #include -RCSID("$Id: attr.c,v 1.37 2007/06/14 13:50:26 wmcbrine Exp $") +RCSID("$Id: attr.c,v 1.38 2007/06/21 05:38:07 wmcbrine Exp $") /*man-start************************************************************** @@ -309,8 +309,8 @@ int attr_set(attr_t attrs, short color_pair, void *opts) int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts) { - chtype newattr, tmp; - int basey, basex, imax, ic; + chtype *dest, newattr; + int startpos, endpos; PDC_LOG(("wchgat() - called\n")); @@ -319,30 +319,20 @@ int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts) newattr = (attr & A_ATTRIBUTES) | COLOR_PAIR(color); - basey = win->_cury; - basex = win->_curx; - imax = win->_maxx - win->_curx; + startpos = win->_curx; + endpos = ((n < 0) ? win->_maxx : min(startpos + n, win->_maxx)) - 1; + dest = win->_y[win->_cury]; - if (n > 0) - imax = ((imax < n) ? imax : n); + for (n = startpos; n <= endpos; n++) + dest[n] = (dest[n] & A_CHARTEXT) | newattr; - for (ic = 0; ic < imax; ic++) - { - tmp = (win->_y[basey][basex + ic] & A_CHARTEXT) | newattr; - win->_y[basey][basex + ic] = tmp; - } + n = win->_cury; - if (win->_firstch[basey] == _NO_CHANGE) - { - win->_firstch[basey] = basex; - win->_lastch[basey] = basex + imax - 1; - } - else - { - win->_firstch[basey] = min(win->_firstch[basey], basex); - win->_lastch[basey] = max(win->_lastch[basey], - basex + imax - 1); - } + if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE) + win->_firstch[n] = startpos; + + if (endpos > win->_lastch[n]) + win->_lastch[n] = endpos; PDC_sync(win);