]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_bkgd.3x
ncurses 6.4 - patch 20230701
[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.39 2023/07/01 15:43:20 tom Exp $
31 .de bP
32 .ie n  .IP \(bu 4
33 .el    .IP \(bu 2
34 ..
35 .TH curs_bkgd 3X 2023-07-01 "ncurses 6.4" "Library calls"
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 The \fBbkgd\fP and \fBwbkgd\fP functions
75 set the background property of the current or specified window
76 and then apply this setting to every character position in that window.
77 According to X/Open Curses, it should do this:
78 .bP
79 The rendition of every character on the screen is changed to
80 the new background rendition.
81 .bP
82 Wherever the former background character
83 appears, it is changed to the new background character.
84 .PP
85 Neither X/Open Curses nor the SVr4 manual pages give details about
86 the way the rendition of characters on the screen is updated when
87 \fBbkgd\fP or \fBwbkgd\fP is used to change the background character.
88 .PP
89 This implementation, like SVr4 curses, does not store the background
90 and window attribute contributions to each cell separately.
91 It updates the rendition by comparing the character, non-color attributes and
92 colors contained in the background.
93 For each cell in the window, whether or not it is blank:
94 .bP
95 The library first compares the \fIcharacter\fP,
96 and if it matches the current character part of the background,
97 it replaces that with the new background character.
98 .IP
99 When \fBbkgdset\fP is used to set the background character,
100 that does not update each cell in the window.
101 A subsequent call to \fBbkgd\fP will only modify the \fIcharacter\fP in
102 cells which match the current background character.
103 .bP
104 The library then checks if the cell uses color,
105 i.e., its color pair value is nonzero.
106 If not, it simply replaces the attributes and color pair in the
107 cell with those from the new background character.
108 .bP
109 If the cell uses color,
110 and that matches the color in the current background,
111 the library removes attributes
112 which may have come from the current background
113 and adds attributes from the new background.
114 It finishes by setting the cell
115 to use the color from the new background.
116 .bP
117 If the cell uses color,
118 and that does not match the color in the current background,
119 the library updates only the non-color attributes,
120 first removing those which may have come from the current background,
121 and then adding attributes from the new background.
122 .PP
123 If the background's character value is zero (0), a space is assumed.
124 .PP
125 If the terminal does not support color,
126 or if color has not been started with \fBstart_color\fP,
127 the new background character's color attribute will be ignored.
128 .SS getbkgd
129 The \fBgetbkgd\fP function returns the given window's current background
130 character/attribute pair.
131 .SH RETURN VALUE
132 These functions are described in the XSI Curses standard, Issue 4.
133 It specifies that \fBbkgd\fP and \fBwbkgd\fP return \fBERR\fP on failure,
134 but gives no failure conditions.
135 .PP
136 The routines \fBbkgd\fP and \fBwbkgd\fP return the integer \fBOK\fP,
137 unless the library has not been initialized.
138 .PP
139 In contrast,
140 the SVr4.0 manual says \fBbkgd\fP and \fBwbkgd\fP may return \fBOK\fP
141 "or a non-negative integer if \fBimmedok\fP is set",
142 which refers to the return value from \fBwrefresh\fP
143 (used to implement the immediate repainting).
144 The SVr4 curses \fBwrefresh\fP returns the number of characters
145 written to the screen during the refresh.
146 This implementation does not do that.
147 .SH NOTES
148 Note that \fBbkgdset\fP and \fBbkgd\fP may be macros.
149 .PP
150 X/Open Curses mentions that the character part of the background must
151 be a single-byte value.
152 This implementation, like SVr4, checks to ensure that,
153 and will reuse the old background character if the check fails.
154 .SH PORTABILITY
155 These functions are described in the XSI Curses standard, Issue 4
156 (X/Open Curses).
157 .SH SEE ALSO
158 .na
159 \fBcurses\fP(3X),
160 \fBcurs_addch\fP(3X),
161 \fBcurs_attr\fP(3X),
162 \fBcurs_outopts\fP(3X)