blob: 25ba1f9f72c8b2e5c99257a5090be8341af6f7f6 [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 1998-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_bkgd.3x,v 1.61 2024/04/20 18:54:36 tom Exp $
31.TH curs_bkgd 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\%bkgdset\fP,
49\fB\%wbkgdset\fP,
50\fB\%bkgd\fP,
51\fB\%wbkgd\fP,
52\fB\%getbkgd\fP \-
53manipulate background of a \fIcurses\fR window of characters
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053054.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040055.nf
56\fB#include <curses.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053057.PP
micky3879b9f5e72025-07-08 18:04:53 -040058\fBint bkgd(chtype \fIch\fP);
59\fBint wbkgd(WINDOW *\fIwin\fP, chtype \fIch\fP);
60.PP
61\fBvoid bkgdset(chtype \fIch\fP);
62\fBvoid wbkgdset(WINDOW *\fIwin\fP, chtype \fIch\fP);
63.PP
64\fBchtype getbkgd(WINDOW *\fIwin\fP);
65.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053066.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040067The
68.I background
69of a
70.I curses
71window
72(in the library's non-\*(``wide\*('' configuration)
73is a
74.I \%chtype
75combining a set of attributes
76(see \fB\%curs_attr\fP(3X))
77with a character called the
78.I "blank character."
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053079.PP
micky3879b9f5e72025-07-08 18:04:53 -040080The blank character is a spacing character that populates a window's
81character cells when their contents are erased without replacement.
82The background's attributes are combined with all non-blank characters
83written to the window,
84as with the \fB\%waddch\fP(3X) and \fB\%winsch\fP(3X) families of
85functions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053086.PP
micky3879b9f5e72025-07-08 18:04:53 -040087The blank character and attributes of the background combine with
88characters written to the window as described below.
89The background becomes a property of the character and moves with it
90through any scrolling and insert/delete line/character operations.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053091.PP
micky3879b9f5e72025-07-08 18:04:53 -040092To the extent possible on a given terminal,
93the attribute part of the background is displayed as the graphic
94rendition of the character put on the screen.
95.SS "bkgd, wbkgd"
96\fB\%bkgd\fP and \fB\%wbkgd\fP set the background property of
97\fB\%stdscr\fP or the specified window and then apply this setting to
98every character cell in that window.
Steve Kondikae271bc2015-11-15 02:50:53 +010099.bP
micky3879b9f5e72025-07-08 18:04:53 -0400100The rendition of every character in the window changes to the new
101background rendition.
Steve Kondikae271bc2015-11-15 02:50:53 +0100102.bP
micky3879b9f5e72025-07-08 18:04:53 -0400103Wherever the former background character appears,
104it changes to the new background character.
105.PP
106.I \%ncurses
107updates the rendition of each character cell by comparing the character,
108non-color attributes,
109and colors.
110The library applies to following procedure to each cell in the window,
111whether or not it is blank.
112.bP
113.I \%ncurses
114first compares the cell's character to the previously specified blank
115character;
116if they match,
117.I \%ncurses
118writes the new blank character to the cell.
119.bP
120.I \%ncurses
121then checks if the cell uses color,
122that is,
123its color pair value is nonzero.
124If not,
125it simply replaces the attributes and color pair in the cell with those
126from the new background character.
127.bP
128If the cell uses color,
129and its background color matches that of the current window background,
130.I \%ncurses
131removes attributes that may have come from the current background and
132adds those from the new background.
133It finishes by setting the cell's background to use the new window
134background color.
135.bP
136If the cell uses color,
137and its background color does not match that of the current window
138background,
139.I \%ncurses
140updates only the non-color attributes,
141first removing those that may have come from the current background,
142and then adding attributes from the new background.
143.PP
144.I \%ncurses
145treats a background character value of zero (0) as a blank character.
146.PP
147If the terminal does not support color,
148or if color has not been initialized with \fB\%start_color\fP(3X),
149.I \%ncurses
150ignores the new background character's color attribute.
151.SS "bkgdset, wbkgdset"
152\fB\%bkgdset\fP and \fB\%wbkgdset\fP manipulate the background of
153the applicable window,
154without updating the character cells as \fB\%bkgd\fP and
155\fB\%wbkgd\fP do;
156only future writes reflect the updated background.
Steve Kondikae271bc2015-11-15 02:50:53 +0100157.SS getbkgd
micky3879b9f5e72025-07-08 18:04:53 -0400158\fB\%getbkgd\fP obtains the given window's background character and
159attribute combination.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530160.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400161Functions returning an \fIint\fP return \fBOK\fP on success.
162\fB\%bkgd\fP returns \fBERR\fP if the library has not been initialized.
163\fB\%wbkgd\fP and \fB\%getbkgd\fP return \fBERR\fP if a \fI\%WINDOW\fP
164pointer argument is null.
Steve Kondikae271bc2015-11-15 02:50:53 +0100165.PP
micky3879b9f5e72025-07-08 18:04:53 -0400166\fB\%bkgdset\fP and \fBwbkgdset\fP do not return a value.
167.PP
168\fB\%getbkgd\fP returns a window's background character and attribute
169combination.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530170.SH NOTES
micky3879b9f5e72025-07-08 18:04:53 -0400171Unusually,
172there is no \fB\%wgetbkgd\fP function;
173\fB\%getbkgd\fP behaves as one would expect \fB\%wgetbkgd\fP to,
174accepting a \fI\%WINDOW\fP pointer argument.
Steve Kondikae271bc2015-11-15 02:50:53 +0100175.PP
micky3879b9f5e72025-07-08 18:04:53 -0400176\fB\%bkgd\fP and
177\fB\%bkgdset\fP
178may be implemented as macros.
179.PP
180X/Open Curses mentions that the character part of the background must
181be a single-byte value.
182\fI\%ncurses\fP,
183like SVr4 \fIcurses\fP,
184checks to ensure that,
185and will reuse the old background character if the check fails.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530186.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400187X/Open Curses,
188Issue 4 describes these functions.
189It specifies that
190\fB\%bkgd\fP,
191\fB\%wbkgd\fP,
192and
193\fB\%getbkgd\fP
194return \fBERR\fP on failure
195(in the case of the last,
196this value is cast to
197.IR \%chtype ),
198but describes no failure conditions.
Steve Kondikae271bc2015-11-15 02:50:53 +0100199.PP
micky3879b9f5e72025-07-08 18:04:53 -0400200The SVr4.0 manual says that \fB\%bkgd\fP and \fB\%wbkgd\fP may return
201\fBOK\fP
202\*(``or a non-negative integer if \fB\%immedok\fP is set\*('',
203which refers to the return value from \fB\%wrefresh\fP(3X),
204used to implement the immediate repainting.
205SVr4 \fIcurses\fP's \fB\%wrefresh\fP returns the number of characters
206written to the screen during the refresh.
207\fI\%ncurses\fP does not do that.
208.PP
209Neither X/Open Curses nor the SVr4 manual pages detail how the rendition
210of characters on the screen updates when \fB\%bkgd\fP or \fB\%wbkgd\fP
211changes the background character.
212.IR \%ncurses ,
213like SVr4
214.IR curses ,
215does not
216(in its non-\*(``wide\*('' configuration)
217store the background and window attribute contributions to each
218character cell separately.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530219.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400220\fB\%curs_bkgrnd\fP(3X) describes the corresponding functions in the
221\*(``wide\*('' configuration of
222.IR \%ncurses .
Steve Kondikae271bc2015-11-15 02:50:53 +0100223.PP
micky3879b9f5e72025-07-08 18:04:53 -0400224\fB\%curses\fP(3X),
225\fB\%curs_addch\fP(3X),
226\fB\%curs_attr\fP(3X)