]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_attr.3x
ncurses 6.0 - patch 20170121
[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.49 2017/01/07 19:25:15 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 .\" ---------------------------------------------------------------------------
142 .SS Window attributes
143 .PP
144 The \fBattr_set\fP and \fBwattr_set\fP functions set the current attributes
145 of the given window to \fIattrs\fP, with color specified by \fIpair\fP.
146 X/Open specified an additional parameter \fIopts\fP which is unused in
147 all implementations.
148 .PP
149 Use \fBattr_get\fP and \fBwattr_get\fP to retrieve attributes for
150 the given window.
151 .PP
152 Use \fBattr_on\fP and \fBwattr_on\fP to turn on window attributes, i.e.,
153 values OR'd together in \fIattr\fP,
154 without affecting other attributes.
155 Use \fBattr_off\fP and \fBwattr_off\fP to turn off window attributes,
156 again values OR'd together in \fIattr\fP,
157 without affecting other attributes.
158 .\" ---------------------------------------------------------------------------
159 .SS Legacy window attributes
160 Most of the window attribute routines are extensions of older routines
161 which assume that color pairs are OR'd into the attribute parameter.
162 These older routines use the same name, omitting an underscore (\fB_\fP).
163
164 The \fBattrset\fP routine is a legacy feature predating SVr4 curses
165 but kept in X/Open Curses for the same reason that SVr4 curses kept it:
166 compatibility.
167 .PP
168 The remaining \fBattr\fR* functions operate exactly like the corresponding
169 \fBattr_\fR* functions, except that they take arguments of type \fBint\fR
170 rather than \fBattr_t\fR.
171 .PP
172 There is no corresponding \fBattrget\fP function as such in X/Open Curses,
173 although ncurses provides \fBgetattrs\fP (see curs_legacy(3X)).
174 .\" ---------------------------------------------------------------------------
175 .SS Change character rendition
176 .PP
177 The routine \fBchgat\fR changes the attributes of a given number of characters
178 starting at the current cursor location of \fBstdscr\fR.
179 It does not update
180 the cursor and does not perform wrapping.
181 A character count of \-1 or greater
182 than the remaining window width means to change attributes all the way to the
183 end of the current line.
184 The \fBwchgat\fR function generalizes this to any window;
185 the \fBmvwchgat\fR function does a cursor move before acting.
186 .PP
187 In these functions,
188 the color \fIpair\fP argument is a color-pair index
189 (as in the first argument of \fBinit_pair\fR, see \fBcurs_color\fR(3X)).
190 The \fBopts\fR argument is not
191 presently used, but is reserved for the future (leave it \fBNULL\fR).
192 .\" ---------------------------------------------------------------------------
193 .SS Change window color
194 The routine \fBcolor_set\fR sets the current color of the given window to the
195 foreground/background combination described by the color \fIpair\fP parameter.
196 The parameter \fIopts\fP is reserved for future use;
197 applications must supply a null pointer.
198 .\" ---------------------------------------------------------------------------
199 .SS Standout
200 .PP
201 The routine \fBstandout\fR is
202 the same as \fBattron(A_STANDOUT)\fR.
203 The routine \fBstandend\fR is the same
204 as \fBattrset(A_NORMAL)\fR or \fBattrset(0)\fR, that is, it turns off all
205 attributes.
206 .PP
207 X/Open does not mark these "restricted", because
208 .bP
209 they have well established legacy use, and
210 .bP
211 there is no ambiguity about the way the attributes
212 might be combined with a color pair.
213 .\" ---------------------------------------------------------------------------
214 .SH VIDEO ATTRIBUTES
215 The following video attributes, defined in \fB<curses.h>\fR, can be passed to
216 the routines \fBattron\fR, \fBattroff\fR, and \fBattrset\fR, or OR'd with the
217 characters passed to \fBaddch\fR (see \fBcurs_addch\fR(3X)).
218 .PP
219 .RS
220 .TS
221 l l
222 _ _ _
223 l l .
224 \fIName\fR      \fIDescription\fR
225 \fBA_NORMAL\fR  Normal display (no highlight)
226 \fBA_STANDOUT\fR        Best highlighting mode of the terminal.
227 \fBA_UNDERLINE\fR       Underlining
228 \fBA_REVERSE\fR Reverse video
229 \fBA_BLINK\fR   Blinking
230 \fBA_DIM\fR     Half bright
231 \fBA_BOLD\fR    Extra bright or bold
232 \fBA_PROTECT\fR Protected mode
233 \fBA_INVIS\fR   Invisible or blank mode
234 \fBA_ALTCHARSET\fR      Alternate character set
235 \fBA_ITALIC\fR  Italics (non-X/Open extension)
236 \fBA_CHARTEXT\fR        Bit-mask to extract a character
237 .TE
238 .RE
239 .PP
240 These video attributes are supported by \fBattr_on\fP and related functions
241 (which also support the attributes recognized by \fBattron\fP, etc.):
242 .RS
243 .TS
244 l l
245 _ _ _
246 l l .
247 \fIName\fR      \fIDescription\fR
248 \fBWA_HORIZONTAL\fR     Horizontal highlight
249 \fBWA_LEFT\fR   Left highlight
250 \fBWA_LOW\fR    Low highlight
251 \fBWA_RIGHT\fR  Right highlight
252 \fBWA_TOP\fR    Top highlight
253 \fBWA_VERTICAL\fR       Vertical highlight
254 .TE
255 .RE
256 .PP
257 The return values of many of these routines are not meaningful (they are
258 implemented as macro-expanded assignments and simply return their argument).
259 The SVr4 manual page claims (falsely) that these routines always return \fB1\fR.
260 .SH NOTES
261 These functions may be macros:
262 \fBattroff\fR, \fBwattroff\fR, \fBattron\fR, \fBwattron\fR,
263 \fBattrset\fR, \fBwattrset\fR, \fBstandend\fR and \fBstandout\fR.
264 .PP
265 Color pair values can only be OR'd with attributes if the pair
266 number is less than 256.
267 The alternate functions such as \fBcolor_set\fP can pass a color pair
268 value directly.
269 However, ncurses ABI 4 and 5 simply OR this value within the alternate functions.
270 You must use ncurses ABI 6 to support more than 256 color pairs.
271 .SH PORTABILITY
272 These functions are supported in the XSI Curses standard, Issue 4.
273 The
274 standard defined the dedicated type for highlights, \fBattr_t\fR, which is not
275 defined in SVr4 curses.
276 The functions taking \fBattr_t\fR arguments are
277 not supported under SVr4.
278 .PP
279 The XSI Curses standard states that whether the traditional functions
280 \fBattron\fR/\fBattroff\fR/\fBattrset\fR can manipulate attributes other than
281 \fBA_BLINK\fR, \fBA_BOLD\fR, \fBA_DIM\fR, \fBA_REVERSE\fR, \fBA_STANDOUT\fR, or
282 \fBA_UNDERLINE\fR is "unspecified".
283 Under this implementation as well as
284 SVr4 curses, these functions correctly manipulate all other highlights
285 (specifically, \fBA_ALTCHARSET\fR, \fBA_PROTECT\fR, and \fBA_INVIS\fR).
286 .PP
287 This implementation provides the \fBA_ITALIC\fP attribute for terminals
288 which have the \fBenter_italics_mode\fP (\fBsitm\fP)
289 and \fBexit_italics_mode\fP (\fBritm\fP) capabilities.
290 Italics are not mentioned in X/Open Curses.
291 Unlike the other video attributes, \fBA_ITALIC\fP is unrelated
292 to the \fBset_attributes\fP capabilities.
293 This implementation makes the assumption that
294 \fBexit_attribute_mode\fP may also reset italics.
295 .PP
296 XSI Curses added the new entry points, \fBattr_get\fR, \fBattr_on\fR,
297 \fBattr_off\fR, \fBattr_set\fR, \fBwattr_on\fR, \fBwattr_off\fR,
298 \fBwattr_get\fR, \fBwattr_set\fR.
299 These are intended to work with
300 a new series of highlight macros prefixed with \fBWA_\fR.
301 The older macros have direct counterparts in the newer set of names:
302 .PP
303 .RS
304 .ne 9
305 .TS
306 l l
307 _ _ _
308 l l .
309 \fIName\fR      \fIDescription\fR
310 \fBWA_NORMAL\fR Normal display (no highlight)
311 \fBWA_STANDOUT\fR       Best highlighting mode of the terminal.
312 \fBWA_UNDERLINE\fR      Underlining
313 \fBWA_REVERSE\fR        Reverse video
314 \fBWA_BLINK\fR  Blinking
315 \fBWA_DIM\fR    Half bright
316 \fBWA_BOLD\fR   Extra bright or bold
317 \fBWA_ALTCHARSET\fR     Alternate character set
318 .TE
319 .RE
320 .PP
321 Very old versions of this library did not force an update of the screen
322 when changing the attributes.
323 Use \fBtouchwin\fR to force the screen to match the updated attributes.
324 .PP
325 The XSI curses standard specifies that each pair of corresponding \fBA_\fR
326 and \fBWA_\fR-using functions operates on the same current-highlight
327 information.
328 .PP
329 The XSI standard extended conformance level adds new highlights
330 \fBA_HORIZONTAL\fR, \fBA_LEFT\fR, \fBA_LOW\fR, \fBA_RIGHT\fR, \fBA_TOP\fR,
331 \fBA_VERTICAL\fR (and corresponding \fBWA_\fR macros for each).
332 As of August 2013,
333 no known terminal provides these highlights
334 (i.e., via the \fBsgr1\fP capability).
335 .SH RETURN VALUE
336 All routines return the integer \fBOK\fR on success, or \fBERR\fP on failure.
337 .PP
338 X/Open does not define any error conditions.
339 .PP
340 This implementation
341 .bP
342 returns an error if the window pointer is null.
343 .bP
344 returns an error if the color pair parameter
345 for \fBwcolor_set\fP is outside the range 0..COLOR_PAIRS\-1.
346 .PP
347 Functions with a "mv" prefix first perform a cursor movement using
348 \fBwmove\fP, and return an error if the position is outside the window,
349 or if the window pointer is null.
350 .SH SEE ALSO
351 .na
352 \fBcurses\fR(3X),
353 \fBcurs_addch\fR(3X),
354 \fBcurs_addstr\fR(3X),
355 \fBcurs_bkgd\fR(3X),
356 \fBcurs_printw\fR(3X),
357 \fBcurs_variables\fR(3X)