Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | '\" t |
| 2 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 3 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 4 | .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 5 | .\" * |
| 6 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 7 | .\" copy of this software and associated documentation files (the * |
| 8 | .\" "Software"), to deal in the Software without restriction, including * |
| 9 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 10 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 11 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 12 | .\" furnished to do so, subject to the following conditions: * |
| 13 | .\" * |
| 14 | .\" The above copyright notice and this permission notice shall be included * |
| 15 | .\" in all copies or substantial portions of the Software. * |
| 16 | .\" * |
| 17 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 18 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 19 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 20 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 21 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 22 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 23 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 24 | .\" * |
| 25 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 26 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 27 | .\" sale, use or other dealings in this Software without prior written * |
| 28 | .\" authorization. * |
| 29 | .\"*************************************************************************** |
| 30 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 31 | .\" $Id: curs_attr.3x,v 1.105 2024/04/27 17:54:42 tom Exp $ |
| 32 | .TH curs_attr 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
| 33 | .ie \n(.g \{\ |
| 34 | .ds `` \(lq |
| 35 | .ds '' \(rq |
| 36 | .\} |
| 37 | .el \{\ |
| 38 | .ie t .ds `` `` |
| 39 | .el .ds `` "" |
| 40 | .ie t .ds '' '' |
| 41 | .el .ds '' "" |
| 42 | .\} |
| 43 | . |
| 44 | .de bP |
| 45 | .ie n .IP \(bu 4 |
| 46 | .el .IP \(bu 2 |
| 47 | .. |
| 48 | .\" --------------------------------------------------------------------------- |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 50 | \fB\%attr_get\fP, |
| 51 | \fB\%wattr_get\fP, |
| 52 | \fB\%attr_set\fP, |
| 53 | \fB\%wattr_set\fP, |
| 54 | \fB\%attr_off\fP, |
| 55 | \fB\%wattr_off\fP, |
| 56 | \fB\%attr_on\fP, |
| 57 | \fB\%wattr_on\fP, |
| 58 | \fB\%attroff\fP, |
| 59 | \fB\%wattroff\fP, |
| 60 | \fB\%attron\fP, |
| 61 | \fB\%wattron\fP, |
| 62 | \fB\%attrset\fP, |
| 63 | \fB\%wattrset\fP, |
| 64 | \fB\%chgat\fP, |
| 65 | \fB\%wchgat\fP, |
| 66 | \fB\%mvchgat\fP, |
| 67 | \fB\%mvwchgat\fP, |
| 68 | \fB\%color_set\fP, |
| 69 | \fB\%wcolor_set\fP, |
| 70 | \fB\%standend\fP, |
| 71 | \fB\%wstandend\fP, |
| 72 | \fB\%standout\fP, |
| 73 | \fB\%wstandout\fP \- |
| 74 | manipulate attributes of character cells in \fIcurses\fR windows |
| 75 | .\" --------------------------------------------------------------------------- |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 76 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 77 | .nf |
| 78 | \fB#include <curses.h> |
| 79 | .PP |
| 80 | \fBint attr_get(attr_t *\fIattrs\fP, short *\fIpair\fP, void *\fIopts\fP); |
| 81 | \fBint wattr_get(WINDOW *\fIwin\fP, attr_t *\fIattrs\fP, short *\fIpair\fP,\fR \fPvoid *\fIopts\fP); |
| 82 | \fBint attr_set(attr_t \fIattrs\fP, short \fIpair\fP, void *\fIopts\fP); |
| 83 | \fBint wattr_set(WINDOW *\fIwin\fP, attr_t \fIattrs\fP, short \fIpair\fP, void *\fIopts\fP); |
| 84 | .PP |
| 85 | \fBint attr_off(attr_t \fIattrs\fP, void *\fIopts\fP); |
| 86 | \fBint wattr_off(WINDOW *\fIwin\fP, attr_t \fIattrs\fP, void *\fIopts\fP); |
| 87 | \fBint attr_on(attr_t \fIattrs\fP, void *\fIopts\fP); |
| 88 | \fBint wattr_on(WINDOW *\fIwin\fP, attr_t \fIattrs\fP, void *\fIopts\fP); |
| 89 | .PP |
| 90 | \fBint attroff(int \fIattrs\fP); |
| 91 | \fBint wattroff(WINDOW *\fIwin\fP, int \fIattrs\fP); |
| 92 | \fBint attron(int \fIattrs\fP); |
| 93 | \fBint wattron(WINDOW *\fIwin\fP, int \fIattrs\fP); |
| 94 | \fBint attrset(int \fIattrs\fP); |
| 95 | \fBint wattrset(WINDOW *\fIwin\fP, int \fIattrs\fP); |
| 96 | .PP |
| 97 | \fBint chgat(int \fIn\fP, attr_t \fIattr\fP, short \fIpair\fP,\fR \fPconst void *\fIopts\fP); |
| 98 | \fBint wchgat(WINDOW *\fIwin\fP, |
| 99 | \fBint \fIn\fB, attr_t \fIattr\fB,\fR \fBshort \fIpair\fB, const void *\fIopts\fB);\fR |
| 100 | \fBint mvchgat(int \fIy\fB, int \fIx\fB,\fR |
| 101 | \fBint \fIn\fB, attr_t \fIattr\fB, short \fIpair\fB, const void *\fIopts\fB);\fR |
| 102 | \fBint mvwchgat(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB,\fR |
| 103 | \fBint \fIn\fB, attr_t \fIattr\fB, short \fIpair\fB, const void *\fIopts\fB);\fR |
| 104 | .PP |
| 105 | \fBint color_set(short \fIpair\fB, void* \fIopts\fB);\fR |
| 106 | \fBint wcolor_set(WINDOW *\fIwin\fB, short \fIpair\fB,\fR \fBvoid* \fIopts\fP);\fR |
| 107 | .PP |
| 108 | \fBint standend(void);\fP |
| 109 | \fBint wstandend(WINDOW *\fIwin\fB);\fR |
| 110 | \fBint standout(void);\fP |
| 111 | \fBint wstandout(WINDOW *\fIwin\fB);\fR |
| 112 | .fi |
| 113 | .\" --------------------------------------------------------------------------- |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 115 | These routines manipulate the current attributes of the named window, |
| 116 | which then apply to all characters that are written into |
| 117 | the window with \fBwaddch\fP, \fBwaddstr\fP and \fBwprintw\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 118 | Attributes are |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 119 | a property of the character, and move with the character through any scrolling |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 120 | and insert/delete line/character operations. |
| 121 | To the extent possible, they are |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 122 | displayed as appropriate modifications to the graphic rendition of characters |
| 123 | put on the screen. |
| 124 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 125 | These routines do not affect the attributes used |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 126 | when erasing portions of the window. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 127 | See \fBcurs_bkgd\fP(3X) for functions which modify the attributes used for |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 128 | erasing and clearing. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 129 | .\" --------------------------------------------------------------------------- |
| 130 | .SS "Window Attributes" |
| 131 | There are two sets of functions: |
| 132 | .bP |
| 133 | functions for manipulating the window attributes and color: |
| 134 | \fBwattr_set\fP and \fBwattr_get\fP. |
| 135 | .bP |
| 136 | functions for manipulating only the window attributes (not color): |
| 137 | \fBwattr_on\fP and \fBwattr_off\fP. |
| 138 | .PP |
| 139 | The \fBwattr_set\fP function sets the current attributes |
| 140 | of the given window to \fIattrs\fP, with color specified by \fIpair\fP. |
| 141 | .PP |
| 142 | Use \fBwattr_get\fP to retrieve attributes for the given window. |
| 143 | .PP |
| 144 | Use \fBattr_on\fP and \fBwattr_on\fP to turn on window attributes, i.e., |
| 145 | values OR'd together in \fIattr\fP, |
| 146 | without affecting other attributes. |
| 147 | Use \fBattr_off\fP and \fBwattr_off\fP to turn off window attributes, |
| 148 | again values OR'd together in \fIattr\fP, |
| 149 | without affecting other attributes. |
| 150 | .\" --------------------------------------------------------------------------- |
| 151 | .SS "Legacy Window Attributes" |
| 152 | The X/Open window attribute routines which \fIset\fP or \fIget\fP, |
| 153 | turn \fIon\fP or \fIoff\fP |
| 154 | are extensions of older routines |
| 155 | which assume that color pairs are OR'd into the attribute parameter. |
| 156 | These newer routines use similar names, because |
| 157 | X/Open simply added an underscore (\fB_\fP) for the newer names. |
| 158 | .PP |
| 159 | The \fBint\fP datatype used in the legacy routines is treated as if |
| 160 | it is the same size as \fBchtype\fP (used by \fBaddch\fP(3X)). |
| 161 | It holds the common video attributes (such as bold, reverse), |
| 162 | as well as a few bits for color. |
| 163 | Those bits correspond to the \fBA_COLOR\fP symbol. |
| 164 | The \fBCOLOR_PAIR\fP macro provides a value which can be OR'd into |
| 165 | the attribute parameter. |
| 166 | For example, |
| 167 | as long as that value fits into the \fBA_COLOR\fP mask, |
| 168 | then these calls produce similar results: |
| 169 | .PP |
| 170 | .RS 4 |
| 171 | .EX |
| 172 | attrset(A_BOLD | COLOR_PAIR(\fIpair\fP)); |
| 173 | attr_set(A_BOLD, \fIpair\fP, NULL); |
| 174 | .EE |
| 175 | .RE |
| 176 | .PP |
| 177 | However, if the value does not fit, then the \fBCOLOR_PAIR\fP macro |
| 178 | uses only the bits that fit. |
| 179 | For example, |
| 180 | because in \fI\%ncurses\fP \fBA_COLOR\fP has eight (8) bits, |
| 181 | then \fBCOLOR_PAIR(\fI259\fB)\fR is 4 |
| 182 | (i.e., 259 is 4 more than the limit 255). |
| 183 | .PP |
| 184 | The \fBPAIR_NUMBER\fP macro extracts a pair number from an \fBint\fP |
| 185 | (or \fBchtype\fP). |
| 186 | For example, the \fIinput\fP and \fIoutput\fP values in these statements |
| 187 | would be the same: |
| 188 | .PP |
| 189 | .RS 4 |
| 190 | .EX |
| 191 | int value = A_BOLD | COLOR_PAIR(\fIinput\fP); |
| 192 | int \fIoutput\fP = PAIR_NUMBER(value); |
| 193 | .EE |
| 194 | .RE |
| 195 | .PP |
| 196 | The \fBattrset\fP routine is a legacy feature predating SVr4 curses |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 197 | but kept in X/Open Curses for the same reason that SVr4 curses kept it: |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 198 | compatibility. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 199 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 200 | The remaining \fBattr\fP* functions operate exactly like the corresponding |
| 201 | \fBattr_\fP* functions, except that they take arguments of type \fBint\fP |
| 202 | rather than \fBattr_t\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 203 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 204 | There is no corresponding \fB\%attrget\fP function as such |
| 205 | in X/Open Curses, |
| 206 | although \fI\%ncurses\fP provides \fB\%getattrs\fP |
| 207 | (see \fB\%curs_legacy\fP(3X)). |
| 208 | .\" --------------------------------------------------------------------------- |
| 209 | .SS "Change Character Rendition" |
| 210 | The routine \fBchgat\fP changes the attributes of a given number of characters |
| 211 | starting at the current cursor location of \fBstdscr\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 212 | It does not update |
| 213 | the cursor and does not perform wrapping. |
| 214 | A character count of \-1 or greater |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 215 | than the remaining window width means to change attributes all the way to the |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 216 | end of the current line. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 217 | The \fBwchgat\fP function generalizes this to any window; |
| 218 | the \fBmvwchgat\fP function does a cursor move before acting. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 219 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 220 | In these functions, |
| 221 | the color \fIpair\fP argument is a color pair index |
| 222 | (as in the first argument of \fBinit_pair\fP, see \fBcurs_color\fP(3X)). |
| 223 | .\" --------------------------------------------------------------------------- |
| 224 | .SS "Change Window Color" |
| 225 | The routine \fBcolor_set\fP sets the current color of the given window to the |
| 226 | foreground/background combination described by the color \fIpair\fP parameter. |
| 227 | .\" --------------------------------------------------------------------------- |
| 228 | .SS Standout |
| 229 | The routine \fBstandout\fP is |
| 230 | the same as \fBattron(A_STANDOUT)\fP. |
| 231 | The routine \fBstandend\fP is the same |
| 232 | as \fBattrset(A_NORMAL)\fP or \fBattrset(0)\fP, that is, it turns off all |
| 233 | attributes. |
| 234 | .PP |
| 235 | X/Open Curses does not mark these \*(``restricted\*('', because |
| 236 | .bP |
| 237 | they have well established legacy use, and |
| 238 | .bP |
| 239 | there is no ambiguity about the way the attributes |
| 240 | might be combined with a color pair. |
| 241 | .\" --------------------------------------------------------------------------- |
| 242 | .SS "Video Attributes" |
| 243 | The following video attributes, defined in \fB<curses.h>\fP, can be passed to |
| 244 | the routines \fBattron\fP, \fBattroff\fP, and \fBattrset\fP, or OR'd with the |
| 245 | characters passed to \fBaddch\fP (see \fBcurs_addch\fP(3X)). |
| 246 | .PP |
| 247 | .ne 15 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 248 | .RS |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 249 | .TS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 250 | Lb Lb |
| 251 | Lb Lx. |
| 252 | Name Description |
| 253 | _ |
| 254 | A_NORMAL Normal display (no highlight) |
| 255 | A_STANDOUT T{ |
| 256 | Best highlighting mode of the terminal |
| 257 | T} |
| 258 | A_UNDERLINE Underlining |
| 259 | A_REVERSE Reverse video |
| 260 | A_BLINK Blinking |
| 261 | A_DIM Half bright |
| 262 | A_BOLD Extra bright or bold |
| 263 | A_PROTECT Protected mode |
| 264 | A_INVIS Invisible or blank mode |
| 265 | A_ALTCHARSET Alternate character set |
| 266 | A_ITALIC Italics (non-X/Open extension) |
| 267 | A_CHARTEXT Bit-mask to extract a character |
| 268 | A_COLOR T{ |
| 269 | Bit-mask to extract a color (legacy routines) |
| 270 | T} |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 271 | .TE |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 272 | .RE |
| 273 | .PP |
| 274 | These video attributes are supported by \fBattr_on\fP and related functions |
| 275 | (which also support the attributes recognized by \fBattron\fP, etc.): |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 276 | .PP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 277 | .RS |
| 278 | .TS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 279 | Lb Lb |
| 280 | Lb Lx. |
| 281 | Name Description |
| 282 | _ |
| 283 | WA_HORIZONTAL Horizontal highlight |
| 284 | WA_LEFT Left highlight |
| 285 | WA_LOW Low highlight |
| 286 | WA_RIGHT Right highlight |
| 287 | WA_TOP Top highlight |
| 288 | WA_VERTICAL Vertical highlight |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 289 | .TE |
| 290 | .RE |
| 291 | .PP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 292 | The return values of many of these routines are not meaningful (they are |
| 293 | implemented as macro-expanded assignments and simply return their argument). |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 294 | The SVr4 manual page claims (falsely) that these routines always return \fB1\fP. |
| 295 | .\" --------------------------------------------------------------------------- |
| 296 | .SH RETURN VALUE |
| 297 | All routines return the integer \fBOK\fP on success, or \fBERR\fP on failure. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 298 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 299 | X/Open Curses does not specify any error conditions. |
| 300 | .PP |
| 301 | This implementation |
| 302 | .bP |
| 303 | returns an error if the window pointer is null. |
| 304 | .bP |
| 305 | returns an error if the color pair parameter |
| 306 | for \fBwcolor_set\fP is outside the range 0..COLOR_PAIRS\-1. |
| 307 | .bP |
| 308 | does not return an error if either of the parameters of \fBwattr_get\fP |
| 309 | used for retrieving attribute or color pair values is \fBNULL\fP. |
| 310 | .PP |
| 311 | Functions prefixed with \*(``mv\*('' first perform cursor movement and |
| 312 | fail if the position |
| 313 | .RI ( y , |
| 314 | .IR x ) |
| 315 | is outside the window boundaries. |
| 316 | .\" --------------------------------------------------------------------------- |
| 317 | .SH NOTES |
| 318 | These functions may be macros: |
| 319 | .sp |
| 320 | .RS |
| 321 | \fBattroff\fP, \fBwattroff\fP, \fBattron\fP, \fBwattron\fP, |
| 322 | \fBattrset\fP, \fBwattrset\fP, \fBstandend\fP and \fBstandout\fP. |
| 323 | .RE |
| 324 | .PP |
| 325 | Color pair values can only be OR'd with attributes if the pair |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 326 | number is less than 256. |
| 327 | The alternate functions such as \fBcolor_set\fP can pass a color pair |
| 328 | value directly. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 329 | However, \fI\%ncurses\fP ABI 4 and 5 simply OR this value |
| 330 | within the alternate functions. |
| 331 | You must use \fI\%ncurses\fP ABI 6 to support more than 256 color pairs. |
| 332 | .\" --------------------------------------------------------------------------- |
| 333 | .SH EXTENSIONS |
| 334 | This implementation provides the \fBA_ITALIC\fP attribute for terminals |
| 335 | which have the \fBenter_italics_mode\fP (\fBsitm\fP) |
| 336 | and \fBexit_italics_mode\fP (\fBritm\fP) capabilities. |
| 337 | Italics are not mentioned in X/Open Curses. |
| 338 | Unlike the other video attributes, \fBA_ITALIC\fP is unrelated |
| 339 | to the \fBset_attributes\fP capabilities. |
| 340 | This implementation makes the assumption that |
| 341 | \fBexit_attribute_mode\fP may also reset italics. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 342 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 343 | Each of the functions added by XSI Curses has a parameter \fIopts\fP, |
| 344 | which X/Open Curses still (after more than twenty years) documents |
| 345 | as reserved for future use, saying that it should be \fBNULL\fP. |
| 346 | This implementation uses that parameter in ABI 6 for the functions which |
| 347 | have a color pair parameter to support \fIextended color pairs\fP: |
| 348 | .bP |
| 349 | For functions which modify the color, e.g., |
| 350 | \fBwattr_set\fP and \fBwattr_on\fP, |
| 351 | if \fIopts\fP is set it is treated as a pointer to \fBint\fP, |
| 352 | and used to set the color pair instead of the \fBshort\fP \fIpair\fP parameter. |
| 353 | .bP |
| 354 | For functions which retrieve the color, e.g., |
| 355 | \fBwattr_get\fP, |
| 356 | if \fIopts\fP is set it is treated as a pointer to \fBint\fP, |
| 357 | and used to retrieve the color pair as an \fBint\fP value, |
| 358 | in addition to |
| 359 | retrieving it via the standard pointer to \fBshort\fP parameter. |
| 360 | .bP |
| 361 | For functions which turn attributes off, e.g., |
| 362 | \fBwattr_off\fP, |
| 363 | the \fIopts\fP parameter is ignored except |
| 364 | except to check that it is \fBNULL\fP. |
| 365 | .\" --------------------------------------------------------------------------- |
| 366 | .SH PORTABILITY |
| 367 | These functions are described in X/Open Curses, Issue 4. |
| 368 | The standard defined the dedicated type for highlights, |
| 369 | \fBattr_t\fP, which was not defined in SVr4 curses. |
| 370 | The functions taking \fBattr_t\fP arguments were not supported under SVr4. |
| 371 | .PP |
| 372 | Very old versions of this library did not force an update of the screen |
| 373 | when changing the attributes. |
| 374 | Use \fBtouchwin\fP to force the screen to match the updated attributes. |
| 375 | .PP |
| 376 | X/Open Curses states that whether the traditional functions |
| 377 | \fBattron\fP/\fBattroff\fP/\fBattrset\fP can manipulate attributes other than |
| 378 | \fBA_BLINK\fP, \fBA_BOLD\fP, \fBA_DIM\fP, \fBA_REVERSE\fP, \fBA_STANDOUT\fP, or |
| 379 | \fBA_UNDERLINE\fP is \*(``unspecified\*(''. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 380 | Under this implementation as well as |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 381 | SVr4 curses, these functions correctly manipulate all other highlights |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 382 | (specifically, \fBA_ALTCHARSET\fP, \fBA_PROTECT\fP, and \fBA_INVIS\fP). |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 383 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 384 | X/Open Curses added these entry points: |
| 385 | .sp |
| 386 | .RS |
| 387 | \fBattr_get\fP, \fBattr_on\fP, |
| 388 | \fBattr_off\fP, \fBattr_set\fP, \fBwattr_on\fP, \fBwattr_off\fP, |
| 389 | \fBwattr_get\fP, \fBwattr_set\fP |
| 390 | .RE |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 391 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 392 | The new functions are intended to work with |
| 393 | a new series of highlight macros prefixed with \fBWA_\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 394 | The older macros have direct counterparts in the newer set of names: |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 395 | .PP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 396 | .RS |
| 397 | .ne 9 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 398 | .TS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 399 | Lb Lb |
| 400 | Lb Lx. |
| 401 | Name Description |
| 402 | _ |
| 403 | WA_NORMAL Normal display (no highlight) |
| 404 | WA_STANDOUT T{ |
| 405 | Best highlighting mode of the terminal |
| 406 | T} |
| 407 | WA_UNDERLINE Underlining |
| 408 | WA_REVERSE Reverse video |
| 409 | WA_BLINK Blinking |
| 410 | WA_DIM Half bright |
| 411 | WA_BOLD Extra bright or bold |
| 412 | WA_ALTCHARSET Alternate character set |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 413 | .TE |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 414 | .RE |
| 415 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 416 | X/Open Curses does not assign values to these symbols, |
| 417 | nor does it state whether or not they are related to the |
| 418 | similarly-named A_NORMAL, etc.: |
| 419 | .bP |
| 420 | X/Open Curses specifies that each pair of corresponding \fBA_\fP |
| 421 | and \fBWA_\fP-using functions operates on the same current-highlight |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 422 | information. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 423 | .bP |
| 424 | However, in some implementations, those symbols have unrelated values. |
| 425 | .IP |
| 426 | For example, the Solaris \fIxpg4\fP (X/Open) curses declares |
| 427 | \fBattr_t\fP to be an unsigned short integer (16-bits), |
| 428 | while \fBchtype\fP is a unsigned integer (32-bits). |
| 429 | The \fBWA_\fP symbols in this case are different from the \fBA_\fP symbols |
| 430 | because they are used for a smaller datatype which does not |
| 431 | represent \fBA_CHARTEXT\fP or \fBA_COLOR\fP. |
| 432 | .IP |
| 433 | In this implementation (as in many others), the values happen to be |
| 434 | the same because it simplifies copying information between |
| 435 | \fBchtype\fP and \fBcchar_t\fP variables. |
| 436 | .bP |
| 437 | Because \fI\%ncurses\fP's \fBattr_t\fP can hold a color pair |
| 438 | (in the \fBA_COLOR\fP field), |
| 439 | a call to |
| 440 | \fBwattr_on\fP, |
| 441 | \fBwattr_off\fP, or |
| 442 | \fBwattr_set\fP |
| 443 | may alter the window's color. |
| 444 | If the color pair information in the attribute parameter is zero, |
| 445 | no change is made to the window's color. |
| 446 | .IP |
| 447 | This is consistent with SVr4 curses; |
| 448 | X/Open Curses does not specify this. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 449 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 450 | The X/Open Curses extended conformance level adds new highlights |
| 451 | \fBA_HORIZONTAL\fP, \fBA_LEFT\fP, \fBA_LOW\fP, \fBA_RIGHT\fP, \fBA_TOP\fP, |
| 452 | \fBA_VERTICAL\fP (and corresponding \fBWA_\fP macros for each). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 453 | As of August 2013, |
| 454 | no known terminal provides these highlights |
| 455 | (i.e., via the \fBsgr1\fP capability). |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 456 | .\" --------------------------------------------------------------------------- |
| 457 | .SH HISTORY |
| 458 | X/Open Curses is largely based on SVr4 curses, |
| 459 | adding support for \*(``wide-characters\*('' (not specific to Unicode). |
| 460 | Some of the X/Open differences from SVr4 curses address the way |
| 461 | video attributes can be applied to wide-characters. |
| 462 | But aside from that, \fBattrset\fP and \fBattr_set\fP are similar. |
| 463 | SVr4 curses provided the basic features for manipulating video attributes. |
| 464 | However, earlier versions of curses provided a part of these features. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 465 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 466 | As seen in 2.8BSD, curses assumed 7-bit characters, |
| 467 | using the eighth bit of a byte to represent the \fIstandout\fP |
| 468 | feature (often implemented as bold and/or reverse video). |
| 469 | The BSD curses library provided functions \fBstandout\fP and \fBstandend\fP |
| 470 | which were carried along into X/Open Curses due to their pervasive use |
| 471 | in legacy applications. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 472 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 473 | Some terminals in the 1980s could support a variety of video attributes, |
| 474 | although the BSD curses library could do nothing with those. |
| 475 | System V (1983) provided an improved curses library. |
| 476 | It defined the \fBA_\fP symbols for use by applications to manipulate the |
| 477 | other attributes. |
| 478 | There are few useful references for the chronology. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 479 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 480 | Goodheart's book |
| 481 | \fIUNIX Curses Explained\fP (1991) describes SVr3 (1987), |
| 482 | commenting on several functions: |
| 483 | .bP |
| 484 | the \fBattron\fP, \fBattroff\fP, \fBattrset\fP functions |
| 485 | (and most of the functions found in SVr4 but not in BSD curses) were |
| 486 | introduced by System V, |
| 487 | .bP |
| 488 | the alternate character set feature with \fBA_ALTCHARSET\fP was |
| 489 | added in SVr2 and improved in SVr3 (by adding \fBacs_map[]\fP), |
| 490 | .bP |
| 491 | \fBstart_color\fP and related color-functions were introduced by System V.3.2, |
| 492 | .bP |
| 493 | pads, soft-keys were added in SVr3, and |
| 494 | .PP |
| 495 | Goodheart did not mention the background character or the \fBcchar_t\fP type. |
| 496 | Those are respectively SVr4 and X/Open features. |
| 497 | He did mention the \fBA_\fP constants, but did not indicate their values. |
| 498 | Those were not the same in different systems, |
| 499 | even for those marked as System V. |
| 500 | .PP |
| 501 | Different Unix systems used different sizes for the bit-fields in \fBchtype\fP |
| 502 | for \fIcharacters\fP and \fIcolors\fP, and took into account the different |
| 503 | integer sizes (32-bit versus 64-bit). |
| 504 | .PP |
| 505 | This table showing the number of bits for \fBA_COLOR\fP |
| 506 | and \fBA_CHARTEXT\fP |
| 507 | was gleaned from the curses header files for |
| 508 | various operating systems and architectures. |
| 509 | The inferred architecture and notes reflect |
| 510 | the format and size of the defined constants |
| 511 | as well as clues such as the alternate character set implementation. |
| 512 | A 32-bit library can be used on a 64-bit system, |
| 513 | but not necessarily the reverse. |
| 514 | .PP |
| 515 | .TS |
| 516 | Lb Lb Lb Cb S Lb |
| 517 | Lb2 Lb Lb2 Lb2 Lb2 Lb |
| 518 | L L L L L Lx. |
| 519 | \& \& \& Bits \& |
| 520 | Year System Arch Color Char Notes |
| 521 | _ |
| 522 | 1992 Solaris 5.2 32 6 17 SVr4 \fIcurses\fP |
| 523 | 1992 HP-UX 9 32 no 8 SVr2 \fIcurses\fP |
| 524 | 1992 AIX 3.2 32 no 23 SVr2 \fIcurses\fP |
| 525 | 1994 OSF/1 r3 32 no 23 SVr2 \fIcurses\fP |
| 526 | 1995 HP-UX 10.00 32 6 16 SVr3 \fIcurses_colr\fP |
| 527 | 1995 HP-UX 10.00 32 6 8 SVr4, X/Open \fIcurses\fP |
| 528 | 1995 Solaris 5.4 32/64 7 16 X/Open \fIcurses\fP |
| 529 | 1996 AIX 4.2 32 7 16 X/Open \fIcurses\fP |
| 530 | 1996 OSF/1 r4 32 6 16 X/Open \fIcurses\fP |
| 531 | 1997 HP-UX 11.00 32 6 8 X/Open \fIcurses\fP |
| 532 | 2000 U/Win 32/64 7/31 16 uses \fIchtype\fP |
| 533 | .TE |
| 534 | .PP |
| 535 | Notes: |
| 536 | .RS 3 |
| 537 | .PP |
| 538 | Regarding HP-UX, |
| 539 | .bP |
| 540 | HP-UX 10.20 (1996) added support for 64-bit PA-RISC processors in 1996. |
| 541 | .bP |
| 542 | HP-UX 10.30 (1997) marked \*(``curses_colr\*('' obsolete. |
| 543 | That version of curses was dropped with HP-UX 11.30 in 2006. |
| 544 | .PP |
| 545 | Regarding OSF/1 (and Tru64), |
| 546 | .bP |
| 547 | These used 64-bit hardware. |
| 548 | Like \fI\%ncurses\fP, |
| 549 | the OSF/1 curses interface is not customized for 32-bit and 64-bit |
| 550 | versions. |
| 551 | .bP |
| 552 | Unlike other systems which evolved from AT&T code, |
| 553 | OSF/1 provided a new implementation for X/Open curses. |
| 554 | .PP |
| 555 | Regarding Solaris, |
| 556 | .bP |
| 557 | The initial release of Solaris was in 1992. |
| 558 | .bP |
| 559 | The \fIxpg4\fP (X/Open) curses was developed by MKS from 1990 to 1995. |
| 560 | Sun's copyright began in 1996. |
| 561 | .bP |
| 562 | Sun updated the X/Open curses interface |
| 563 | after 64-bit support was introduced in 1997, |
| 564 | but did not modify the SVr4 curses interface. |
| 565 | .PP |
| 566 | Regarding U/Win, |
| 567 | .bP |
| 568 | Development of the curses library began in 1991, stopped in 2000. |
| 569 | .bP |
| 570 | Color support was added in 1998. |
| 571 | .bP |
| 572 | The library uses only \fBchtype\fP (no \fBcchar_t\fP). |
| 573 | .RE |
| 574 | .PP |
| 575 | Once X/Open curses was adopted in the mid-1990s, the constraint of |
| 576 | a 32-bit interface with many colors and wide-characters for \fBchtype\fP |
| 577 | became a moot point. |
| 578 | The \fBcchar_t\fP structure (whose size and |
| 579 | members are not specified in X/Open Curses) could be extended as needed. |
| 580 | .PP |
| 581 | Other interfaces are rarely used now: |
| 582 | .bP |
| 583 | BSD curses was improved slightly in 1993/1994 using Keith Bostic's |
| 584 | modification to make the library 8-bit clean for \fBnvi\fP(1). |
| 585 | He moved \fIstandout\fP attribute to a structure member. |
| 586 | .IP |
| 587 | The resulting 4.4BSD curses was replaced by \fI\%ncurses\fP over the |
| 588 | next ten years. |
| 589 | .bP |
| 590 | U/Win is rarely used now. |
| 591 | .\" --------------------------------------------------------------------------- |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 592 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 593 | \fB\%curses\fP(3X), |
| 594 | \fB\%curs_addch\fP(3X), |
| 595 | \fB\%curs_addstr\fP(3X), |
| 596 | \fB\%curs_bkgd\fP(3X), |
| 597 | \fB\%curs_printw\fP(3X), |
| 598 | \fB\%curs_variables\fP(3X) |