Debian Codegraph @

upstream/debian-unstable/man3/bkgd.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
4 .\" *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
12 .\" *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
15 .\" *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
27 .\" authorization. *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_bkgd.3x,v 1.76 2025/08/23 22:39:20 tom Exp $
31 .TH bkgd 3NCURSES 2025-08-23 "ncurses 6.6" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el .ds `` ""
39 .ie t .ds '' ''
40 .el .ds '' ""
41 .\}
42 .
43 .de bP
44 .ie n .IP \(bu 4
45 .el .IP \(bu 2
46 ..
47 .SH NAME
48 \fB\%bkgdset\fP,
49 \fB\%wbkgdset\fP,
50 \fB\%bkgd\fP,
51 \fB\%wbkgd\fP,
52 \fB\%getbkgd\fP \-
53 manipulate background of a \fIcurses\fR window of characters
54 .SH SYNOPSIS
55 .nf
56 \fB#include <curses.h>
57 .PP
58 \fBint bkgd(chtype \fIch\fP);
59 \fBint wbkgd(WINDOW *\fIwin\fP, chtype \fIch\fP);
60 .PP
61 \fBvoid bkgdset(chtype \fIch\fP);
62 \fBvoid wbkgdset(WINDOW *\fIwin\fP, chtype \fIch\fP);
63 .PP
64 \fBchtype getbkgd(WINDOW *\fIwin\fP);
65 .fi
66 .SH DESCRIPTION
67 Every
68 .I curses
69 window has a
70 .I "background character"
71 property:
72 in the library's non-wide-character configuration,
73 it is a
74 .I curses
75 character
76 .RI \%( chtype )
77 that combines a set of attributes
78 (and,
79 if colors are enabled,
80 a color pair identifier)
81 with a character code.
82 When erasing
83 (parts of)
84 a window,
85 .I curses
86 replaces the erased cells with the background character.
87 .PP
88 .I curses
89 also uses the background character when writing characters to a
90 populated window.
91 .bP
92 The attribute part of the background character combines with all
93 non-blank character cells in the window,
94 as populated by the \fB\%waddch\fP(3NCURSES) and \fB\%winsch\fP(3NCURSES)
95 families of functions
96 (and those that call them).
97 .bP
98 Both the character code and attributes of the background character
99 combine with blank character cells in the window.
100 .PP
101 The background character's set of attributes becomes a property
102 of the character cell
103 and move with it through any scrolling
104 and insert/delete line/character operations.
105 To the extent possible on the terminal type,
106 .I curses
107 displays the attributes of the background character
108 as the graphic rendition of a character cell on the display.
109 .SS "bkgd, wbkgd"
110 .B \%bkgd
111 and
112 .B \%wbkgd
113 set the background property of
114 .B \%stdscr
115 or the specified window and then apply this setting to
116 every character cell in that window.
117 .bP
118 The rendition of every character in the window changes to the new
119 background rendition.
120 .bP
121 Wherever the former background character appears,
122 it changes to the new background character.
123 .PP
124 .I \%ncurses
125 updates the rendition of each character cell by comparing the character,
126 non-color attributes,
127 and color pair selection.
128 The library applies the following procedure to each cell in the window,
129 whether or not it is blank.
130 .bP
131 .I \%ncurses
132 first compares the cell's character to the previously specified
133 background character;
134 if they match,
135 .I \%ncurses
136 writes the new background character to the cell.
137 .bP
138 .I \%ncurses
139 then checks whether the cell uses color;
140 that is,
141 its color pair value is nonzero.
142 If not,
143 it simply replaces the attributes and color pair in the cell with those
144 from the new background character.
145 .bP
146 If the cell uses color,
147 and its background color matches that of the current window background,
148 .I \%ncurses
149 removes attributes that may have come from the current background and
150 adds those from the new background.
151 It finishes by setting the cell's background to use the new window
152 background color.
153 .bP
154 If the cell uses color,
155 and its background color does not match that of the current window
156 background,
157 .I \%ncurses
158 updates only the non-color attributes,
159 first removing those that may have come from the current background,
160 and then adding attributes from the new background.
161 .PP
162 If the new background's character is non-spacing
163 (for example,
164 if it is a control character),
165 .I \%ncurses
166 retains the existing background character,
167 except for one special case:
168 .I \%ncurses
169 treats a background character code of zero (0) as a space.
170 .PP
171 If the terminal does not support color,
172 or if color has not been initialized with \fB\%start_color\fP(3NCURSES),
173 .I \%ncurses
174 ignores the new background character's color pair selection.
175 .SS "bkgdset, wbkgdset"
176 .B \%bkgdset
177 and
178 .B \%wbkgdset
179 manipulate the background of the applicable window,
180 without updating the character cells as
181 .B \%bkgd
182 and
183 .B \%wbkgd
184 do;
185 only future writes reflect the updated background.
186 .SS getbkgd
187 .B \%getbkgd
188 returns the given window's background character,
189 attributes,
190 and color pair as a
191 .IR \%chtype "."
192 .SH RETURN VALUE
193 .B \%bkgdset
194 and
195 .B \%wbkgdset
196 do not return a value.
197 .PP
198 Functions returning an
199 .I int
200 return
201 .B ERR
202 upon failure and
203 .B OK
204 upon success.
205 In
206 .IR \%ncurses ","
207 failure occurs if
208 .bP
209 the
210 .I curses
211 screen has not been initialized,
212 or
213 .bP
214 .I win
215 is
216 .IR NULL "."
217 .PP
218 .BR \%getbkgd 's
219 return value is as described above.
220 .SH NOTES
221 Unusually,
222 there is no
223 .B \%wgetbkgd
224 function;
225 .B \%getbkgd
226 behaves as one would expect
227 .B \%wgetbkgd
228 to,
229 accepting a
230 .I \%WINDOW
231 pointer argument.
232 .PP
233 .B \%bkgd
234 and
235 .B \%bkgdset
236 may be implemented as macros.
237 .PP
238 X/Open Curses mentions that the character part of the background must
239 be a single-byte value.
240 .IR \%ncurses ","
241 like SVr4
242 .IR curses ","
243 checks to ensure that it is,
244 and retains the existing background character if the check fails.
245 .SH PORTABILITY
246 X/Open Curses Issue\ 4 describes these functions.
247 It indicates that
248 .IR bkgd ","
249 .IR wbkgd ","
250 and
251 .I getbkgd
252 return
253 .I ERR
254 on failure
255 (in the case of the last,
256 this value is cast to
257 .IR \%chtype ),
258 but specifies no error conditions for them.
259 .PP
260 SVr4 documentation
261 .\" SVID 4, vol. 3, p. 482
262 says that
263 .I \%bkgd
264 and
265 .I \%wbkgd
266 return
267 .I OK
268 \*(``or a non-negative integer if
269 .I \%immedok() \" Courier roman in source
270 is set\*('',
271 referring to the return value from
272 .IR \%wrefresh ","
273 which in SVr4 returns a count of characters
274 written to the window if its
275 .I \%immedok
276 property is set;
277 .\" ...though its wrefresh() man page says nothing about immedok()...
278 in
279 .IR \%ncurses ","
280 it does not.
281 .PP
282 Neither X/Open Curses nor the SVr4 manual pages detail how the rendition
283 of characters in the window updates when
284 .I \%bkgd
285 or
286 .I \%wbkgd
287 changes the background character.
288 .IR \%ncurses ","
289 like SVr4
290 .IR curses ","
291 does not
292 (in its non-wide-character configuration)
293 store the background and window attribute contributions to each
294 character cell separately.
295 .SH HISTORY
296 SVr3.1 (1987)
297 introduced these functions.
298 .SH SEE ALSO
299 \fB\%bkgrnd\fP(3NCURSES) describes the corresponding functions in the
300 wide configuration of
301 .IR \%ncurses "."
302 .PP
303 \fB\%ncurses\fP(3NCURSES),
304 \fB\%addch\fP(3NCURSES),
305 \fB\%attr\fP(3NCURSES)