]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_attr.3x
ncurses 6.0 - patch 20170916
[ncurses.git] / man / curs_attr.3x
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
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 .\"
30 .\" $Id: curs_attr.3x,v 1.53 2017/03/28 23:31:39 tom Exp $
31 .TH curs_attr 3X ""
32 .de bP
33 .IP \(bu 4
34 ..
35 .na
36 .hy 0
37 .SH NAME
38 .\" attr_get
39 \fBattr_get\fR,
40 \fBwattr_get\fR,
41 \fBattr_set\fR,
42 \fBwattr_set\fR,
43 .\" .br
44 \fBattr_off\fR,
45 \fBwattr_off\fR,
46 \fBattr_on\fR,
47 \fBwattr_on\fR,
48 .\" .br
49 \fBattroff\fR,
50 \fBwattroff\fR,
51 \fBattron\fR,
52 \fBwattron\fR,
53 \fBattrset\fR,
54 \fBwattrset\fR,
55 .\" .br
56 \fBchgat\fR,
57 \fBwchgat\fR,
58 \fBmvchgat\fR,
59 \fBmvwchgat\fR,
60 .\" .br
61 \fBcolor_set\fR,
62 \fBwcolor_set\fR,
63 .\" .br
64 \fBstandend\fR,
65 \fBwstandend\fR,
66 \fBstandout\fR,
67 \fBwstandout\fR \- \fBcurses\fR character and window attribute control routines
68 .ad
69 .hy
70 .SH SYNOPSIS
71 \fB#include <curses.h>\fR
72 .sp
73 \fBint attr_get(attr_t *\fP\fIattrs\fP\fB, short *\fP\fIpair\fP\fB, void *\fP\fIopts\fP\fB);\fR
74 .br
75 \fBint wattr_get(WINDOW *\fP\fIwin\fP\fB, attr_t *\fP\fIattrs\fP\fB, short *\fP\fIpair\fP\fB,\fR \fBvoid *\fP\fIopts\fP\fB);\fR
76 .br
77 \fBint attr_set(attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void *\fP\fIopts\fP\fB);\fR
78 .br
79 \fBint wattr_set(WINDOW *\fP\fIwin\fP\fB, attr_t \fP\fIattrs\fP\fB, short \fP\fIpair\fP\fB, void *\fP\fIopts\fP\fB);\fR
80 .sp
81 \fBint attr_off(attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
82 .br
83 \fBint wattr_off(WINDOW *\fP\fIwin\fP\fB, attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
84 .br
85 \fBint attr_on(attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
86 .br
87 \fBint wattr_on(WINDOW *\fP\fIwin\fP\fB, attr_t \fP\fIattrs\fP\fB, void *\fP\fIopts\fP\fB);\fR
88 .sp
89 \fBint attroff(int \fP\fIattrs);\fR
90 .br
91 \fBint wattroff(WINDOW *\fP\fIwin\fP\fB, int \fP\fIattrs\fP\fB);\fR
92 .br
93 \fBint attron(int \fP\fIattrs\fP\fB);\fR
94 .br
95 \fBint wattron(WINDOW *\fP\fIwin\fP\fB, int \fP\fIattrs\fP\fB);\fR
96 .br
97 \fBint attrset(int \fP\fIattrs\fP\fB);\fR
98 .br
99 \fBint wattrset(WINDOW *\fP\fIwin\fP\fB, int \fP\fIattrs\fP\fB);\fR
100 .sp
101 \fBint chgat(int \fP\fIn\fP\fB, attr_t \fP\fIattr\fP\fB, short \fP\fIpair\fP\fB,\fR \fBconst void *\fP\fIopts\fP\fB);\fR
102 .br
103 \fBint wchgat(WINDOW *\fP\fIwin\fP\fB,\fP
104       \fBint \fP\fIn\fP\fB, attr_t \fP\fIattr\fP\fB,\fR \fBshort \fP\fIpair\fP\fB, const void *\fP\fIopts\fP\fB);\fR
105 .br
106 \fBint mvchgat(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB,\fP
107       \fBint \fP\fIn\fP\fB, attr_t \fP\fIattr\fP\fB,\fR \fBshort \fP\fIpair\fP\fB, const void *\fP\fIopts\fP\fB);\fR
108 .br
109 \fBint mvwchgat(WINDOW *\fP\fIwin, int \fP\fIy, int \fP\fIx\fP\fB,\fP
110       \fBint \fP\fIn,\fR \fBattr_t \fP\fIattr\fP\fB, short \fP\fIpair\fP\fB, const void *\fP\fIopts\fP\fB);\fR
111 .sp
112 \fBint color_set(short \fP\fIpair\fP\fB, void* \fP\fIopts\fP\fB);\fR
113 .br
114 \fBint wcolor_set(WINDOW *\fP\fIwin\fP\fB, short \fP\fIpair\fP\fB,\fR \fBvoid* \fP\fIopts);\fR
115 .sp
116 \fBint standend(void);\fR
117 .br
118 \fBint wstandend(WINDOW *\fP\fIwin\fP\fB);\fR
119 .br
120 \fBint standout(void);\fR
121 .br
122 \fBint wstandout(WINDOW *\fP\fIwin\fP\fB);\fR
123 .SH DESCRIPTION
124 .PP
125 These routines manipulate the current attributes of the named window,
126 which then apply to all characters that are written into
127 the window with \fBwaddch\fR, \fBwaddstr\fR and \fBwprintw\fR.
128 Attributes are
129 a property of the character, and move with the character through any scrolling
130 and insert/delete line/character operations.
131 To the extent possible, they are
132 displayed as appropriate modifications to the graphic rendition of characters
133 put on the screen.
134 .PP
135 These routines do not affect the attributes used
136 when erasing portions of the window.
137 See \fBcurs_bkgd\fR(3X) for functions which modify the attributes used for
138 erasing and clearing.
139 .PP
140 Routines which do not have a \fBWINDOW*\fP parameter apply to \fBstdscr\fP.
141 For example,
142 \fBattr_set\fP is the \fBstdscr\fP variant of \fBwattr_set\fP.
143 .\" ---------------------------------------------------------------------------
144 .SS Window attributes
145 .PP
146 There are two sets of functions:
147 .bP
148 functions for manipulating the window attributes and color:
149 \fBwattr_set\fP and \fBwattr_get\fP.
150 .bP
151 functions for manipulating only the window attributes (not color):
152 \fBwattr_on\fP and \fBwattr_off\fP.
153 .PP
154 The \fBwattr_set\fP function sets the current attributes
155 of the given window to \fIattrs\fP, with color specified by \fIpair\fP.
156 .PP
157 Use \fBwattr_get\fP to retrieve attributes for the given window.
158 .PP
159 Use \fBattr_on\fP and \fBwattr_on\fP to turn on window attributes, i.e.,
160 values OR'd together in \fIattr\fP,
161 without affecting other attributes.
162 Use \fBattr_off\fP and \fBwattr_off\fP to turn off window attributes,
163 again values OR'd together in \fIattr\fP,
164 without affecting other attributes.
165 .\" ---------------------------------------------------------------------------
166 .SS Legacy window attributes
167 Most of the window attribute routines are extensions of older routines
168 which assume that color pairs are OR'd into the attribute parameter.
169 These older routines use the same name, omitting an underscore (\fB_\fP).
170
171 The \fBattrset\fP routine is a legacy feature predating SVr4 curses
172 but kept in X/Open Curses for the same reason that SVr4 curses kept it:
173 compatibility.
174 .PP
175 The remaining \fBattr\fR* functions operate exactly like the corresponding
176 \fBattr_\fR* functions, except that they take arguments of type \fBint\fR
177 rather than \fBattr_t\fR.
178 .PP
179 There is no corresponding \fBattrget\fP function as such in X/Open Curses,
180 although ncurses provides \fBgetattrs\fP (see curs_legacy(3X)).
181 .\" ---------------------------------------------------------------------------
182 .SS Change character rendition
183 .PP
184 The routine \fBchgat\fR changes the attributes of a given number of characters
185 starting at the current cursor location of \fBstdscr\fR.
186 It does not update
187 the cursor and does not perform wrapping.
188 A character count of \-1 or greater
189 than the remaining window width means to change attributes all the way to the
190 end of the current line.
191 The \fBwchgat\fR function generalizes this to any window;
192 the \fBmvwchgat\fR function does a cursor move before acting.
193 .PP
194 In these functions,
195 the color \fIpair\fP argument is a color-pair index
196 (as in the first argument of \fBinit_pair\fR, see \fBcurs_color\fR(3X)).
197 .\" ---------------------------------------------------------------------------
198 .SS Change window color
199 The routine \fBcolor_set\fR sets the current color of the given window to the
200 foreground/background combination described by the color \fIpair\fP parameter.
201 .\" ---------------------------------------------------------------------------
202 .SS Standout
203 .PP
204 The routine \fBstandout\fR is
205 the same as \fBattron(A_STANDOUT)\fR.
206 The routine \fBstandend\fR is the same
207 as \fBattrset(A_NORMAL)\fR or \fBattrset(0)\fR, that is, it turns off all
208 attributes.
209 .PP
210 X/Open does not mark these "restricted", because
211 .bP
212 they have well established legacy use, and
213 .bP
214 there is no ambiguity about the way the attributes
215 might be combined with a color pair.
216 .\" ---------------------------------------------------------------------------
217 .SH VIDEO ATTRIBUTES
218 The following video attributes, defined in \fB<curses.h>\fR, can be passed to
219 the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR'd with the
220 characters passed to \fBaddch\fR (see \fBcurs_addch\fR(3X)).
221 .PP
222 .RS
223 .TS
224 l l
225 _ _ _
226 l l .
227 \fIName\fR      \fIDescription\fR
228 \fBA_NORMAL\fR  Normal display (no highlight)
229 \fBA_STANDOUT\fR        Best highlighting mode of the terminal.
230 \fBA_UNDERLINE\fR       Underlining
231 \fBA_REVERSE\fR Reverse video
232 \fBA_BLINK\fR   Blinking
233 \fBA_DIM\fR     Half bright
234 \fBA_BOLD\fR    Extra bright or bold
235 \fBA_PROTECT\fR Protected mode
236 \fBA_INVIS\fR   Invisible or blank mode
237 \fBA_ALTCHARSET\fR      Alternate character set
238 \fBA_ITALIC\fR  Italics (non-X/Open extension)
239 \fBA_CHARTEXT\fR        Bit-mask to extract a character
240 .TE
241 .RE
242 .PP
243 These video attributes are supported by \fBattr_on\fP and related functions
244 (which also support the attributes recognized by \fBattron\fP, etc.):
245 .RS
246 .TS
247 l l
248 _ _ _
249 l l .
250 \fIName\fR      \fIDescription\fR
251 \fBWA_HORIZONTAL\fR     Horizontal highlight
252 \fBWA_LEFT\fR   Left highlight
253 \fBWA_LOW\fR    Low highlight
254 \fBWA_RIGHT\fR  Right highlight
255 \fBWA_TOP\fR    Top highlight
256 \fBWA_VERTICAL\fR       Vertical highlight
257 .TE
258 .RE
259 .PP
260 The return values of many of these routines are not meaningful (they are
261 implemented as macro-expanded assignments and simply return their argument).
262 The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
263 .SH NOTES
264 These functions may be macros:
265 .sp
266 .RS
267 \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
268 \fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR.
269 .RE
270 .PP
271 Color pair values can only be OR'd with attributes if the pair
272 number is less than 256.
273 The alternate functions such as \fBcolor_set\fP can pass a color pair
274 value directly.
275 However, ncurses ABI 4 and 5 simply OR this value within the alternate functions.
276 You must use ncurses ABI 6 to support more than 256 color pairs.
277 .SH EXTENSIONS
278 .PP
279 This implementation provides the \fBA_ITALIC\fP attribute for terminals
280 which have the \fBenter_italics_mode\fP (\fBsitm\fP)
281 and \fBexit_italics_mode\fP (\fBritm\fP) capabilities.
282 Italics are not mentioned in X/Open Curses.
283 Unlike the other video attributes, \fBA_ITALIC\fP is unrelated
284 to the \fBset_attributes\fP capabilities.
285 This implementation makes the assumption that
286 \fBexit_attribute_mode\fP may also reset italics.
287 .PP
288 Each of the functions added by XSI Curses has a parameter \fIopts\fP,
289 which X/Open Curses still (after more than twenty years) documents
290 as reserved for future use, saying that it should be \fBNULL\fP.
291 This implementation uses that parameter in ABI 6 for the functions which
292 have a color-pair parameter to support \fIextended color pairs\fP:
293 .bP
294 For functions which modify the color, e.g.,
295 \fBwattr_set\fP,
296 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
297 and used to set the color pair instead of the \fBshort\fP \fIpair\fP parameter.
298 .bP
299 For functions which retrieve the color, e.g.,
300 \fBwattr_get\fP,
301 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
302 and used to retrieve the color pair as an \fBint\fP value,
303 in addition
304 retrieving it via the standard pointer to \fBshort\fP parameter.
305 .PP
306 The remaining functions which have \fIopts\fP,
307 but do not manipulate color,
308 e.g., \fBwattr_on\fP and \fBwattr_off\fP
309 are not used by this implementation except to check that they are \fBNULL\fP.
310 .SH PORTABILITY
311 These functions are supported in the XSI Curses standard, Issue 4.
312 The standard defined the dedicated type for highlights,
313 \fBattr_t\fR, which was not defined in SVr4 curses.
314 The functions taking \fBattr_t\fR arguments were not supported under SVr4.
315 .PP
316 Very old versions of this library did not force an update of the screen
317 when changing the attributes.
318 Use \fBtouchwin\fR to force the screen to match the updated attributes.
319 .PP
320 The XSI Curses standard states that whether the traditional functions
321 \fBattron\fR/\fBattroff\fR/\fBattrset\fR can manipulate attributes other than
322 \fBA_BLINK\fR, \fBA_BOLD\fR, \fBA_DIM\fR, \fBA_REVERSE\fR, \fBA_STANDOUT\fR, or
323 \fBA_UNDERLINE\fR is "unspecified".
324 Under this implementation as well as
325 SVr4 curses, these functions correctly manipulate all other highlights
326 (specifically, \fBA_ALTCHARSET\fR, \fBA_PROTECT\fR, and \fBA_INVIS\fR).
327 .PP
328 XSI Curses added these entry points:
329 .sp
330 .RS
331 \fBattr_get\fR, \fBattr_on\fR,
332 \fBattr_off\fR, \fBattr_set\fR, \fBwattr_on\fR, \fBwattr_off\fR,
333 \fBwattr_get\fR, \fBwattr_set\fR
334 .RE
335 .PP
336 The new functions are intended to work with
337 a new series of highlight macros prefixed with \fBWA_\fR.
338 The older macros have direct counterparts in the newer set of names:
339 .PP
340 .RS
341 .ne 9
342 .TS
343 l l
344 _ _ _
345 l l .
346 \fIName\fR      \fIDescription\fR
347 \fBWA_NORMAL\fR Normal display (no highlight)
348 \fBWA_STANDOUT\fR       Best highlighting mode of the terminal.
349 \fBWA_UNDERLINE\fR      Underlining
350 \fBWA_REVERSE\fR        Reverse video
351 \fBWA_BLINK\fR  Blinking
352 \fBWA_DIM\fR    Half bright
353 \fBWA_BOLD\fR   Extra bright or bold
354 \fBWA_ALTCHARSET\fR     Alternate character set
355 .TE
356 .RE
357 .PP
358 The XSI curses standard specifies that each pair of corresponding \fBA_\fR
359 and \fBWA_\fR-using functions operates on the same current-highlight
360 information.
361 .PP
362 The XSI standard extended conformance level adds new highlights
363 \fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
364 \fBA_VERTICAL\fR (and corresponding \fBWA_\fR macros for each).
365 As of August 2013,
366 no known terminal provides these highlights
367 (i.e., via the \fBsgr1\fP capability).
368 .SH RETURN VALUE
369 All routines return the integer \fBOK\fR on success, or \fBERR\fP on failure.
370 .PP
371 X/Open does not define any error conditions.
372 .PP
373 This implementation
374 .bP
375 returns an error if the window pointer is null.
376 .bP
377 returns an error if the color pair parameter
378 for \fBwcolor_set\fP is outside the range 0..COLOR_PAIRS\-1.
379 .bP
380 does not return an error if either of the parameters of \fBwattr_get\fP
381 used for retrieving attribute or color-pair values is \fBNULL\fP.
382 .PP
383 Functions with a "mv" prefix first perform a cursor movement using
384 \fBwmove\fP, and return an error if the position is outside the window,
385 or if the window pointer is null.
386 .SH SEE ALSO
387 .na
388 \fBcurses\fR(3X),
389 \fBcurs_addch\fR(3X),
390 \fBcurs_addstr\fR(3X),
391 \fBcurs_bkgd\fR(3X),
392 \fBcurs_printw\fR(3X),
393 \fBcurs_variables\fR(3X)