1curs_getcchar(3X) curs_getcchar(3X)
2
3
4
6 getcchar, setcchar - Get a wide character string and rendition from a
7 cchar_t or set a cchar_t from a wide-character string
8
10 #include <curses.h>
11
12 int getcchar(
13 const cchar_t *wcval,
14 wchar_t *wch,
15 attr_t *attrs,
16 short *color_pair,
17 void *opts );
18
19 int setcchar(
20 cchar_t *wcval,
21 const wchar_t *wch,
22 const attr_t attrs,
23 short color_pair,
24 const void *opts );
25
27 getcchar
28 The getcchar function gets a wide-character string and rendition from a
29 cchar_t argument. When wch is not a null pointer, the getcchar func‐
30 tion does the following:
31
32 · Extracts information from a cchar_t value wcval
33
34 · Stores the character attributes in the location pointed to by attrs
35
36 · Stores the color-pair in the location pointed to by color_pair
37
38 · Stores the wide-character string, characters referenced by wcval,
39 into the array pointed to by wch.
40
41 When wch is a null pointer, the getcchar function does the following:
42
43 · Obtains the number of wide characters pointed to by wcval
44
45 · Does not change the data referenced by attrs or color_pair
46
47 setcchar
48 The setcchar function initializes the location pointed to by wcval by
49 using:
50
51 · The character attributes in attrs
52
53 · The color pair in color_pair
54
55 · The wide-character string pointed to by wch. The string must be
56 L'\0' terminated, contain at most one spacing character, which must
57 be the first.
58
59 Up to CCHARW_MAX-1 nonspacing characters may follow. Additional
60 nonspacing characters are ignored.
61
62 The string may contain a single control character instead. In that
63 case, no nonspacing characters are allowed.
64
66 X/Open Curses documents the opts argument as reserved for future use,
67 saying that it must be null. This implementation uses that parameter
68 in ABI 6 for the functions which have a color-pair parameter to support
69 extended color pairs:
70
71 · For functions which modify the color, e.g., setcchar, if opts is
72 set it is treated as a pointer to int, and used to set the color
73 pair instead of the short pair parameter.
74
75 · For functions which retrieve the color, e.g., getcchar, if opts is
76 set it is treated as a pointer to int, and used to retrieve the
77 color pair as an int value, in addition retrieving it via the stan‐
78 dard pointer to short parameter.
79
81 The wcval argument may be a value generated by a call to setcchar or by
82 a function that has a cchar_t output argument. If wcval is constructed
83 by any other means, the effect is unspecified.
84
86 When wch is a null pointer, getcchar returns the number of wide charac‐
87 ters referenced by wcval, including one for a trailing null.
88
89 When wch is not a null pointer, getcchar returns OK upon successful
90 completion, and ERR otherwise.
91
92 Upon successful completion, setcchar returns OK. Otherwise, it returns
93 ERR.
94
96 The CCHARW_MAX symbol is specific to ncurses. X/Open Curses does not
97 provide details for the layout of the cchar_t structure. It tells what
98 data are stored in it:
99
100 · a spacing character (wchar_t, i.e., 32-bits).
101
102 · non-spacing characters (again, wchar_t's).
103
104 · attributes (at least 16 bits, inferred from the various ACS- and
105 WACS-flags).
106
107 · color pair (at least 16 bits, inferred from the unsigned short
108 type).
109
110 The non-spacing characters are optional, in the sense that zero or more
111 may be stored in a cchar_t. XOpen/Curses specifies a limit:
112
113 Implementations may limit the number of non-spacing characters that
114 can be associated with a spacing character, provided any limit is
115 at least 5.
116
117 The Unix implementations at the time follow that limit:
118
119 · AIX 4 and OSF1 4 use the same declaration with an array of 5 non-
120 spacing characters z and a single spacing character c.
121
122 · HP-UX 10 uses an opaque structure with 28 bytes, which is large
123 enough for the 6 wchar_t values.
124
125 · Solaris xpg4 curses uses a single array of 6 wchar_t values.
126
127 This implementation's cchar_t was defined in 1995 using 5 for the total
128 of spacing and non-spacing characters (CCHARW_MAX). That was probably
129 due to a misreading of the AIX 4 header files, because the X/Open
130 Curses document was not generally available at that time. Later (in
131 2002), this detail was overlooked when beginning to implement the func‐
132 tions using the structure.
133
134 In practice, even four non-spacing characters may seem enough. X/Open
135 Curses documents possible uses for non-spacing characters, including
136 using them for ligatures between characters (a feature apparently not
137 supported by any curses implementation). Unicode does not limit the
138 (analogous) number of combining characters, so some applications may be
139 affected.
140
142 Functions: curs_attr(3X), curs_color(3X), curses(3X), wcwidth(3).
143
144
145
146 curs_getcchar(3X)