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