]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_bkgd.c
ncurses 4.1
[ncurses.git] / ncurses / lib_bkgd.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22 #include <curses.priv.h>
23
24 MODULE_ID("$Id: lib_bkgd.c,v 1.7 1997/04/12 17:44:37 tom Exp $")
25
26 int wbkgd(WINDOW *win, const chtype ch)
27 {
28 int x, y;
29 chtype old_bkgd = getbkgd(win);
30 chtype new_bkgd = ch;
31
32         T((T_CALLED("wbkgd(%p,%s)"), win, _tracechtype(new_bkgd)));
33
34         if (TextOf(new_bkgd) == 0)
35                 new_bkgd |= BLANK;
36         wbkgdset(win, new_bkgd);
37         wattrset(win, AttrOf(new_bkgd));
38
39         for (y = 0; y <= win->_maxy; y++) {
40                 for (x = 0; x <= win->_maxx; x++) {
41                         if (win->_line[y].text[x] == old_bkgd)
42                                 win->_line[y].text[x] = new_bkgd;
43                         else
44                                 win->_line[y].text[x] =
45                                         TextOf(win->_line[y].text[x])
46                                         | AttrOf(new_bkgd);
47                 }
48         }
49         touchwin(win);
50         _nc_synchook(win);
51         returnCode(OK);
52 }