Debian Codegraph @

doc/html/man/curs_getcchar.3x.html

raw
1 <!--
2 ****************************************************************************
3 * Copyright 2019-2024,2025 Thomas E. Dickey *
4 * Copyright 2001-2015,2017 Free Software Foundation, Inc. *
5 * *
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: *
13 * *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
16 * *
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. *
24 * *
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 *
28 * authorization. *
29 ****************************************************************************
30 * @Id: curs_getcchar.3x,v 1.57 2025/02/23 13:48:31 tom Exp @
31 -->
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
33 <HTML>
34 <HEAD>
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 2025-02-23 ncurses 6.6 Library calls</TITLE>
38 <link rel="author" href="mailto:[email protected]">
39
40 </HEAD>
41 <BODY>
42 <H1 class="no-header">curs_getcchar 3x 2025-02-23 ncurses 6.6 Library calls</H1>
43 <PRE>
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>
45
46
47 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
48 <STRONG>getcchar</STRONG>, <STRONG>setcchar</STRONG> - convert between a wide-character string and a
49 <EM>curses</EM> complex character
50
51
52 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
53 <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
54
55 <STRONG>int</STRONG> <STRONG>getcchar(const</STRONG> <STRONG>cchar_t</STRONG> <STRONG>*</STRONG> <EM>wch</EM><STRONG>,</STRONG> <STRONG>wchar_t</STRONG> <STRONG>*</STRONG> <EM>wc</EM><STRONG>,</STRONG>
56 <STRONG>attr_t</STRONG> <STRONG>*</STRONG> <EM>attrs</EM><STRONG>,</STRONG> <STRONG>short</STRONG> <STRONG>*</STRONG> <EM>pair</EM><STRONG>,</STRONG> <STRONG>void</STRONG> <STRONG>*</STRONG> <EM>opts</EM><STRONG>);</STRONG>
57 <STRONG>int</STRONG> <STRONG>setcchar(cchar_t</STRONG> <STRONG>*</STRONG> <EM>wch</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>wchar_t</STRONG> <STRONG>*</STRONG> <EM>wc</EM><STRONG>,</STRONG>
58 <STRONG>const</STRONG> <STRONG>attr_t</STRONG> <EM>attrs</EM><STRONG>,</STRONG> <STRONG>short</STRONG> <EM>pair</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*</STRONG> <EM>opts</EM><STRONG>);</STRONG>
59
60
61 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
62 The <EM>curses</EM> complex character data type <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> is a structure type
63 comprising a wide-character string, a set of attributes, and a color
64 pair identifier. The <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> structure is opaque; do not attempt to
65 access its members directly. The library provides functions to
66 manipulate this type.
67
68
69 </PRE><H3><a name="h3-getcchar">getcchar</a></H3><PRE>
70 <STRONG>getcchar</STRONG> destructures a <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> into its components.
71
72 If <EM>wc</EM> is not a null pointer, <STRONG>getcchar</STRONG>:
73
74 <STRONG>o</STRONG> stores the wide-character string in the <EM>curses</EM> complex character
75 <EM>wch</EM> into <EM>wc</EM>;
76
77 <STRONG>o</STRONG> stores the attributes in <EM>attrs</EM>; and
78
79 <STRONG>o</STRONG> stores the color pair identifier in <EM>pair</EM>.
80
81 If <EM>wc</EM> is a null pointer, <STRONG>getcchar</STRONG> counts the <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> wide characters in
82 <EM>wch</EM>, returns that value, and leaves <EM>attrs</EM> and <EM>pair</EM> unchanged.
83
84
85 </PRE><H3><a name="h3-setcchar">setcchar</a></H3><PRE>
86 <STRONG>setcchar</STRONG> constructs a <EM>curses</EM> complex character <EM>wch</EM> from the components
87 <EM>wc</EM>, <EM>attrs</EM>, and <EM>pair</EM>. The wide-character string <EM>wch</EM> must be terminated
88 with a null wide character <STRONG>L'\0'</STRONG> and must contain at most one spacing
89 character, which, if present, must be the first wide character in the
90 string.
91
92 Up to <STRONG>CCHARW_MAX</STRONG> - 1 non-spacing characters may follow (see
93 <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>). <EM>ncurses</EM> ignores any additional non-spacing
94 characters.
95
96 The string may contain a single control character instead. In that
97 case, no non-spacing characters are allowed.
98
99
100 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
101 If <STRONG>getcchar</STRONG> is passed a null pointer as its <EM>wc</EM> argument, it returns the
102 number of wide characters for a given <EM>wch</EM> that it would store in <EM>wc</EM>,
103 counting a trailing null wide character. If <STRONG>getcchar</STRONG> is not passed a
104 null pointer as its <EM>wc</EM> argument, it returns <STRONG>OK</STRONG> on success and <STRONG>ERR</STRONG> on
105 failure.
106
107 In <EM>ncurses</EM>, <STRONG>getcchar</STRONG> returns <STRONG>ERR</STRONG> if either <EM>attrs</EM> or <EM>pair</EM> is a null
108 pointer and <EM>wc</EM> is not.
109
110 <STRONG>setcchar</STRONG> returns <STRONG>OK</STRONG> on success and <STRONG>ERR</STRONG> on failure.
111
112 In <EM>ncurses</EM>, <STRONG>setcchar</STRONG> returns <STRONG>ERR</STRONG> if
113
114 <STRONG>o</STRONG> <EM>wch</EM> is a null pointer,
115
116 <STRONG>o</STRONG> <EM>wc</EM> starts with a (wide) control character and contains any other
117 wide characters, or
118
119 <STRONG>o</STRONG> <EM>pair</EM> has a negative value.
120
121
122 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
123 <EM>wch</EM> may be a value stored by <STRONG>setcchar</STRONG> or another <EM>curses</EM> function with a
124 writable <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> argument. If <EM>wch</EM> is constructed by any other means,
125 the library's behavior is unspecified.
126
127
128 </PRE><H2><a name="h2-EXTENSIONS">EXTENSIONS</a></H2><PRE>
129 X/Open Curses documents the <EM>opts</EM> argument as reserved for future use,
130 saying that it must be a null pointer. The <EM>ncurses</EM> 6 ABI uses it with
131 functions that have a color pair parameter to support extended color
132 pairs.
133
134 <STRONG>o</STRONG> In functions that assign colors, such as <STRONG>setcchar</STRONG>, if <EM>opts</EM> is not a
135 null pointer, <EM>ncurses</EM> treats it as a pointer to <EM>int</EM>, and interprets
136 it instead of the <EM>short</EM> <EM>pair</EM> parameter as a color pair identifier.
137
138 <STRONG>o</STRONG> In functions that retrieve colors, such as <STRONG>getcchar</STRONG>, if <EM>opts</EM> is not
139 a null pointer, <EM>ncurses</EM> treats it as a pointer to <EM>int</EM>, and stores
140 the retrieved color pair identifier there as well as in the <EM>short</EM>
141 <EM>pair</EM> parameter (which may therefore undergo a narrowing
142 conversion).
143
144
145 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
146 Applications employing <EM>ncurses</EM> extensions should condition their use on
147 the visibility of the <STRONG>NCURSES_VERSION</STRONG> preprocessor macro.
148
149 These functions are described in X/Open Curses Issue 4. It specifies
150 no error conditions for them.
151
152 X/Open Curses does not detail the layout of the <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> structure,
153 describing only its minimal required contents:
154
155 <STRONG>o</STRONG> a spacing wide character (<EM>wchar</EM><STRONG>_</STRONG><EM>t</EM>),
156
157 <STRONG>o</STRONG> at least five non-spacing wide characters (<EM>wchar</EM><STRONG>_</STRONG><EM>t</EM>; see below),
158
159 <STRONG>o</STRONG> attributes (at least 15 bits' worth, inferred from the count of
160 specified <EM>WA</EM><STRONG>_</STRONG> constants),
161
162 <STRONG>o</STRONG> a color pair identifier (at least 16 bits, inferred from the <EM>short</EM>
163 type used to encode it).
164
165 Non-spacing characters are optional, in the sense that zero or more may
166 be stored in a <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM>. XOpen/Curses specifies a limit:
167
168 Implementations may limit the number of non-spacing characters that
169 can be associated with a spacing character, provided any limit is
170 at least 5.
171
172 Then-contemporary Unix implementations adhered to that limit.
173
174 <STRONG>o</STRONG> AIX 4 and OSF/1 4 used the same declaration with a single spacing
175 wide character <EM>c</EM> and an array of 5 non-spacing wide characters <EM>z</EM>.
176
177 <STRONG>o</STRONG> HP-UX 10 used an opaque structure of 28 bytes, large enough for 6
178 <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> values.
179
180 <STRONG>o</STRONG> Solaris <EM>xcurses</EM> uses a single array of 6 <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> values.
181
182 <EM>ncurses</EM> defined its <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> in 1995 using 5 as the <EM>total</EM> of spacing and
183 non-spacing characters (<STRONG>CCHARW_MAX</STRONG>). That was probably due to a
184 misreading of the AIX 4 header files, because the X/Open Curses
185 document was not generally available at that time. Later (in 2002),
186 this detail was overlooked when work began to implement the functions
187 using the structure.
188
189 In practice, a mere four non-spacing characters may seem adequate.
190 X/Open Curses documents possible applications of non-spacing
191 characters, including their use as ligatures (a feature apparently not
192 supported by any <EM>curses</EM> implementation). Unicode does not limit the
193 (analogous) number of combining characters in a grapheme cluster; some
194 applications may be affected. <EM>ncurses</EM> can be compiled with a different
195 <STRONG>CCHARW_MAX</STRONG> value; doing so alters the library's ABI.
196
197
198 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
199 X/Open Curses Issue 4 (1995) initially specified these functions.
200
201
202 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
203 <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>
204
205 ncurses 6.6 2025-02-23 <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
206 </PRE>
207 <div class="nav">
208 <ul>
209 <li><a href="#h2-NAME">NAME</a></li>
210 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
211 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
212 <ul>
213 <li><a href="#h3-getcchar">getcchar</a></li>
214 <li><a href="#h3-setcchar">setcchar</a></li>
215 </ul>
216 </li>
217 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
218 <li><a href="#h2-NOTES">NOTES</a></li>
219 <li><a href="#h2-EXTENSIONS">EXTENSIONS</a></li>
220 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
221 <li><a href="#h2-HISTORY">HISTORY</a></li>
222 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
223 </ul>
224 </div>
225 </BODY>
226 </HTML>