]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_bkgd.3x
ncurses 6.4 - patch 20230917
[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.44 2023/09/16 23:34:43 tom Exp $
31 .TH curs_bkgd 3X 2023-09-16 "ncurses 6.4" "Library calls"
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .SH NAME
37 \fB\%bkgdset\fP,
38 \fB\%wbkgdset\fP,
39 \fB\%bkgd\fP,
40 \fB\%wbkgd\fP,
41 \fB\%getbkgd\fP \-
42 manipulate background of a \fIcurses\fR window of characters
43 .SH SYNOPSIS
44 \fB#include <curses.h>\fP
45 .PP
46 \fBvoid bkgdset(chtype \fIch\fB);\fR
47 .br
48 \fBvoid wbkgdset(WINDOW *\fIwin, chtype \fIch\fB);\fR
49 .sp
50 \fBint bkgd(chtype \fIch\fB);\fR
51 .br
52 \fBint wbkgd(WINDOW *\fIwin\fB, chtype \fIch\fB);\fR
53 .sp
54 \fBchtype getbkgd(WINDOW *\fIwin\fB);\fR
55 .br
56 .SH DESCRIPTION
57 .SS bkgdset
58 The \fBbkgdset\fP and \fBwbkgdset\fP routines
59 set the \fIbackground\fP for a window.
60 A window's background is a \fBchtype\fP consisting of
61 any combination of attributes (i.e., rendition) and a character:
62 .bP
63 The attribute part of the background is combined (OR'ed) with all non-blank
64 characters that are written into the window with \fBwaddch\fP.
65 .bP
66 Both the character and attribute parts of the background are combined with
67 blank characters that are written into the window.
68 .PP
69 The background becomes a property of each
70 character and moves with the character through any scrolling and
71 insert/delete line/character operations.
72 .PP
73 To the extent possible on a particular terminal,
74 the attribute part of the background is displayed
75 as the graphic rendition of the character put on the screen.
76 .SS bkgd
77 The \fBbkgd\fP and \fBwbkgd\fP functions
78 set the background property of the current or specified window
79 and then apply this setting to every character position in that window.
80 According to X/Open Curses, it should do this:
81 .bP
82 The rendition of every character on the screen is changed to
83 the new background rendition.
84 .bP
85 Wherever the former background character
86 appears, it is changed to the new background character.
87 .PP
88 Neither X/Open Curses nor the SVr4 manual pages give details about
89 the way the rendition of characters on the screen is updated when
90 \fBbkgd\fP or \fBwbkgd\fP is used to change the background character.
91 .PP
92 This implementation, like SVr4 curses, does not store the background
93 and window attribute contributions to each cell separately.
94 It updates the rendition by comparing the character, non-color attributes and
95 colors contained in the background.
96 For each cell in the window, whether or not it is blank:
97 .bP
98 The library first compares the \fIcharacter\fP,
99 and if it matches the current character part of the background,
100 it replaces that with the new background character.
101 .IP
102 When \fBbkgdset\fP is used to set the background character,
103 that does not update each cell in the window.
104 A subsequent call to \fBbkgd\fP will only modify the \fIcharacter\fP in
105 cells which match the current background character.
106 .bP
107 The library then checks if the cell uses color,
108 i.e., its color pair value is nonzero.
109 If not, it simply replaces the attributes and color pair in the
110 cell with those from the new background character.
111 .bP
112 If the cell uses color,
113 and that matches the color in the current background,
114 the library removes attributes
115 which may have come from the current background
116 and adds attributes from the new background.
117 It finishes by setting the cell
118 to use the color from the new background.
119 .bP
120 If the cell uses color,
121 and that does not match the color in the current background,
122 the library updates only the non-color attributes,
123 first removing those which may have come from the current background,
124 and then adding attributes from the new background.
125 .PP
126 If the background's character value is zero (0), a space is assumed.
127 .PP
128 If the terminal does not support color,
129 or if color has not been started with \fBstart_color\fP,
130 the new background character's color attribute will be ignored.
131 .SS getbkgd
132 The \fBgetbkgd\fP function returns the given window's current background
133 character/attribute pair.
134 .SH RETURN VALUE
135 These functions are described in the XSI Curses standard, Issue 4.
136 It specifies that \fBbkgd\fP and \fBwbkgd\fP return \fBERR\fP on failure,
137 but gives no failure conditions.
138 .PP
139 The routines \fBbkgd\fP and \fBwbkgd\fP return the integer \fBOK\fP,
140 unless the library has not been initialized.
141 .PP
142 In contrast,
143 the SVr4.0 manual says \fBbkgd\fP and \fBwbkgd\fP may return \fBOK\fP
144 "or a non-negative integer if \fBimmedok\fP is set",
145 which refers to the return value from \fBwrefresh\fP
146 (used to implement the immediate repainting).
147 The SVr4 curses \fBwrefresh\fP returns the number of characters
148 written to the screen during the refresh.
149 This implementation does not do that.
150 .SH NOTES
151 Note that \fBbkgdset\fP and \fBbkgd\fP may be macros.
152 .PP
153 X/Open Curses mentions that the character part of the background must
154 be a single-byte value.
155 This implementation, like SVr4, checks to ensure that,
156 and will reuse the old background character if the check fails.
157 .SH PORTABILITY
158 These functions are described in the XSI Curses standard, Issue 4
159 (X/Open Curses).
160 .SH SEE ALSO
161 .na
162 \fBcurses\fP(3X),
163 \fBcurs_addch\fP(3X),
164 \fBcurs_attr\fP(3X),
165 \fBcurs_outopts\fP(3X)