2 ****************************************************************************
3 * Copyright 2018-2023,2024 Thomas E. Dickey *
4 * Copyright 1998-2015,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: curs_bkgd.3x,v 1.61 2024/04/20 18:54:36 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>curs_bkgd 3x 2024-04-20 ncurses 6.5 Library calls</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">curs_bkgd 3x 2024-04-20 ncurses 6.5 Library calls</H1>
44 <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG> Library calls <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>bkgdset</STRONG>, <STRONG>wbkgdset</STRONG>, <STRONG>bkgd</STRONG>, <STRONG>wbkgd</STRONG>, <STRONG>getbkgd</STRONG> - manipulate background of a
51 <EM>curses</EM> window of characters
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
57 <STRONG>int</STRONG> <STRONG>bkgd(chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
58 <STRONG>int</STRONG> <STRONG>wbkgd(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
60 <STRONG>void</STRONG> <STRONG>bkgdset(chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
61 <STRONG>void</STRONG> <STRONG>wbkgdset(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG>
63 <STRONG>chtype</STRONG> <STRONG>getbkgd(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>);</STRONG>
66 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
67 The <EM>background</EM> of a <EM>curses</EM> window (in the library's non-"wide"
68 configuration) is a <EM>chtype</EM> combining a set of attributes (see
69 <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>) with a character called the <EM>blank</EM> <EM>character.</EM>
71 The blank character is a spacing character that populates a window's
72 character cells when their contents are erased without replacement.
73 The background's attributes are combined with all non-blank characters
74 written to the window, as with the <STRONG><A HREF="curs_addch.3x.html">waddch(3x)</A></STRONG> and <STRONG><A HREF="curs_insch.3x.html">winsch(3x)</A></STRONG> families
77 The blank character and attributes of the background combine with
78 characters written to the window as described below. The background
79 becomes a property of the character and moves with it through any
80 scrolling and insert/delete line/character operations.
82 To the extent possible on a given terminal, the attribute part of the
83 background is displayed as the graphic rendition of the character put
87 </PRE><H3><a name="h3-bkgd_wbkgd">bkgd, wbkgd</a></H3><PRE>
88 <STRONG>bkgd</STRONG> and <STRONG>wbkgd</STRONG> set the background property of <STRONG>stdscr</STRONG> or the specified
89 window and then apply this setting to every character cell in that
92 <STRONG>o</STRONG> The rendition of every character in the window changes to the new
95 <STRONG>o</STRONG> Wherever the former background character appears, it changes to the
96 new background character.
98 <EM>ncurses</EM> updates the rendition of each character cell by comparing the
99 character, non-color attributes, and colors. The library applies to
100 following procedure to each cell in the window, whether or not it is
103 <STRONG>o</STRONG> <EM>ncurses</EM> first compares the cell's character to the previously
104 specified blank character; if they match, <EM>ncurses</EM> writes the new
105 blank character to the cell.
107 <STRONG>o</STRONG> <EM>ncurses</EM> then checks if the cell uses color, that is, its color pair
108 value is nonzero. If not, it simply replaces the attributes and
109 color pair in the cell with those from the new background
112 <STRONG>o</STRONG> If the cell uses color, and its background color matches that of
113 the current window background, <EM>ncurses</EM> removes attributes that may
114 have come from the current background and adds those from the new
115 background. It finishes by setting the cell's background to use
116 the new window background color.
118 <STRONG>o</STRONG> If the cell uses color, and its background color does not match
119 that of the current window background, <EM>ncurses</EM> updates only the
120 non-color attributes, first removing those that may have come from
121 the current background, and then adding attributes from the new
124 <EM>ncurses</EM> treats a background character value of zero (0) as a blank
127 If the terminal does not support color, or if color has not been
128 initialized with <STRONG><A HREF="curs_color.3x.html">start_color(3x)</A></STRONG>, <EM>ncurses</EM> ignores the new background
129 character's color attribute.
132 </PRE><H3><a name="h3-bkgdset_wbkgdset">bkgdset, wbkgdset</a></H3><PRE>
133 <STRONG>bkgdset</STRONG> and <STRONG>wbkgdset</STRONG> manipulate the background of the applicable
134 window, without updating the character cells as <STRONG>bkgd</STRONG> and <STRONG>wbkgd</STRONG> do; only
135 future writes reflect the updated background.
138 </PRE><H3><a name="h3-getbkgd">getbkgd</a></H3><PRE>
139 <STRONG>getbkgd</STRONG> obtains the given window's background character and attribute
143 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
144 Functions returning an <EM>int</EM> return <STRONG>OK</STRONG> on success. <STRONG>bkgd</STRONG> returns <STRONG>ERR</STRONG> if
145 the library has not been initialized. <STRONG>wbkgd</STRONG> and <STRONG>getbkgd</STRONG> return <STRONG>ERR</STRONG> if
146 a <EM>WINDOW</EM> pointer argument is null.
148 <STRONG>bkgdset</STRONG> and <STRONG>wbkgdset</STRONG> do not return a value.
150 <STRONG>getbkgd</STRONG> returns a window's background character and attribute
154 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
155 Unusually, there is no <STRONG>wgetbkgd</STRONG> function; <STRONG>getbkgd</STRONG> behaves as one would
156 expect <STRONG>wgetbkgd</STRONG> to, accepting a <EM>WINDOW</EM> pointer argument.
158 <STRONG>bkgd</STRONG> and <STRONG>bkgdset</STRONG> may be implemented as macros.
160 X/Open Curses mentions that the character part of the background must
161 be a single-byte value. <EM>ncurses</EM>, like SVr4 <EM>curses</EM>, checks to ensure
162 that, and will reuse the old background character if the check fails.
165 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
166 X/Open Curses, Issue 4 describes these functions. It specifies that
167 <STRONG>bkgd</STRONG>, <STRONG>wbkgd</STRONG>, and <STRONG>getbkgd</STRONG> return <STRONG>ERR</STRONG> on failure (in the case of the
168 last, this value is cast to <EM>chtype</EM>), but describes no failure
171 The SVr4.0 manual says that <STRONG>bkgd</STRONG> and <STRONG>wbkgd</STRONG> may return <STRONG>OK</STRONG> "or a non-
172 negative integer if <STRONG>immedok</STRONG> is set", which refers to the return value
173 from <STRONG><A HREF="curs_refresh.3x.html">wrefresh(3x)</A></STRONG>, used to implement the immediate repainting. SVr4
174 <EM>curses</EM>'s <STRONG>wrefresh</STRONG> returns the number of characters written to the
175 screen during the refresh. <EM>ncurses</EM> does not do that.
177 Neither X/Open Curses nor the SVr4 manual pages detail how the
178 rendition of characters on the screen updates when <STRONG>bkgd</STRONG> or <STRONG>wbkgd</STRONG>
179 changes the background character. <EM>ncurses</EM>, like SVr4 <EM>curses</EM>, does not
180 (in its non-"wide" configuration) store the background and window
181 attribute contributions to each character cell separately.
184 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
185 <STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG> describes the corresponding functions in the "wide"
186 configuration of <EM>ncurses</EM>.
188 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>, <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
192 ncurses 6.5 2024-04-20 <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
196 <li><a href="#h2-NAME">NAME</a></li>
197 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
198 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
200 <li><a href="#h3-bkgd_wbkgd">bkgd, wbkgd</a></li>
201 <li><a href="#h3-bkgdset_wbkgdset">bkgdset, wbkgdset</a></li>
202 <li><a href="#h3-getbkgd">getbkgd</a></li>
205 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
206 <li><a href="#h2-NOTES">NOTES</a></li>
207 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
208 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>