]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getcchar.3x
ncurses 6.3 - patch 20211120
[ncurses.git] / man / curs_getcchar.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2020,2021 Thomas E. Dickey                                *
3 .\" Copyright 2001-2015,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
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:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
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.                               *
23 .\"                                                                          *
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       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_getcchar.3x,v 1.25 2021/06/17 21:26:02 tom Exp $
31 .TH curs_getcchar 3X ""
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .SH NAME
37 \fBgetcchar\fP,
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
39 .SH SYNOPSIS
40 \fB#include <curses.h>\fP
41 .sp
42 \fBint getcchar(\fP
43 .br
44 .B "        const cchar_t *\fIwcval\fP,"
45 .br
46 .B "        wchar_t *\fIwch\fP,"
47 .br
48 .B "        attr_t *\fIattrs\fP,"
49 .br
50 .B "        short *\fIcolor_pair\fP,"
51 .br
52 .B "        void *\fIopts\fP );"
53 .sp
54 .B "int setcchar("
55 .br
56 .B "        cchar_t *\fIwcval\fP,"
57 .br
58 .B "        const wchar_t *\fIwch\fP,"
59 .br
60 .B "        const attr_t \fIattrs\fP,"
61 .br
62 .B "        short \fIcolor_pair\fP,"
63 .br
64 .B "        const void *\fIopts\fP );"
65 .SH DESCRIPTION
66 .SS getcchar
67 .PP
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:
72 .bP
73 Extracts information from a \fBcchar_t\fP value \fIwcval\fP
74 .bP
75 Stores the character attributes in the location pointed to by \fIattrs\fP
76 .bP
77 Stores the color-pair in the location pointed to by \fIcolor_pair\fP
78 .bP
79 Stores the wide-character string,
80 characters referenced by \fIwcval\fP, into the array pointed to by \fIwch\fP.
81 .PP
82 When
83 \fIwch\fP
84 is a null pointer, the
85 \fBgetcchar\fP
86 function does the following:
87 .bP
88 Obtains the number of wide characters pointed to by \fIwcval\fP
89 .bP
90 Does not change the data referenced by
91 \fIattrs\fP
92 or
93 \fIcolor_pair\fP
94 .SS setcchar
95 .PP
96 The \fBsetcchar\fP function initializes the location pointed to by \fIwcval\fP
97 by using:
98 .bP
99 The character attributes in
100 \fIattrs\fP
101 .bP
102 The color pair in
103 \fIcolor_pair\fP
104 .bP
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.
109 .IP
110 Up to \fBCCHARW_MAX\fP\-1 nonspacing characters may follow.
111 Additional nonspacing characters are ignored.
112 .IP
113 The string may contain a single control character instead.
114 In that case, no nonspacing characters are allowed.
115 .SH EXTENSIONS
116 .PP
117 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
118 saying that it must be null.
119 This implementation
120 uses that parameter in ABI 6 for the functions which have a color-pair
121 parameter to support extended color pairs:
122 .bP
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.
126 .bP
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.
131 .SH NOTES
132 .PP
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.
136 .SH RETURN VALUE
137 .PP
138 When \fIwch\fP is a null pointer,
139 \fBgetcchar\fP returns the number of wide characters referenced by
140 \fIwcval\fP,
141 including one for a trailing null.
142 .PP
143 When \fIwch\fP is not a null pointer,
144 \fBgetcchar\fP returns \fBOK\fP upon successful completion,
145 and \fBERR\fP otherwise.
146 .PP
147 Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
148 Otherwise, it returns \fBERR\fP.
149 .SH PORTABILITY
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
152 structure.
153 It tells what data are stored in it:
154 .bP
155 a spacing character (\fBwchar_t\fP, i.e., 32-bits).
156 .bP
157 non-spacing characters (again, \fBwchar_t\fP's).
158 .bP
159 attributes (at least 16 bits, inferred from the various ACS- and WACS-flags).
160 .bP
161 color pair (at least 16 bits, inferred from the \fBunsigned short\fP type).
162 .PP
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:
166 .RS 4
167 .PP
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.
170 .RE
171 .PP
172 The Unix implementations at the time follow that limit:
173 .bP
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.
176 .bP
177 HP-UX\ 10 uses an opaque structure with 28 bytes,
178 which is large enough for the 6 \fBwchar_t\fP values.
179 .bP
180 Solaris xpg4 curses uses a single array of 6 \fBwchar_t\fP values.
181 .PP
182 This implementation's \fBcchar_t\fP was defined in 1995
183 using \fB5\fP for the total of spacing and non-spacing characters
184 (\fBCCHARW_MAX\fP).
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.
189 .PP
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.
196 .SH SEE ALSO
197 .PP
198 Functions:
199 \fBcurs_attr\fR(3X),
200 \fBcurs_color\fR(3X),
201 \fBcurses\fR(3X),
202 \fBwcwidth\fR(3).