Simplified. Could use more.

This commit is contained in:
William McBrine
2006-11-05 07:27:16 +00:00
parent 68f0edd643
commit 8155d549ea

View File

@@ -13,7 +13,7 @@
#include <curspriv.h>
RCSID("$Id: bkgd.c,v 1.31 2006/11/05 03:57:26 wmcbrine Exp $");
RCSID("$Id: bkgd.c,v 1.32 2006/11/05 07:27:16 wmcbrine Exp $");
/*man-start**************************************************************
@@ -98,17 +98,19 @@ int wbkgd(WINDOW *win, chtype ch)
if (win->_bkgd == ch)
return OK;
oldcolr = (win->_bkgd & A_COLOR);
if (oldcolr != 0)
oldattr = ((win->_bkgd & A_ATTRIBUTES) ^ oldcolr);
oldch = (win->_bkgd & A_CHARTEXT);
oldcolr = win->_bkgd & A_COLOR;
if (oldcolr)
oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;
oldch = win->_bkgd & A_CHARTEXT;
wbkgdset(win, ch);
newcolr = (win->_bkgd & A_COLOR);
if (newcolr != 0)
newattr = ((win->_bkgd & A_ATTRIBUTES) ^ newcolr);
newch = (win->_bkgd & A_CHARTEXT);
newcolr = win->_bkgd & A_COLOR;
if (newcolr)
newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;
newch = win->_bkgd & A_CHARTEXT;
/* what follows is what seems to occur in the System V
implementation of this routine */
@@ -123,10 +125,8 @@ int wbkgd(WINDOW *win, chtype ch)
/* determine the colors and attributes of the
character read from the window */
colr = (ch & A_COLOR);
attr = (ch & A_ATTRIBUTES);
if (colr != 0)
attr = (attr ^ colr);
colr = ch & A_COLOR;
attr = ch & (A_ATTRIBUTES ^ A_COLOR);
/* if the color is the same as the old
background color, then make it the new
@@ -140,17 +140,17 @@ int wbkgd(WINDOW *win, chtype ch)
background, then combine the remaining ones
with the new background */
attr = (attr ^ oldattr);
attr ^= oldattr;
attr |= newattr;
/* change character if it is there because it
was the old background character */
ch = (ch & A_CHARTEXT);
ch &= A_CHARTEXT;
if (ch == oldch)
ch = newch;
ch = ((ch | attr) | colr);
ch |= (attr | colr);
*winptr = ch;
@@ -171,27 +171,15 @@ int bkgd(chtype ch)
void wbkgdset(WINDOW *win, chtype ch)
{
chtype bkgdattr;
PDC_LOG(("wbkgdset() - called\n"));
if (!win)
return;
if (win)
{
if (!(ch & A_CHARTEXT))
ch |= ' ';
if (win->_bkgd == ch)
return;
if ((ch & A_ATTRIBUTES) == 0)
bkgdattr = A_NORMAL;
else
bkgdattr = (ch & A_ATTRIBUTES);
ch = (ch & A_CHARTEXT);
if (ch == 0)
ch = ' ';
win->_bkgd = (ch | bkgdattr);
win->_bkgd = ch;
}
}
void bkgdset(chtype ch)