]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_bkgd.c
ncurses 5.5
[ncurses.git] / ncurses / base / lib_bkgd.c
index ca189a656ebd8de87ae7600be85b91a4c64316ae..48111a7816e593c83a6589aad1a58d42aa7b9ada 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2001-2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                         1997                    *
+ *     and: Sven Verdoolaege                        2000                    *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_bkgd.c,v 1.29 2002/09/22 20:30:32 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.32 2005/04/16 18:03:48 tom Exp $")
 
 /*
  * Set the window's background information.
@@ -54,10 +57,23 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch)
        toggle_attr_off(win->_attrs, off);
        toggle_attr_on(win->_attrs, on);
 
-       if (CharOf(CHDEREF(ch)) == L('\0'))
+#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)));
-       else
+           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
@@ -70,9 +86,11 @@ wbkgrndset(WINDOW *win, const ARG_CH_T ch)
            int tmp;
 
            wgetbkgrnd(win, &wch);
-           tmp = wctob(CharOf(wch));
+           tmp = _nc_to_char((wint_t) CharOf(wch));
 
-           win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch);
+           win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp)
+                         | (AttrOf(wch) & ALL_BUT_COLOR)
+                         | COLOR_PAIR(GET_WINDOW_PAIR(win)));
        }
 #endif
     }