summaryrefslogtreecommitdiff
path: root/lib/libcurses/curses_attributes.3
blob: 307ea858b2c8a08bc20e2974c9b4c681a38e4715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
.\"	$NetBSD: curses_attributes.3,v 1.8 2008/04/30 13:10:51 martin Exp $
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Julian Coleman.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 14, 2008
.Dt CURSES_ATTRIBUTES 3
.Os
.Sh NAME
.Nm curses_attributes ,
.Nm attron ,
.Nm attroff ,
.Nm attrset ,
.Nm color_set ,
.Nm getattrs ,
.Nm termattrs ,
.Nm wattron ,
.Nm wattroff ,
.Nm wattrset ,
.Nm wcolor_set ,
.Nm attr_on ,
.Nm attr_off ,
.Nm attr_set ,
.Nm attr_get ,
.Nm term_attrs ,
.Nm wattr_on ,
.Nm wattr_off ,
.Nm wattr_set ,
.Nm wattr_get
.Nd curses general attribute manipulation routines
.Sh LIBRARY
.Lb libcurses
.Sh SYNOPSIS
.In curses.h
.Ft int
.Fn attron "int attr"
.Ft int
.Fn attroff "int attr"
.Ft int
.Fn attrset "int attr"
.Ft int
.Fn color_set "short pair" "void *opt"
.Ft chtype
.Fn getattrs "WINDOW *win"
.Ft chtype
.Fn termattrs "void"
.Ft int
.Fn wcolor_set "WINDOW *win" "short pair" "void *opt"
.Ft int
.Fn wattron "WINDOW * win" "int attr"
.Ft int
.Fn wattroff "WINDOW * win" "int attr"
.Ft int
.Fn wattrset "WINDOW * win" "int attr"
.Ft int
.Fn attr_on "attr_t attr" "void *opt"
.Ft int
.Fn attr_off "attr_t attr" "void *opt"
.Ft int
.Fn attr_set "attr_t attr" "short pair" "void *opt"
.Ft int
.Fn attr_get "attr_t *attr" "short *pair" "void *opt"
.Ft attr_t
.Fn term_attrs "void"
.Ft int
.Fn wattr_on "WINDOW *win" "attr_t attr" "void *opt"
.Ft int
.Fn wattr_off "WINDOW *win" "attr_t attr" "void *opt"
.Ft int
.Fn wattr_set "WINDOW *win" "attr_t attr" "short pair" "void *opt"
.Ft int
.Fn wattr_get "WINDOW *win" "attr_t *attr" "short *pair" "void *opt"
.Sh DESCRIPTION
These functions manipulate attributes on
.Dv stdscr
or on the specified window.
The attributes that can be manipulated are:
.Pp
.Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent
.It A_NORMAL
no special attributes are applied
.It A_STANDOUT
characters are displayed in standout mode
.It A_UNDERLINE
characters are displayed underlined
.It A_REVERSE
characters are displayed in inverse video
.It A_BLINK
characters blink
.It A_DIM
characters are displayed at a lower intensity
.It A_BOLD
characters are displayed at a higher intensity
.It A_INVIS
characters are added invisibly
.It A_PROTECT
characters are protected from modification
.It A_ALTCHARSET
characters are displayed using the alternate character set (ACS)
.It COLOR_PAIR(n)
characters are displayed using color pair n.
.El
.Pp
The
.Fn attron
function turns on the attributes specified in
.Fa attr
on
.Dv stdscr ,
while the
.Fn attroff
function turns off the attributes specified in
.Fa attr
on
.Dv stdscr .
.Pp
The function
.Fn attrset
sets the attributes of
.Dv stdscr
to those specified in
.Fa attr ,
turning off any others.
To turn off all the attributes (including color and alternate character set),
use
.Fn attrset A_NORMAL .
.Pp
Multiple attributes can be manipulated by combining the attributes
using a logical
.Em OR .
For example,
.Fn attron "A_REVERSE | A_BOLD"
will turn on both inverse video and higher intensity.
.Pp
The function
.Fn color_set
sets the color pair attribute to the pair specified in
.Fa pair .
.Pp
The function
.Fn getattrs
returns the attributes that are currently applied to window specified by
.Fa win .
.Pp
The function
.Fn termattrs
returns the logical
.Em OR
of attributes that can be applied to the screen.
.Pp
The functions
.Fn wattron ,
.Fn wattroff ,
.Fn wattrset ,
and
.Fn wcolor_set
are equivalent to
.Fn attron ,
.Fn attroff
.Fn attrset ,
and
.Fn color_set
respectively, excepting that the attributes are applied to the window
specified by
.Fa win .
.Pp
The following functions additionally manipulate wide attributes on
.Dv stdscr
or on the specified window.
The additional wide attributes that can be manipulated are:
.Pp
.Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent
.It WA_STANDOUT
characters are displayed in standout mode
.It WA_UNDERLINE
characters are displayed underlined
.It WA_REVERSE
characters are displayed in inverse video
.It WA_BLINK
characters blink
.It WA_DIM
characters are displayed at a lower intensity
.It WA_BOLD
characters are displayed at a higher intensity
.It WA_INVIS
characters are added invisibly
.It WA_PROTECT
characters are protected from modification
.It WA_ALTCHARSET
characters are displayed using the alternate character set (ACS)
.It WA_LOW
characters are displayed with low highlight
.It WA_TOP
characters are displayed with top highlight
.It WA_HORIZONTAL
characters are displayed with horizontal highlight
.It WA_VERTICAL
characters are displayed with vertical highlight
.It WA_LEFT
characters are displayed with left highlight
.It WA_RIGHT
characters are displayed with right highlight
.El
.Pp
The
.Fn attr_on
function turns on the wide attributes specified in
.Fa attr
on
.Dv stdscr ,
while the
.Fn attr_off
function turns off the wide attributes specified in
.Fa attr
on
.Dv stdscr .
.Pp
The function
.Fn attr_set
sets the wide attributes of
.Dv stdscr
to those specified in
.Fa attr
and
.Fa pair ,
turning off any others.
Note that a color pair specified in
.Fa pair
will override any color pair specified in
.Fa attr .
.Pp
The function
.Fn attr_get
sets
.Fa attr
to the wide attributes and
.Fa pair
to the color pair currently applied to
.Dv stdscr .
Either of
.Fa attr
and
.Fa pair
can be
.Dv NULL ,
if the relevant value is of no interest.
.Pp
The function
.Fn term_attrs
returns the logical
.Em OR
of wide attributes that can be applied to the screen.
.Pp
The functions
.Fn wattr_on ,
.Fn wattr_off
and
.Fn wattr_set
are equivalent to
.Fn attr_on ,
.Fn attr_off
and
.Fn attr_set
respectively, excepting that the character is added to the window specified by
.Fa win .
.Pp
The function
.Fn wattr_get
is equivalent to
.Fn attr_get ,
excepting that the wide attributes and color pair currently applied to
.Fa win
are set.
.Pp
The following constants can be used to extract the components of a
.Dv chtype :
.Pp
.Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent
.It A_ATTRIBUTES
bit-mask containing attributes part
.It A_CHARTEXT
bit-mask containing character part
.It A_COLOR
bit-mask containing color-pair part
.El
.Sh RETURN VALUES
These functions return OK on success and ERR on failure.
.Sh SEE ALSO
.Xr curses_addch 3 ,
.Xr curses_addchstr 3 ,
.Xr curses_addstr 3 ,
.Xr curses_background 3 ,
.Xr curses_color 3 ,
.Xr curses_insertch 3 ,
.Xr curses_standout 3 ,
.Xr curses_underscore 3
.Sh NOTES
The
.Fa opt
argument is not currently used but is reserved for a future version of the
specification.
.Sh STANDARDS
The
.Nx
Curses library complies with the X/Open Curses specification, part of the
Single Unix Specification.
.Pp
The
.Fn getattrs
function
is a
.Nx
extension.
.Sh HISTORY
These functions first appeared in
.Nx 1.5 .
.Sh BUGS
Some terminals do not support characters with both color and other attributes
set.
In this case, the other attribute is displayed instead of the color attribute.