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