- T((T_CALLED("wbkgdset(%p,%s)"), win, _tracechtype(ch)));
-
- if (win) {
- chtype off = AttrOf(win->_bkgd);
- chtype on = AttrOf(ch);
-
- toggle_attr_off(win->_attrs,off);
- toggle_attr_on (win->_attrs,on);
-
- if (TextOf(ch)==0)
- ch |= BLANK;
- win->_bkgd = ch;
- }
- returnVoid;
+ T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracech_t(ch)));
+
+ if (win) {
+ attr_t off = AttrOf(win->_nc_bkgd);
+ attr_t on = AttrOf(CHDEREF(ch));
+
+ toggle_attr_off(WINDOW_ATTRS(win), off);
+ toggle_attr_on(WINDOW_ATTRS(win), on);
+
+#if NCURSES_EXT_COLORS
+ {
+ int pair;
+
+ if ((pair = GetPair(win->_nc_bkgd)) != 0)
+ SET_WINDOW_PAIR(win, 0);
+ if ((pair = GetPair(CHDEREF(ch))) != 0)
+ SET_WINDOW_PAIR(win, pair);
+ }
+#endif
+
+ if (CharOf(CHDEREF(ch)) == L('\0')) {
+ SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
+ if_EXT_COLORS(SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch))));
+ } else {
+ win->_nc_bkgd = CHDEREF(ch);
+ }
+#if USE_WIDEC_SUPPORT
+ /*
+ * If we're compiled for wide-character support, _bkgrnd is the
+ * preferred location for the background information since it stores
+ * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the
+ * macro getbkgd() will work.
+ */
+ {
+ cchar_t wch;
+ int tmp;
+
+ memset(&wch, 0, sizeof(wch));
+ (void) wgetbkgrnd(win, &wch);
+ tmp = _nc_to_char((wint_t) CharOf(wch));
+
+ win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp)
+ | (AttrOf(wch) & ALL_BUT_COLOR)
+ | (chtype) ColorPair(GET_WINDOW_PAIR(win)));
+ }
+#endif
+ }
+ returnVoid;
+}
+
+NCURSES_EXPORT(void)
+wbkgdset(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ wbkgrndset(win, CHREF(wch));