2 ****************************************************************************
3 * Copyright 2019-2021,2023 Thomas E. Dickey *
4 * Copyright 2001-2015,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: curs_getcchar.3x,v 1.43 2023/12/16 21:07:24 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>curs_getcchar 3x 2023-12-16 ncurses 6.4 Library calls</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">curs_getcchar 3x 2023-12-16 ncurses 6.4 Library calls</H1>
44 <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG> Library calls <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>getcchar</STRONG>, <STRONG>setcchar</STRONG> - convert between a wide-character string and a
51 <EM>curses</EM> complex character string
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
57 <STRONG>int</STRONG> <STRONG>getcchar(</STRONG>
58 <STRONG>const</STRONG> <STRONG>cchar_t</STRONG> <STRONG>*</STRONG><EM>wcval</EM><STRONG>,</STRONG>
59 <STRONG>wchar_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>,</STRONG>
60 <STRONG>attr_t</STRONG> <STRONG>*</STRONG><EM>attrs</EM><STRONG>,</STRONG>
61 <STRONG>short</STRONG> <STRONG>*</STRONG><EM>color</EM><STRONG>_</STRONG><EM>pair</EM><STRONG>,</STRONG>
62 <STRONG>void</STRONG> <STRONG>*</STRONG><EM>opts</EM> <STRONG>);</STRONG>
64 <STRONG>int</STRONG> <STRONG>setcchar(</STRONG>
65 <STRONG>cchar_t</STRONG> <STRONG>*</STRONG><EM>wcval</EM><STRONG>,</STRONG>
66 <STRONG>const</STRONG> <STRONG>wchar_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>,</STRONG>
67 <STRONG>const</STRONG> <STRONG>attr_t</STRONG> <EM>attrs</EM><STRONG>,</STRONG>
68 <STRONG>short</STRONG> <EM>color</EM><STRONG>_</STRONG><EM>pair</EM><STRONG>,</STRONG>
69 <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*</STRONG><EM>opts</EM> <STRONG>);</STRONG>
72 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
74 </PRE><H3><a name="h3-getcchar">getcchar</a></H3><PRE>
75 The <STRONG>getcchar</STRONG> function gets a wide-character string and rendition from a
76 <STRONG>cchar_t</STRONG> argument. When <EM>wch</EM> is not a null pointer, the <STRONG>getcchar</STRONG>
77 function does the following:
79 <STRONG>o</STRONG> Extracts information from a <STRONG>cchar_t</STRONG> value <EM>wcval</EM>
81 <STRONG>o</STRONG> Stores the character attributes in the location pointed to by <EM>attrs</EM>
83 <STRONG>o</STRONG> Stores the color pair in the location pointed to by <EM>color</EM><STRONG>_</STRONG><EM>pair</EM>
85 <STRONG>o</STRONG> Stores the wide-character string, characters referenced by <EM>wcval</EM>,
86 into the array pointed to by <EM>wch</EM>.
88 When <EM>wch</EM> is a null pointer, the <STRONG>getcchar</STRONG> function does the following:
90 <STRONG>o</STRONG> Obtains the number of wide characters pointed to by <EM>wcval</EM>
92 <STRONG>o</STRONG> Does not change the data referenced by <EM>attrs</EM> or <EM>color</EM><STRONG>_</STRONG><EM>pair</EM>
95 </PRE><H3><a name="h3-setcchar">setcchar</a></H3><PRE>
96 The <STRONG>setcchar</STRONG> function initializes the location pointed to by <EM>wcval</EM> by
99 <STRONG>o</STRONG> The character attributes in <EM>attrs</EM>
101 <STRONG>o</STRONG> The color pair in <EM>color</EM><STRONG>_</STRONG><EM>pair</EM>
103 <STRONG>o</STRONG> The wide-character string pointed to by <EM>wch</EM>. The string must be
104 L'\0' terminated, contain at most one spacing character, which must
107 Up to <STRONG>CCHARW_MAX</STRONG>-1 non-spacing characters may follow. Additional
108 non-spacing characters are ignored.
110 The string may contain a single control character instead. In that
111 case, no non-spacing characters are allowed.
114 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
115 When <EM>wch</EM> is a null pointer, <STRONG>getcchar</STRONG> returns the number of wide
116 characters referenced by <EM>wcval</EM>, including one for a trailing null.
118 When <EM>wch</EM> is not a null pointer, <STRONG>getcchar</STRONG> returns <STRONG>OK</STRONG> upon successful
119 completion, and <STRONG>ERR</STRONG> otherwise.
121 Upon successful completion, <STRONG>setcchar</STRONG> returns <STRONG>OK</STRONG>. Otherwise, it returns
122 <STRONG>ERR</STRONG>.
125 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
126 The <EM>wcval</EM> argument may be a value generated by a call to <STRONG>setcchar</STRONG> or by
127 a function that has a <STRONG>cchar_t</STRONG> output argument. If <EM>wcval</EM> is constructed
128 by any other means, the effect is unspecified.
131 </PRE><H2><a name="h2-EXTENSIONS">EXTENSIONS</a></H2><PRE>
132 X/Open Curses documents the <EM>opts</EM> argument as reserved for future use,
133 saying that it must be null. This implementation uses that parameter
134 in ABI 6 for the functions which have a color pair parameter to support
135 extended color pairs:
137 <STRONG>o</STRONG> For functions which modify the color, e.g., <STRONG>setcchar</STRONG>, if <EM>opts</EM> is
138 set it is treated as a pointer to <STRONG>int</STRONG>, and used to set the color
139 pair instead of the <STRONG>short</STRONG> pair parameter.
141 <STRONG>o</STRONG> For functions which retrieve the color, e.g., <STRONG>getcchar</STRONG>, if <EM>opts</EM> is
142 set it is treated as a pointer to <STRONG>int</STRONG>, and used to retrieve the
143 color pair as an <STRONG>int</STRONG> value, in addition retrieving it via the
144 standard pointer to <STRONG>short</STRONG> parameter.
147 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
148 The <STRONG>CCHARW_MAX</STRONG> symbol is specific to <EM>ncurses</EM>. X/Open Curses does not
149 provide details for the layout of the <STRONG>cchar_t</STRONG> structure. It tells what
150 data are stored in it:
152 <STRONG>o</STRONG> a spacing character (<STRONG>wchar_t</STRONG>, i.e., 32-bits).
154 <STRONG>o</STRONG> non-spacing characters (again, <STRONG>wchar_t</STRONG>'s).
156 <STRONG>o</STRONG> attributes (at least 16 bits, inferred from the various ACS- and
159 <STRONG>o</STRONG> color pair (at least 16 bits, inferred from the <STRONG>unsigned</STRONG> <STRONG>short</STRONG>
162 The non-spacing characters are optional, in the sense that zero or more
163 may be stored in a <STRONG>cchar_t</STRONG>. XOpen/Curses specifies a limit:
165 Implementations may limit the number of non-spacing characters that
166 can be associated with a spacing character, provided any limit is
169 The Unix implementations at the time follow that limit:
171 <STRONG>o</STRONG> AIX 4 and OSF1 4 use the same declaration with an array of 5 non-
172 spacing characters <EM>z</EM> and a single spacing character <EM>c</EM>.
174 <STRONG>o</STRONG> HP-UX 10 uses an opaque structure with 28 bytes, which is large
175 enough for the 6 <STRONG>wchar_t</STRONG> values.
177 <STRONG>o</STRONG> Solaris <EM>xpg4</EM> curses uses a single array of 6 <STRONG>wchar_t</STRONG> values.
179 This implementation's <STRONG>cchar_t</STRONG> was defined in 1995 using <STRONG>5</STRONG> for the total
180 of spacing and non-spacing characters (<STRONG>CCHARW_MAX</STRONG>). That was probably
181 due to a misreading of the AIX 4 header files, because the X/Open
182 Curses document was not generally available at that time. Later (in
183 2002), this detail was overlooked when beginning to implement the
184 functions using the structure.
186 In practice, even four non-spacing characters may seem enough. X/Open
187 Curses documents possible uses for non-spacing characters, including
188 using them for ligatures between characters (a feature apparently not
189 supported by any curses implementation). Unicode does not limit the
190 (analogous) number of combining characters, so some applications may be
194 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
195 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>, <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>, <STRONG>wcwidth(3)</STRONG>
199 ncurses 6.4 2023-12-16 <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
203 <li><a href="#h2-NAME">NAME</a></li>
204 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
205 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
207 <li><a href="#h3-getcchar">getcchar</a></li>
208 <li><a href="#h3-setcchar">setcchar</a></li>
211 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
212 <li><a href="#h2-NOTES">NOTES</a></li>
213 <li><a href="#h2-EXTENSIONS">EXTENSIONS</a></li>
214 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
215 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>