home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wnattr -- Change attributes on current window
- *
- * Synopsis presult = wnattr(fore,back);
- *
- * BWINDOW *presult Pointer to newly-changed BWINDOW
- * structure, or NIL if failure.
- * int fore New foreground attribute (-1 if
- * foreground to be unchanged).
- * int back New background attribute (-1 if
- * background to be unchanged).
- *
- * Description This function fills the data area of the current window
- * with a given attribute without affecting the characters
- * already displayed there. The cursor is not moved.
- *
- * If fore or back is -1, then foreground or background
- * attributes are left unchanged, respectively.
- *
- * This function does not affect the window's default
- * attributes. Use WNSETOPT for that purpose.
- *
- * An error occurs if no window is current.
- *
- * Returns presult Pointer to newly-changed BWINDOW
- * structure, or NIL if failure.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_BAD_WIN b_pcurwin is invalid.
- * WN_NOT_SHOWN Internal error.
- * WN_BAD_DEV Internal error.
- * WN_ILL_DIM Internal error.
- * WN_NULL_PTR Internal error.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bwindow.h>
-
- BWINDOW *wnattr(fore,back)
- int fore,back;
- {
- int i,area;
- CELL *pdata;
- char oldmask,attr;
-
- if (wnvalwin(b_pcurwin) == NIL)
- {
- wnerror(WN_BAD_WIN);
- return NIL;
- }
-
- if (fore == -1) /* "oldmask" will help us */
- oldmask = 0x0f; /* extract the portions of the */
- else /* existing attributes that we */
- oldmask = 0x00; /* want to keep. */
- if (back == -1)
- oldmask |= 0xf0;
-
- attr = (char) (utnybbyt(back,fore) & ~oldmask);
-
- area = b_pcurwin->img.dim.h * b_pcurwin->img.dim.w;
- pdata = b_pcurwin->img.pdata;
-
- for (i = 0; i < area; i++)
- pdata[i].attr = (pdata[i].attr & oldmask) | attr;
-
- b_pcurwin->internals.dirty = 1;
-
- /* Write whole window unless */
- /* delayed or not shown. */
- return ( b_pcurwin->options.delayed
- || b_pcurwin->where_shown.dev == ABSENT)
- ? b_pcurwin
- : wnupdate(b_pcurwin);
- }