Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 2002-2015,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $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 Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 43 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 44 | .ie n .IP \(bu 4 |
| 45 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 46 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | \fB\%bkgrnd\fP, |
| 49 | \fB\%wbkgrnd\fP, |
| 50 | \fB\%bkgrndset\fP, |
| 51 | \fB\%wbkgrndset\fP, |
| 52 | \fB\%getbkgrnd\fP, |
| 53 | \fB\%wgetbkgrnd\fP \- |
| 54 | manipulate background of a \fIcurses\fP window of wide characters |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 56 | .nf |
| 57 | \fB#include <curses.h> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 58 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 59 | \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 Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 68 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 69 | The |
| 70 | .I background |
| 71 | of a |
| 72 | .I curses |
| 73 | window |
| 74 | (in the library's \*(``wide\*('' configuration) |
| 75 | is a |
| 76 | .I \%cchar_t |
| 77 | combining a set of attributes |
| 78 | (see \fB\%curs_attr\fP(3X)) |
| 79 | with a complex character called the |
| 80 | .I "blank character." |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 81 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 82 | The blank character is a spacing character that populates a window's |
| 83 | character cells when their contents are erased without replacement. |
| 84 | The background's attributes are combined with all non-blank characters |
| 85 | written to the window, |
| 86 | as with the \fB\%wadd_wch\fP(3X) and \fB\%wins_wch\fP(3X) families of |
| 87 | functions. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 88 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 89 | The blank character and attributes of the background combine with |
| 90 | characters written to the window as described below. |
| 91 | The background becomes a property of the character and moves with it |
| 92 | through any scrolling and insert/delete line/character operations. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 93 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 94 | To the extent possible on a given terminal, |
| 95 | the attribute part of the background is displayed as the graphic |
| 96 | rendition 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 |
| 100 | every character cell in that window. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 101 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 102 | The rendition of every character in the window changes to the new |
| 103 | background rendition. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 104 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 105 | Wherever the former background character appears, |
| 106 | it changes to the new background character. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 107 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 108 | .I \%ncurses |
| 109 | updates the rendition of each character cell by comparing the character, |
| 110 | non-color attributes, |
| 111 | and colors. |
| 112 | The library applies to following procedure to each cell in the window, |
| 113 | whether or not it is blank. |
| 114 | .bP |
| 115 | .I \%ncurses |
| 116 | first compares the cell's character to the previously specified blank |
| 117 | character; |
| 118 | if they match, |
| 119 | .I \%ncurses |
| 120 | writes the new blank character to the cell. |
| 121 | .bP |
| 122 | .I \%ncurses |
| 123 | then checks if the cell uses color, |
| 124 | that is, |
| 125 | its color pair value is nonzero. |
| 126 | If not, |
| 127 | it simply replaces the attributes and color pair in the cell with those |
| 128 | from the new background character. |
| 129 | .bP |
| 130 | If the cell uses color, |
| 131 | and its background color matches that of the current window background, |
| 132 | .I \%ncurses |
| 133 | removes attributes that may have come from the current background and |
| 134 | adds those from the new background. |
| 135 | It finishes by setting the cell's background to use the new window |
| 136 | background color. |
| 137 | .bP |
| 138 | If the cell uses color, |
| 139 | and its background color does not match that of the current window |
| 140 | background, |
| 141 | .I \%ncurses |
| 142 | updates only the non-color attributes, |
| 143 | first removing those that may have come from the current background, |
| 144 | and then adding attributes from the new background. |
| 145 | .PP |
| 146 | .I \%ncurses |
| 147 | treats a background character value of zero (0) as a blank character. |
| 148 | .PP |
| 149 | If the terminal does not support color, |
| 150 | or if color has not been initialized with \fB\%start_color\fP(3X), |
| 151 | .I \%ncurses |
| 152 | ignores the new background character's color attribute. |
| 153 | .SS "bkgrndset, wbkgrndset" |
| 154 | \fB\%bkgrndset\fP and \fB\%wbkgrndset\fP manipulate the background of |
| 155 | the applicable window, |
| 156 | without updating the character cells as \fB\%bkgrnd\fP and |
| 157 | \fB\%wbkgrnd\fP do; |
| 158 | only future writes reflect the updated background. |
| 159 | .SS "getbkgrnd, wgetbkgrnd" |
| 160 | The \fB\%getbkgrnd\fP and \fB\%wgetbkgrnd\fP functions obtain the |
| 161 | background character and attribute pair of \fB\%stdscr\fP or the |
| 162 | specified window and store it via the |
| 163 | .I wch |
| 164 | pointer. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 165 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 166 | \fBbkgrndset\fP and \fBwbkgrndset\fP do not return a value. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 167 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 168 | The other functions return |
| 169 | .B ERR |
| 170 | upon failure and |
| 171 | .B OK |
| 172 | upon success. |
| 173 | In |
| 174 | .IR \%ncurses , |
| 175 | failure occurs if |
| 176 | .bP |
| 177 | a |
| 178 | .I \%WINDOW |
| 179 | pointer |
| 180 | .I win |
| 181 | is null, or |
| 182 | .bP |
| 183 | a |
| 184 | .I \%cchar_t |
| 185 | pointer |
| 186 | .I wch |
| 187 | is null. |
| 188 | .SH NOTES |
| 189 | \fB\%bkgrnd\fP, |
| 190 | \fB\%bkgrndset\fP, and |
| 191 | \fB\%getbkgrnd\fP |
| 192 | may be implemented as macros. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 193 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 194 | Unlike their counterparts in the non-\*(``wide\*('' configuration of |
| 195 | .IR \%ncurses , |
| 196 | \fB\%getbkgrnd\fP and \fB\%wgetbkgrnd\fP supply the background character |
| 197 | and attribute in a modifiable |
| 198 | .I \%cchar_t |
| 199 | parameter, |
| 200 | not as the return value. |
| 201 | .SH PORTABILITY |
| 202 | X/Open Curses, |
| 203 | Issue 4 describes these functions. |
| 204 | It specifies no error conditions for them. |
| 205 | .PP |
| 206 | X/Open Curses does not provide details of how the rendition is updated. |
| 207 | This implementation follows the approach used in SVr4 |
| 208 | .IR curses . |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 209 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 210 | \fB\%curs_bkgd\fP(3X) describes the corresponding functions in the |
| 211 | non-\*(``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) |