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