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