| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> |
| 33 |
<HTML> |
| 34 |
<HEAD> |
| 35 |
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
| 36 |
<meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts"> |
| 37 |
<TITLE>curs_bkgd 3x 2025-08-23 ncurses 6.6 Library calls</TITLE> |
| 38 |
<link rel="author" href="mailto:[email protected]"> |
| 39 |
|
| 40 |
</HEAD> |
| 41 |
<BODY> |
| 42 |
<H1 class="no-header">curs_bkgd 3x 2025-08-23 ncurses 6.6 Library calls</H1> |
| 43 |
<PRE> |
| 44 |
<STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG> Library calls <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG> |
| 45 |
|
| 46 |
|
| 47 |
</PRE><H2><a name="h2-NAME">NAME</a></H2><PRE> |
| 48 |
<STRONG>bkgdset</STRONG>, <STRONG>wbkgdset</STRONG>, <STRONG>bkgd</STRONG>, <STRONG>wbkgd</STRONG>, <STRONG>getbkgd</STRONG> - manipulate background of a |
| 49 |
<EM>curses</EM> window of characters |
| 50 |
|
| 51 |
|
| 52 |
</PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE> |
| 53 |
<STRONG>#include</STRONG> <STRONG><curses.h></STRONG> |
| 54 |
|
| 55 |
<STRONG>int</STRONG> <STRONG>bkgd(chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG> |
| 56 |
<STRONG>int</STRONG> <STRONG>wbkgd(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG> |
| 57 |
|
| 58 |
<STRONG>void</STRONG> <STRONG>bkgdset(chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG> |
| 59 |
<STRONG>void</STRONG> <STRONG>wbkgdset(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>chtype</STRONG> <EM>ch</EM><STRONG>);</STRONG> |
| 60 |
|
| 61 |
<STRONG>chtype</STRONG> <STRONG>getbkgd(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>);</STRONG> |
| 62 |
|
| 63 |
|
| 64 |
</PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE> |
| 65 |
Every <EM>curses</EM> window has a <EM>background</EM> <EM>character</EM> property: in the |
| 66 |
library's non-wide-character configuration, it is a <EM>curses</EM> character |
| 67 |
(<EM>chtype</EM>) that combines a set of attributes (and, if colors are enabled, |
| 68 |
a color pair identifier) with a character code. When erasing (parts |
| 69 |
of) a window, <EM>curses</EM> replaces the erased cells with the background |
| 70 |
character. |
| 71 |
|
| 72 |
<EM>curses</EM> also uses the background character when writing characters to a |
| 73 |
populated window. |
| 74 |
|
| 75 |
<STRONG>o</STRONG> The attribute part of the background character combines with all |
| 76 |
non-blank character cells in the window, as populated by the |
| 77 |
<STRONG><A HREF="curs_addch.3x.html">waddch(3x)</A></STRONG> and <STRONG><A HREF="curs_insch.3x.html">winsch(3x)</A></STRONG> families of functions (and those that |
| 78 |
call them). |
| 79 |
|
| 80 |
<STRONG>o</STRONG> Both the character code and attributes of the background character |
| 81 |
combine with blank character cells in the window. |
| 82 |
|
| 83 |
The background character's set of attributes becomes a property of the |
| 84 |
character cell and move with it through any scrolling and insert/delete |
| 85 |
line/character operations. To the extent possible on the terminal |
| 86 |
type, <EM>curses</EM> displays the attributes of the background character as the |
| 87 |
graphic rendition of a character cell on the display. |
| 88 |
|
| 89 |
|
| 90 |
</PRE><H3><a name="h3-bkgd_wbkgd">bkgd, wbkgd</a></H3><PRE> |
| 91 |
<STRONG>bkgd</STRONG> and <STRONG>wbkgd</STRONG> set the background property of <STRONG>stdscr</STRONG> or the specified |
| 92 |
window and then apply this setting to every character cell in that |
| 93 |
window. |
| 94 |
|
| 95 |
<STRONG>o</STRONG> The rendition of every character in the window changes to the new |
| 96 |
background rendition. |
| 97 |
|
| 98 |
<STRONG>o</STRONG> Wherever the former background character appears, it changes to the |
| 99 |
new background character. |
| 100 |
|
| 101 |
<EM>ncurses</EM> updates the rendition of each character cell by comparing the |
| 102 |
character, non-color attributes, and color pair selection. The library |
| 103 |
applies the following procedure to each cell in the window, whether or |
| 104 |
not it is blank. |
| 105 |
|
| 106 |
<STRONG>o</STRONG> <EM>ncurses</EM> first compares the cell's character to the previously |
| 107 |
specified background character; if they match, <EM>ncurses</EM> writes the |
| 108 |
new background character to the cell. |
| 109 |
|
| 110 |
<STRONG>o</STRONG> <EM>ncurses</EM> then checks whether the cell uses color; that is, its color |
| 111 |
pair value is nonzero. If not, it simply replaces the attributes |
| 112 |
and color pair in the cell with those from the new background |
| 113 |
character. |
| 114 |
|
| 115 |
<STRONG>o</STRONG> If the cell uses color, and its background color matches that of |
| 116 |
the current window background, <EM>ncurses</EM> removes attributes that may |
| 117 |
have come from the current background and adds those from the new |
| 118 |
background. It finishes by setting the cell's background to use |
| 119 |
the new window background color. |
| 120 |
|
| 121 |
<STRONG>o</STRONG> If the cell uses color, and its background color does not match |
| 122 |
that of the current window background, <EM>ncurses</EM> updates only the |
| 123 |
non-color attributes, first removing those that may have come from |
| 124 |
the current background, and then adding attributes from the new |
| 125 |
background. |
| 126 |
|
| 127 |
If the new background's character is non-spacing (for example, if it is |
| 128 |
a control character), <EM>ncurses</EM> retains the existing background |
| 129 |
character, except for one special case: <EM>ncurses</EM> treats a background |
| 130 |
character code of zero (0) as a space. |
| 131 |
|
| 132 |
If the terminal does not support color, or if color has not been |
| 133 |
initialized with <STRONG><A HREF="curs_color.3x.html">start_color(3x)</A></STRONG>, <EM>ncurses</EM> ignores the new background |
| 134 |
character's color pair selection. |
| 135 |
|
| 136 |
|
| 137 |
</PRE><H3><a name="h3-bkgdset_wbkgdset">bkgdset, wbkgdset</a></H3><PRE> |
| 138 |
<STRONG>bkgdset</STRONG> and <STRONG>wbkgdset</STRONG> manipulate the background of the applicable |
| 139 |
window, without updating the character cells as <STRONG>bkgd</STRONG> and <STRONG>wbkgd</STRONG> do; only |
| 140 |
future writes reflect the updated background. |
| 141 |
|
| 142 |
|
| 143 |
</PRE><H3><a name="h3-getbkgd">getbkgd</a></H3><PRE> |
| 144 |
<STRONG>getbkgd</STRONG> returns the given window's background character, attributes, |
| 145 |
and color pair as a <EM>chtype</EM>. |
| 146 |
|
| 147 |
|
| 148 |
</PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE> |
| 149 |
<STRONG>bkgdset</STRONG> and <STRONG>wbkgdset</STRONG> do not return a value. |
| 150 |
|
| 151 |
Functions returning an <EM>int</EM> return <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> upon success. |
| 152 |
In <EM>ncurses</EM>, failure occurs if |
| 153 |
|
| 154 |
<STRONG>o</STRONG> the <EM>curses</EM> screen has not been initialized, or |
| 155 |
|
| 156 |
<STRONG>o</STRONG> <EM>win</EM> is <EM>NULL</EM>. |
| 157 |
|
| 158 |
<STRONG>getbkgd</STRONG>'s return value is as described above. |
| 159 |
|
| 160 |
|
| 161 |
</PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE> |
| 162 |
Unusually, there is no <STRONG>wgetbkgd</STRONG> function; <STRONG>getbkgd</STRONG> behaves as one would |
| 163 |
expect <STRONG>wgetbkgd</STRONG> to, accepting a <EM>WINDOW</EM> pointer argument. |
| 164 |
|
| 165 |
<STRONG>bkgd</STRONG> and <STRONG>bkgdset</STRONG> may be implemented as macros. |
| 166 |
|
| 167 |
X/Open Curses mentions that the character part of the background must |
| 168 |
be a single-byte value. <EM>ncurses</EM>, like SVr4 <EM>curses</EM>, checks to ensure |
| 169 |
that it is, and retains the existing background character if the check |
| 170 |
fails. |
| 171 |
|
| 172 |
|
| 173 |
</PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE> |
| 174 |
X/Open Curses Issue 4 describes these functions. It indicates that |
| 175 |
<EM>bkgd</EM>, <EM>wbkgd</EM>, and <EM>getbkgd</EM> return <EM>ERR</EM> on failure (in the case of the |
| 176 |
last, this value is cast to <EM>chtype</EM>), but specifies no error conditions |
| 177 |
for them. |
| 178 |
|
| 179 |
SVr4 documentation says that <EM>bkgd</EM> and <EM>wbkgd</EM> return <EM>OK</EM> "or a non- |
| 180 |
negative integer if <EM>immedok()</EM> is set", referring to the return value |
| 181 |
from <EM>wrefresh</EM>, which in SVr4 returns a count of characters written to |
| 182 |
the window if its <EM>immedok</EM> property is set; in <EM>ncurses</EM>, it does not. |
| 183 |
|
| 184 |
Neither X/Open Curses nor the SVr4 manual pages detail how the |
| 185 |
rendition of characters in the window updates when <EM>bkgd</EM> or <EM>wbkgd</EM> |
| 186 |
changes the background character. <EM>ncurses</EM>, like SVr4 <EM>curses</EM>, does not |
| 187 |
(in its non-wide-character configuration) store the background and |
| 188 |
window attribute contributions to each character cell separately. |
| 189 |
|
| 190 |
|
| 191 |
</PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE> |
| 192 |
SVr3.1 (1987) introduced these functions. |
| 193 |
|
| 194 |
|
| 195 |
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE> |
| 196 |
<STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG> describes the corresponding functions in the wide |
| 197 |
configuration of <EM>ncurses</EM>. |
| 198 |
|
| 199 |
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>, <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG> |
| 200 |
|
| 201 |
ncurses 6.6 2025-08-23 <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG> |
| 202 |
</PRE> |
| 203 |
<div class="nav"> |
| 204 |
<ul> |
| 205 |
<li><a href="#h2-NAME">NAME</a></li> |
| 206 |
<li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li> |
| 207 |
<li><a href="#h2-DESCRIPTION">DESCRIPTION</a> |
| 208 |
<ul> |
| 209 |
<li><a href="#h3-bkgd_wbkgd">bkgd, wbkgd</a></li> |
| 210 |
<li><a href="#h3-bkgdset_wbkgdset">bkgdset, wbkgdset</a></li> |
| 211 |
<li><a href="#h3-getbkgd">getbkgd</a></li> |
| 212 |
</ul> |
| 213 |
</li> |
| 214 |
<li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li> |
| 215 |
<li><a href="#h2-NOTES">NOTES</a></li> |
| 216 |
<li><a href="#h2-PORTABILITY">PORTABILITY</a></li> |
| 217 |
<li><a href="#h2-HISTORY">HISTORY</a></li> |
| 218 |
<li><a href="#h2-SEE-ALSO">SEE ALSO</a></li> |
| 219 |
</ul> |
| 220 |
</div> |
| 221 |
</BODY> |
| 222 |
</HTML> |