blob: 47d2e13b829fb69e130c89ce4c578f0747acca86 [file] [log] [blame]
micky3879b9f5e72025-07-08 18:04:53 -04001<!--
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05302 ****************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04003 * Copyright 2018-2023,2024 Thomas E. Dickey *
4 * Copyright 1998-2015,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05305 * *
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: *
13 * *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
16 * *
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. *
24 * *
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 *
28 * authorization. *
29 ****************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -040030 * @Id: curs_bkgd.3x,v 1.61 2024/04/20 18:54:36 tom Exp @
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053031-->
Steve Kondikae271bc2015-11-15 02:50:53 +010032<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053033<HTML>
34<HEAD>
Steve Kondikae271bc2015-11-15 02:50:53 +010035<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
micky3879b9f5e72025-07-08 18:04:53 -040036<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">
39
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053040</HEAD>
41<BODY>
micky3879b9f5e72025-07-08 18:04:53 -040042<H1 class="no-header">curs_bkgd 3x 2024-04-20 ncurses 6.5 Library calls</H1>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053043<PRE>
micky3879b9f5e72025-07-08 18:04:53 -040044<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>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053045
46
47
48
micky3879b9f5e72025-07-08 18:04:53 -040049</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
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053052
53
micky3879b9f5e72025-07-08 18:04:53 -040054</PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053055 <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
56
Steve Kondikae271bc2015-11-15 02:50:53 +010057 <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>
micky3879b9f5e72025-07-08 18:04:53 -040059
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>
62
Steve Kondikae271bc2015-11-15 02:50:53 +010063 <STRONG>chtype</STRONG> <STRONG>getbkgd(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>);</STRONG>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053064
65
micky3879b9f5e72025-07-08 18:04:53 -040066</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>
Steve Kondikae271bc2015-11-15 02:50:53 +010070
micky3879b9f5e72025-07-08 18:04:53 -040071 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
75 of functions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053076
micky3879b9f5e72025-07-08 18:04:53 -040077 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.
81
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
84 on the screen.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053085
Steve Kondikae271bc2015-11-15 02:50:53 +010086
micky3879b9f5e72025-07-08 18:04:53 -040087</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
90 window.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053091
micky3879b9f5e72025-07-08 18:04:53 -040092 <STRONG>o</STRONG> The rendition of every character in the window changes to the new
93 background rendition.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053094
micky3879b9f5e72025-07-08 18:04:53 -040095 <STRONG>o</STRONG> Wherever the former background character appears, it changes to the
96 new background character.
97
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
101 blank.
102
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.
106
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
110 character.
111
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.
117
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
122 background.
123
124 <EM>ncurses</EM> treats a background character value of zero (0) as a blank
125 character.
126
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.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530130
Steve Kondikae271bc2015-11-15 02:50:53 +0100131
micky3879b9f5e72025-07-08 18:04:53 -0400132</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.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530136
137
micky3879b9f5e72025-07-08 18:04:53 -0400138</PRE><H3><a name="h3-getbkgd">getbkgd</a></H3><PRE>
139 <STRONG>getbkgd</STRONG> obtains the given window's background character and attribute
140 combination.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530141
142
micky3879b9f5e72025-07-08 18:04:53 -0400143</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.
147
148 <STRONG>bkgdset</STRONG> and <STRONG>wbkgdset</STRONG> do not return a value.
149
150 <STRONG>getbkgd</STRONG> returns a window's background character and attribute
151 combination.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530152
153
micky3879b9f5e72025-07-08 18:04:53 -0400154</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.
157
158 <STRONG>bkgd</STRONG> and <STRONG>bkgdset</STRONG> may be implemented as macros.
159
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.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530163
164
micky3879b9f5e72025-07-08 18:04:53 -0400165</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
169 conditions.
170
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.
176
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.
182
183
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>.
187
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>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530189
190
191
micky3879b9f5e72025-07-08 18:04:53 -0400192ncurses 6.5 2024-04-20 <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530193</PRE>
Steve Kondikae271bc2015-11-15 02:50:53 +0100194<div class="nav">
195<ul>
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>
199<ul>
micky3879b9f5e72025-07-08 18:04:53 -0400200<li><a href="#h3-bkgd_wbkgd">bkgd, wbkgd</a></li>
201<li><a href="#h3-bkgdset_wbkgdset">bkgdset, wbkgdset</a></li>
Steve Kondikae271bc2015-11-15 02:50:53 +0100202<li><a href="#h3-getbkgd">getbkgd</a></li>
203</ul>
204</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>
209</ul>
210</div>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530211</BODY>
212</HTML>