1<!-- 2 **************************************************************************** 3 * Copyright 2019-2023,2024 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.49 2024/04/20 18:55:09 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 2024-04-20 ncurses 6.5 Library calls</TITLE> 38<link rel="author" href="mailto:bug-ncurses@gnu.org"> 39 40</HEAD> 41<BODY> 42<H1 class="no-header">curs_getcchar 3x 2024-04-20 ncurses 6.5 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 48 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 52 53 54</PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE> 55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG> 56 57 <STRONG>int</STRONG> <STRONG>getcchar(</STRONG> 58 <STRONG>const</STRONG> <STRONG>cchar_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>,</STRONG> 59 <STRONG>wchar_t</STRONG> <STRONG>*</STRONG><EM>wc</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> 63 64 <STRONG>int</STRONG> <STRONG>setcchar(</STRONG> 65 <STRONG>cchar_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>,</STRONG> 66 <STRONG>const</STRONG> <STRONG>wchar_t</STRONG> <STRONG>*</STRONG><EM>wc</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> 70 71 72</PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE> 73 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>wc</EM> is not a null pointer, the <STRONG>getcchar</STRONG> function 77 does the following: 78 79 <STRONG>o</STRONG> Extracts information from a <STRONG>cchar_t</STRONG> value <EM>wch</EM> 80 81 <STRONG>o</STRONG> Stores the character attributes in the location pointed to by <EM>attrs</EM> 82 83 <STRONG>o</STRONG> Stores the color pair in the location pointed to by <EM>color</EM><STRONG>_</STRONG><EM>pair</EM> 84 85 <STRONG>o</STRONG> Stores the wide-character string, characters referenced by <EM>wch</EM>, 86 into the array pointed to by <EM>wc</EM>. 87 88 When <EM>wc</EM> is a null pointer, the <STRONG>getcchar</STRONG> function does the following: 89 90 <STRONG>o</STRONG> Obtains the number of wide characters pointed to by <EM>wch</EM> 91 92 <STRONG>o</STRONG> Does not change the data referenced by <EM>attrs</EM> or <EM>color</EM><STRONG>_</STRONG><EM>pair</EM> 93 94 95</PRE><H3><a name="h3-setcchar">setcchar</a></H3><PRE> 96 The <STRONG>setcchar</STRONG> function initializes the location pointed to by <EM>wch</EM> by 97 using: 98 99 <STRONG>o</STRONG> The character attributes in <EM>attrs</EM> 100 101 <STRONG>o</STRONG> The color pair in <EM>color</EM><STRONG>_</STRONG><EM>pair</EM> 102 103 <STRONG>o</STRONG> The wide-character string pointed to by <EM>wc</EM>. The string must be 104 L'\0' terminated, contain at most one spacing character, which must 105 be the first. 106 107 Up to <STRONG>CCHARW_MAX</STRONG>-1 non-spacing characters may follow. Additional 108 non-spacing characters are ignored. 109 110 The string may contain a single control character instead. In that 111 case, no non-spacing characters are allowed. 112 113 114</PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE> 115 When <EM>wc</EM> is a null pointer, <STRONG>getcchar</STRONG> returns the number of wide 116 characters referenced by <EM>wch</EM>, including one for a trailing null. 117 118 When <EM>wc</EM> is not a null pointer, <STRONG>getcchar</STRONG> returns <STRONG>OK</STRONG> upon successful 119 completion, and <STRONG>ERR</STRONG> otherwise. 120 121 Upon successful completion, <STRONG>setcchar</STRONG> returns <STRONG>OK</STRONG>. Otherwise, it returns 122 <STRONG>ERR</STRONG>. 123 124 125</PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE> 126 The <EM>wch</EM> argument may be a value generated by a call to <STRONG>setcchar</STRONG> or by a 127 function that has a <STRONG>cchar_t</STRONG> output argument. If <EM>wch</EM> is constructed by 128 any other means, the effect is unspecified. 129 130 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: 136 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. 140 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. 145 146 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: 151 152 <STRONG>o</STRONG> a spacing character (<STRONG>wchar_t</STRONG>, i.e., 32-bits). 153 154 <STRONG>o</STRONG> non-spacing characters (again, <STRONG>wchar_t</STRONG>'s). 155 156 <STRONG>o</STRONG> attributes (at least 16 bits, inferred from the various ACS- and 157 WACS-flags). 158 159 <STRONG>o</STRONG> color pair (at least 16 bits, inferred from the <STRONG>unsigned</STRONG> <STRONG>short</STRONG> 160 type). 161 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: 164 165 Implementations may limit the number of non-spacing characters that 166 can be associated with a spacing character, provided any limit is 167 at least 5. 168 169 The Unix implementations at the time follow that limit: 170 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>. 173 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. 176 177 <STRONG>o</STRONG> Solaris <EM>xpg4</EM> curses uses a single array of 6 <STRONG>wchar_t</STRONG> values. 178 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. 185 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 191 affected. 192 193 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> 196 197 198 199ncurses 6.5 2024-04-20 <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG> 200</PRE> 201<div class="nav"> 202<ul> 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> 206<ul> 207<li><a href="#h3-getcchar">getcchar</a></li> 208<li><a href="#h3-setcchar">setcchar</a></li> 209</ul> 210</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> 216</ul> 217</div> 218</BODY> 219</HTML> 220