]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_bkgd.3x
ncurses 6.4 - patch 20231202
[ncurses.git] / man / curs_bkgd.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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.51 2023/12/02 21:02:44 tom Exp $
31 .TH curs_bkgd 3X 2023-12-02 "ncurses 6.4" "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 \fBvoid bkgdset(chtype \fIch\fP);
59 \fBvoid wbkgdset(WINDOW *\fIwin\fP, chtype \fIch\fP);
60 .PP
61 \fBint bkgd(chtype \fIch\fP);
62 \fBint wbkgd(WINDOW *\fIwin\fP, chtype \fIch\fP);
63 .PP
64 \fBchtype getbkgd(WINDOW *\fIwin\fP);
65 .fi
66 .SH DESCRIPTION
67 .SS bkgdset
68 The \fBbkgdset\fP and \fBwbkgdset\fP routines
69 set the \fIbackground\fP for a window.
70 A window's background is a \fBchtype\fP consisting of
71 any combination of attributes (i.e., rendition) and a character:
72 .bP
73 The attribute part of the background is combined (OR'ed) with all non-blank
74 characters that are written into the window with \fBwaddch\fP.
75 .bP
76 Both the character and attribute parts of the background are combined with
77 blank characters that are written into the window.
78 .PP
79 The background becomes a property of each
80 character and moves with the character through any scrolling and
81 insert/delete line/character operations.
82 .PP
83 To the extent possible on a particular terminal,
84 the attribute part of the background is displayed
85 as the graphic rendition of the character put on the screen.
86 .SS bkgd
87 The \fBbkgd\fP and \fBwbkgd\fP functions
88 set the background property of the current or specified window
89 and then apply this setting to every character position in that window.
90 According to X/Open Curses, it should do this:
91 .bP
92 The rendition of every character on the screen is changed to
93 the new background rendition.
94 .bP
95 Wherever the former background character
96 appears, it is changed to the new background character.
97 .PP
98 Neither X/Open Curses nor the SVr4 manual pages give details about
99 the way the rendition of characters on the screen is updated when
100 \fBbkgd\fP or \fBwbkgd\fP is used to change the background character.
101 .PP
102 \fI\%ncurses\fP,
103 like SVr4 \fIcurses\fP,
104 does not store the background and window attribute contributions to each
105 cell separately.
106 It updates the rendition by comparing the character,
107 non-color attributes and colors contained in the background.
108 For each cell in the window, whether or not it is blank:
109 .bP
110 The library first compares the \fIcharacter\fP,
111 and if it matches the current character part of the background,
112 it replaces that with the new background character.
113 .IP
114 When \fBbkgdset\fP is used to set the background character,
115 that does not update each cell in the window.
116 A subsequent call to \fBbkgd\fP will only modify the \fIcharacter\fP in
117 cells which match the current background character.
118 .bP
119 The library then checks if the cell uses color,
120 i.e., its color pair value is nonzero.
121 If not, it simply replaces the attributes and color pair in the
122 cell with those from the new background character.
123 .bP
124 If the cell uses color,
125 and that matches the color in the current background,
126 the library removes attributes
127 which may have come from the current background
128 and adds attributes from the new background.
129 It finishes by setting the cell
130 to use the color from the new background.
131 .bP
132 If the cell uses color,
133 and that does not match the color in the current background,
134 the library updates only the non-color attributes,
135 first removing those which may have come from the current background,
136 and then adding attributes from the new background.
137 .PP
138 If the background's character value is zero (0), a space is assumed.
139 .PP
140 If the terminal does not support color,
141 or if color has not been started with \fBstart_color\fP,
142 the new background character's color attribute will be ignored.
143 .SS getbkgd
144 The \fBgetbkgd\fP function returns the given window's current background
145 character/attribute pair.
146 .SH RETURN VALUE
147 Functions returning an \fIint\fP return \fBOK\fP on success.
148 \fB\%bkgd\fP returns \fBERR\fP if the library has not been initialized.
149 \fB\%wbkgd\fP and \fB\%getbkgd\fP return \fBERR\fP if the \fI\%WINDOW\fP
150 pointer argument is null.
151 .PP
152 In contrast,
153 the SVr4.0 manual says \fB\%bkgd\fP and \fB\%wbkgd\fP may return
154 \fBOK\fP
155 \*(``or a non-negative integer if \fB\%immedok\fP is set\*('',
156 which refers to the return value from \fB\%wrefresh\fP
157 (used to implement the immediate repainting).
158 SVr4 \fIcurses\fP \fB\%wrefresh\fP returns the number of characters
159 written to the screen during the refresh.
160 \fI\%ncurses\fP does not do that.
161 .SH NOTES
162 Unusually,
163 there is no \fB\%wgetbkgd\fP function;
164 \fB\%getbkgd\fP behaves as one would expect \fB\%wgetbkgd\fP to,
165 accepting a \fI\%WINDOW\fP pointer argument.
166 .PP
167 Note that \fBbkgdset\fP and \fBbkgd\fP may be macros.
168 .PP
169 X/Open Curses mentions that the character part of the background must
170 be a single-byte value.
171 \fI\%ncurses\fP,
172 like SVr4 \fIcurses\fP,
173 checks to ensure that,
174 and will reuse the old background character if the check fails.
175 .SH PORTABILITY
176 These functions are described in the XSI Curses standard, Issue 4.
177 It specifies that \fBbkgd\fP and \fBwbkgd\fP return \fBERR\fP on
178 failure,
179 but gives no failure conditions.
180 .SH SEE ALSO
181 \fB\%curses\fP(3X),
182 \fB\%curs_addch\fP(3X),
183 \fB\%curs_attr\fP(3X),
184 \fB\%curs_outopts\fP(3X)