]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getcchar.3x
ncurses 6.1 - patch 20191130
[ncurses.git] / man / curs_getcchar.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2001-2017,2019 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_getcchar.3x,v 1.23 2019/11/30 22:22:32 tom Exp $
30 .TH curs_getcchar 3X ""
31 .de bP
32 .ie n  .IP \(bu 4
33 .el    .IP \(bu 2
34 ..
35 .SH NAME
36 \fBgetcchar\fP,
37 \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
38 .SH SYNOPSIS
39 \fB#include <curses.h>\fP
40 .sp
41 \fBint getcchar(\fP
42 .br
43 .B "        const cchar_t *\fIwcval\fP,"
44 .br
45 .B "        wchar_t *\fIwch\fP,"
46 .br
47 .B "        attr_t *\fIattrs\fP,"
48 .br
49 .B "        short *\fIcolor_pair\fP,"
50 .br
51 .B "        void *\fIopts\fP );"
52 .sp
53 .B "int setcchar("
54 .br
55 .B "        cchar_t *\fIwcval\fP,"
56 .br
57 .B "        const wchar_t *\fIwch\fP,"
58 .br
59 .B "        const attr_t \fIattrs\fP,"
60 .br
61 .B "        short \fIcolor_pair\fP,"
62 .br
63 .B "        const void *\fIopts\fP );"
64 .SH DESCRIPTION
65 .SS getcchar
66 .PP
67 The \fBgetcchar\fP function gets a wide-character string
68 and rendition from a \fBcchar_t\fP argument.
69 When \fIwch\fP is not a null pointer,
70 the \fBgetcchar\fP function does the following:
71 .bP
72 Extracts information from a \fBcchar_t\fP value \fIwcval\fP
73 .bP
74 Stores the character attributes in the location pointed to by \fIattrs\fP
75 .bP
76 Stores the color-pair in the location pointed to by \fIcolor_pair\fP
77 .bP
78 Stores the wide-character string,
79 characters referenced by \fIwcval\fP, into the array pointed to by \fIwch\fP.
80 .PP
81 When
82 \fIwch\fP
83 is a null pointer, the
84 \fBgetcchar\fP
85 function does the following:
86 .bP
87 Obtains the number of wide characters pointed to by \fIwcval\fP
88 .bP
89 Does not change the data referenced by
90 \fIattrs\fP
91 or
92 \fIcolor_pair\fP
93 .SS setcchar
94 .PP
95 The \fBsetcchar\fP function initializes the location pointed to by \fIwcval\fP
96 by using:
97 .bP
98 The character attributes in
99 \fIattrs\fP
100 .bP
101 The color pair in
102 \fIcolor_pair\fP
103 .bP
104 The wide-character string pointed to by \fIwch\fP.
105 The string must be L'\\0' terminated,
106 contain at most one spacing character,
107 which must be the first.
108 .IP
109 Up to \fBCCHARW_MAX\fP\-1 nonspacing characters may follow.
110 Additional nonspacing characters are ignored.
111 .IP
112 The string may contain a single control character instead.
113 In that case, no nonspacing characters are allowed.
114 .SH EXTENSIONS
115 .PP
116 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
117 saying that it must be null.
118 This implementation 
119 uses that parameter in ABI 6 for the functions which have a color-pair
120 parameter to support extended color pairs:
121 .bP
122 For  functions  which modify the color, e.g., \fBsetcchar\fP,
123 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
124 and used to  set  the  color pair instead of the \fBshort\fP pair parameter.
125 .bP
126 For functions which retrieve the color, e.g., \fBgetcchar\fP,
127 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
128 and  used  to  retrieve  the color pair as an \fBint\fP value,
129 in addition retrieving it via the standard pointer to \fBshort\fP parameter.
130 .SH NOTES
131 .PP
132 The \fIwcval\fP argument may be a value generated by a call to
133 \fBsetcchar\fP or by a function that has a \fBcchar_t\fP output argument.
134 If \fIwcval\fP is constructed by any other means, the effect is unspecified.
135 .SH RETURN VALUE
136 .PP
137 When \fIwch\fP is a null pointer,
138 \fBgetcchar\fP returns the number of wide characters referenced by
139 \fIwcval\fP,
140 including one for a trailing null.
141 .PP
142 When \fIwch\fP is not a null pointer,
143 \fBgetcchar\fP returns \fBOK\fP upon successful completion,
144 and \fBERR\fP otherwise.
145 .PP
146 Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
147 Otherwise, it returns \fBERR\fP.
148 .SH PORTABILITY
149 The \fBCCHARW_MAX\fP symbol is specific to ncurses.
150 X/Open Curses does not provide details for the layout of the \fBcchar_t\fP
151 structure.
152 It tells what data are stored in it:
153 .bP
154 a spacing character (\fBwchar_t\fP, i.e., 32-bits).
155 .bP
156 non-spacing characters (again, \fBwchar_t\fP's).
157 .bP
158 attributes (at least 16 bits, inferred from the various ACS- and WACS-flags).
159 .bP
160 color pair (at least 16 bits, inferred from the \fBunsigned short\fP type).
161 .PP
162 The non-spacing characters are optional,
163 in the sense that zero or more may be stored in a \fBcchar_t\fP.
164 XOpen/Curses specifies a limit:
165 .RS 4
166 .PP
167 Implementations may limit the number of non-spacing characters that can be
168 associated with a spacing character, provided any limit is at least 5.
169 .RE
170 .PP
171 The Unix implementations at the time follow that limit:
172 .bP
173 AIX\ 4 and OSF1\ 4 use the same declaration with an array of 5 non-spacing
174 characters \fIz\fP and a single spacing character \fIc\fP.
175 .bP
176 HP-UX\ 10 uses an opaque structure with 28 bytes,
177 which is large enough for the 6 \fBwchar_t\fP values.
178 .bP
179 Solaris xpg4 curses uses a single array of 6 \fBwchar_t\fP values.
180 .PP
181 This implementation's \fBcchar_t\fP was defined in 1995
182 using \fB5\fP for the total of spacing and non-spacing characters
183 (\fBCCHARW_MAX\fP).
184 That was probably due to a misreading of the AIX\ 4 header files,
185 because the X/Open Curses document was not generally available at that time.
186 Later (in 2002), this detail was overlooked when beginning to implement
187 the functions using the structure.
188 .PP
189 In practice, even four non-spacing characters may seem enough.
190 X/Open Curses documents possible uses for non-spacing characters,
191 including using them for ligatures between characters
192 (a feature apparently not supported by any curses implementation).
193 Unicode does not limit the (analogous) number of combining characters,
194 so some applications may be affected.
195 .SH SEE ALSO
196 .PP
197 Functions:
198 \fBcurs_attr\fR(3X),
199 \fBcurs_color\fR(3X),
200 \fBcurses\fR(3X),
201 \fBwcwidth\fR(3).