1 .\"***************************************************************************
2 .\" Copyright 2019-2020,2021 Thomas E. Dickey *
3 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc. *
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: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
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. *
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 *
28 .\"***************************************************************************
30 .\" $Id: curs_getcchar.3x,v 1.27 2021/12/25 20:35:03 tom Exp $
31 .TH curs_getcchar 3X ""
38 \fBsetcchar\fP \- Get a wide character string and rendition from a \fBcchar_t\fP or set a \fBcchar_t\fP from a wide-character string
40 \fB#include <curses.h>\fP
44 .B " const cchar_t *\fIwcval\fP,"
46 .B " wchar_t *\fIwch\fP,"
48 .B " attr_t *\fIattrs\fP,"
50 .B " short *\fIcolor_pair\fP,"
52 .B " void *\fIopts\fP );"
56 .B " cchar_t *\fIwcval\fP,"
58 .B " const wchar_t *\fIwch\fP,"
60 .B " const attr_t \fIattrs\fP,"
62 .B " short \fIcolor_pair\fP,"
64 .B " const void *\fIopts\fP );"
68 The \fBgetcchar\fP function gets a wide-character string
69 and rendition from a \fBcchar_t\fP argument.
70 When \fIwch\fP is not a null pointer,
71 the \fBgetcchar\fP function does the following:
73 Extracts information from a \fBcchar_t\fP value \fIwcval\fP
75 Stores the character attributes in the location pointed to by \fIattrs\fP
77 Stores the color-pair in the location pointed to by \fIcolor_pair\fP
79 Stores the wide-character string,
80 characters referenced by \fIwcval\fP, into the array pointed to by \fIwch\fP.
84 is a null pointer, the
86 function does the following:
88 Obtains the number of wide characters pointed to by \fIwcval\fP
90 Does not change the data referenced by
96 The \fBsetcchar\fP function initializes the location pointed to by \fIwcval\fP
99 The character attributes in
105 The wide-character string pointed to by \fIwch\fP.
106 The string must be L'\\0' terminated,
107 contain at most one spacing character,
108 which must be the first.
110 Up to \fBCCHARW_MAX\fP\-1 nonspacing characters may follow.
111 Additional nonspacing characters are ignored.
113 The string may contain a single control character instead.
114 In that case, no nonspacing characters are allowed.
117 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
118 saying that it must be null.
120 uses that parameter in ABI 6 for the functions which have a color-pair
121 parameter to support extended color pairs:
123 For functions which modify the color, e.g., \fBsetcchar\fP,
124 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
125 and used to set the color pair instead of the \fBshort\fP pair parameter.
127 For functions which retrieve the color, e.g., \fBgetcchar\fP,
128 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
129 and used to retrieve the color pair as an \fBint\fP value,
130 in addition retrieving it via the standard pointer to \fBshort\fP parameter.
133 The \fIwcval\fP argument may be a value generated by a call to
134 \fBsetcchar\fP or by a function that has a \fBcchar_t\fP output argument.
135 If \fIwcval\fP is constructed by any other means, the effect is unspecified.
138 When \fIwch\fP is a null pointer,
139 \fBgetcchar\fP returns the number of wide characters referenced by
141 including one for a trailing null.
143 When \fIwch\fP is not a null pointer,
144 \fBgetcchar\fP returns \fBOK\fP upon successful completion,
145 and \fBERR\fP otherwise.
147 Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
148 Otherwise, it returns \fBERR\fP.
150 The \fBCCHARW_MAX\fP symbol is specific to ncurses.
151 X/Open Curses does not provide details for the layout of the \fBcchar_t\fP
153 It tells what data are stored in it:
155 a spacing character (\fBwchar_t\fP, i.e., 32-bits).
157 non-spacing characters (again, \fBwchar_t\fP's).
159 attributes (at least 16 bits, inferred from the various ACS- and WACS-flags).
161 color pair (at least 16 bits, inferred from the \fBunsigned short\fP type).
163 The non-spacing characters are optional,
164 in the sense that zero or more may be stored in a \fBcchar_t\fP.
165 XOpen/Curses specifies a limit:
168 Implementations may limit the number of non-spacing characters that can be
169 associated with a spacing character, provided any limit is at least 5.
172 The Unix implementations at the time follow that limit:
174 AIX\ 4 and OSF1\ 4 use the same declaration with an array of 5 non-spacing
175 characters \fIz\fP and a single spacing character \fIc\fP.
177 HP-UX\ 10 uses an opaque structure with 28 bytes,
178 which is large enough for the 6 \fBwchar_t\fP values.
180 Solaris \fIxpg4\fP curses uses a single array of 6 \fBwchar_t\fP values.
182 This implementation's \fBcchar_t\fP was defined in 1995
183 using \fB5\fP for the total of spacing and non-spacing characters
185 That was probably due to a misreading of the AIX\ 4 header files,
186 because the X/Open Curses document was not generally available at that time.
187 Later (in 2002), this detail was overlooked when beginning to implement
188 the functions using the structure.
190 In practice, even four non-spacing characters may seem enough.
191 X/Open Curses documents possible uses for non-spacing characters,
192 including using them for ligatures between characters
193 (a feature apparently not supported by any curses implementation).
194 Unicode does not limit the (analogous) number of combining characters,
195 so some applications may be affected.
200 \fBcurs_color\fP(3X),