blob: 2551924c11a31eafe598d6d60cf93231e6934d82 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 2002-2015,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_bkgrnd.3x,v 1.42 2024/04/20 18:54:36 tom Exp $
31.TH curs_bkgrnd 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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.
Steve Kondikae271bc2015-11-15 02:50:53 +010043.de bP
micky3879b9f5e72025-07-08 18:04:53 -040044.ie n .IP \(bu 4
45.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010046..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040048\fB\%bkgrnd\fP,
49\fB\%wbkgrnd\fP,
50\fB\%bkgrndset\fP,
51\fB\%wbkgrndset\fP,
52\fB\%getbkgrnd\fP,
53\fB\%wgetbkgrnd\fP \-
54manipulate background of a \fIcurses\fP window of wide characters
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053055.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040056.nf
57\fB#include <curses.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053058.PP
micky3879b9f5e72025-07-08 18:04:53 -040059\fBint bkgrnd(const cchar_t *\fIwch\fP);
60\fBint wbkgrnd(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
61.PP
62\fBvoid bkgrndset(const cchar_t *\fIwch\fP);
63\fBvoid wbkgrndset(WINDOW *\fIwin\fP, const cchar_t *\fIwch\fP);
64.PP
65\fBint getbkgrnd(cchar_t *\fIwch\fP);
66\fBint wgetbkgrnd(WINDOW *\fIwin\fP, cchar_t *\fIwch\fP);
67.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053068.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040069The
70.I background
71of a
72.I curses
73window
74(in the library's \*(``wide\*('' configuration)
75is a
76.I \%cchar_t
77combining a set of attributes
78(see \fB\%curs_attr\fP(3X))
79with a complex character called the
80.I "blank character."
Steve Kondikae271bc2015-11-15 02:50:53 +010081.PP
micky3879b9f5e72025-07-08 18:04:53 -040082The blank character is a spacing character that populates a window's
83character cells when their contents are erased without replacement.
84The background's attributes are combined with all non-blank characters
85written to the window,
86as with the \fB\%wadd_wch\fP(3X) and \fB\%wins_wch\fP(3X) families of
87functions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053088.PP
micky3879b9f5e72025-07-08 18:04:53 -040089The blank character and attributes of the background combine with
90characters written to the window as described below.
91The background becomes a property of the character and moves with it
92through any scrolling and insert/delete line/character operations.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053093.PP
micky3879b9f5e72025-07-08 18:04:53 -040094To the extent possible on a given terminal,
95the attribute part of the background is displayed as the graphic
96rendition of the character put on the screen.
97.SS "bkgrnd, wbkgrnd"
98\fB\%bkgrnd\fP and \fB\%wbkgrnd\fP set the background property of
99\fB\%stdscr\fP or the specified window and then apply this setting to
100every character cell in that window.
Steve Kondikae271bc2015-11-15 02:50:53 +0100101.bP
micky3879b9f5e72025-07-08 18:04:53 -0400102The rendition of every character in the window changes to the new
103background rendition.
Steve Kondikae271bc2015-11-15 02:50:53 +0100104.bP
micky3879b9f5e72025-07-08 18:04:53 -0400105Wherever the former background character appears,
106it changes to the new background character.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530107.PP
micky3879b9f5e72025-07-08 18:04:53 -0400108.I \%ncurses
109updates the rendition of each character cell by comparing the character,
110non-color attributes,
111and colors.
112The library applies to following procedure to each cell in the window,
113whether or not it is blank.
114.bP
115.I \%ncurses
116first compares the cell's character to the previously specified blank
117character;
118if they match,
119.I \%ncurses
120writes the new blank character to the cell.
121.bP
122.I \%ncurses
123then checks if the cell uses color,
124that is,
125its color pair value is nonzero.
126If not,
127it simply replaces the attributes and color pair in the cell with those
128from the new background character.
129.bP
130If the cell uses color,
131and its background color matches that of the current window background,
132.I \%ncurses
133removes attributes that may have come from the current background and
134adds those from the new background.
135It finishes by setting the cell's background to use the new window
136background color.
137.bP
138If the cell uses color,
139and its background color does not match that of the current window
140background,
141.I \%ncurses
142updates only the non-color attributes,
143first removing those that may have come from the current background,
144and then adding attributes from the new background.
145.PP
146.I \%ncurses
147treats a background character value of zero (0) as a blank character.
148.PP
149If the terminal does not support color,
150or if color has not been initialized with \fB\%start_color\fP(3X),
151.I \%ncurses
152ignores the new background character's color attribute.
153.SS "bkgrndset, wbkgrndset"
154\fB\%bkgrndset\fP and \fB\%wbkgrndset\fP manipulate the background of
155the applicable window,
156without updating the character cells as \fB\%bkgrnd\fP and
157\fB\%wbkgrnd\fP do;
158only future writes reflect the updated background.
159.SS "getbkgrnd, wgetbkgrnd"
160The \fB\%getbkgrnd\fP and \fB\%wgetbkgrnd\fP functions obtain the
161background character and attribute pair of \fB\%stdscr\fP or the
162specified window and store it via the
163.I wch
164pointer.
Steve Kondikae271bc2015-11-15 02:50:53 +0100165.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400166\fBbkgrndset\fP and \fBwbkgrndset\fP do not return a value.
Steve Kondikae271bc2015-11-15 02:50:53 +0100167.PP
micky3879b9f5e72025-07-08 18:04:53 -0400168The other functions return
169.B ERR
170upon failure and
171.B OK
172upon success.
173In
174.IR \%ncurses ,
175failure occurs if
176.bP
177a
178.I \%WINDOW
179pointer
180.I win
181is null, or
182.bP
183a
184.I \%cchar_t
185pointer
186.I wch
187is null.
188.SH NOTES
189\fB\%bkgrnd\fP,
190\fB\%bkgrndset\fP, and
191\fB\%getbkgrnd\fP
192may be implemented as macros.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530193.PP
micky3879b9f5e72025-07-08 18:04:53 -0400194Unlike their counterparts in the non-\*(``wide\*('' configuration of
195.IR \%ncurses ,
196\fB\%getbkgrnd\fP and \fB\%wgetbkgrnd\fP supply the background character
197and attribute in a modifiable
198.I \%cchar_t
199parameter,
200not as the return value.
201.SH PORTABILITY
202X/Open Curses,
203Issue 4 describes these functions.
204It specifies no error conditions for them.
205.PP
206X/Open Curses does not provide details of how the rendition is updated.
207This implementation follows the approach used in SVr4
208.IR curses .
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530209.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400210\fB\%curs_bkgd\fP(3X) describes the corresponding functions in the
211non-\*(``wide\*('' configuration of
212.IR \%ncurses .
213.PP
214\fB\%curses\fP(3X),
215\fB\%curs_add_wch\fP(3X),
216\fB\%curs_attr\fP(3X)