]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getcchar.3x
ncurses 6.4 - patch 20230917
[ncurses.git] / man / curs_getcchar.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2021,2023 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.35 2023/09/16 23:34:43 tom Exp $
31 .TH curs_getcchar 3X 2023-09-16 "ncurses 6.4" "Library calls"
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .SH NAME
37 \fB\%getcchar\fP,
38 \fB\%setcchar\fP \-
39 convert between a wide-character string and a \fIcurses\fR complex character string
40 .SH SYNOPSIS
41 \fB#include <curses.h>\fP
42 .sp
43 \fBint getcchar(\fP
44 .br
45 .B "        const cchar_t *\fIwcval\fP,"
46 .br
47 .B "        wchar_t *\fIwch\fP,"
48 .br
49 .B "        attr_t *\fIattrs\fP,"
50 .br
51 .B "        short *\fIcolor_pair\fP,"
52 .br
53 .B "        void *\fIopts\fP );"
54 .sp
55 .B "int setcchar("
56 .br
57 .B "        cchar_t *\fIwcval\fP,"
58 .br
59 .B "        const wchar_t *\fIwch\fP,"
60 .br
61 .B "        const attr_t \fIattrs\fP,"
62 .br
63 .B "        short \fIcolor_pair\fP,"
64 .br
65 .B "        const void *\fIopts\fP );"
66 .SH DESCRIPTION
67 .SS getcchar
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 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 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
116 saying that it must be null.
117 This implementation
118 uses that parameter in ABI 6 for the functions which have a color-pair
119 parameter to support extended color pairs:
120 .bP
121 For  functions  which modify the color, e.g., \fBsetcchar\fP,
122 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
123 and used to  set  the  color pair instead of the \fBshort\fP pair parameter.
124 .bP
125 For functions which retrieve the color, e.g., \fBgetcchar\fP,
126 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
127 and  used  to  retrieve  the color pair as an \fBint\fP value,
128 in addition retrieving it via the standard pointer to \fBshort\fP parameter.
129 .SH NOTES
130 The \fIwcval\fP argument may be a value generated by a call to
131 \fBsetcchar\fP or by a function that has a \fBcchar_t\fP output argument.
132 If \fIwcval\fP is constructed by any other means, the effect is unspecified.
133 .SH RETURN VALUE
134 When \fIwch\fP is a null pointer,
135 \fBgetcchar\fP returns the number of wide characters referenced by
136 \fIwcval\fP,
137 including one for a trailing null.
138 .PP
139 When \fIwch\fP is not a null pointer,
140 \fBgetcchar\fP returns \fBOK\fP upon successful completion,
141 and \fBERR\fP otherwise.
142 .PP
143 Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
144 Otherwise, it returns \fBERR\fP.
145 .SH PORTABILITY
146 The \fBCCHARW_MAX\fP symbol is specific to ncurses.
147 X/Open Curses does not provide details for the layout of the \fBcchar_t\fP
148 structure.
149 It tells what data are stored in it:
150 .bP
151 a spacing character (\fBwchar_t\fP, i.e., 32-bits).
152 .bP
153 non-spacing characters (again, \fBwchar_t\fP's).
154 .bP
155 attributes (at least 16 bits, inferred from the various ACS- and WACS-flags).
156 .bP
157 color pair (at least 16 bits, inferred from the \fBunsigned short\fP type).
158 .PP
159 The non-spacing characters are optional,
160 in the sense that zero or more may be stored in a \fBcchar_t\fP.
161 XOpen/Curses specifies a limit:
162 .RS 4
163 .PP
164 Implementations may limit the number of non-spacing characters that can be
165 associated with a spacing character, provided any limit is at least 5.
166 .RE
167 .PP
168 The Unix implementations at the time follow that limit:
169 .bP
170 AIX\ 4 and OSF1\ 4 use the same declaration with an array of 5 non-spacing
171 characters \fIz\fP and a single spacing character \fIc\fP.
172 .bP
173 HP-UX\ 10 uses an opaque structure with 28 bytes,
174 which is large enough for the 6 \fBwchar_t\fP values.
175 .bP
176 Solaris \fIxpg4\fP curses uses a single array of 6 \fBwchar_t\fP values.
177 .PP
178 This implementation's \fBcchar_t\fP was defined in 1995
179 using \fB5\fP for the total of spacing and non-spacing characters
180 (\fBCCHARW_MAX\fP).
181 That was probably due to a misreading of the AIX\ 4 header files,
182 because the X/Open Curses document was not generally available at that time.
183 Later (in 2002), this detail was overlooked when beginning to implement
184 the functions using the structure.
185 .PP
186 In practice, even four non-spacing characters may seem enough.
187 X/Open Curses documents possible uses for non-spacing characters,
188 including using them for ligatures between characters
189 (a feature apparently not supported by any curses implementation).
190 Unicode does not limit the (analogous) number of combining characters,
191 so some applications may be affected.
192 .SH SEE ALSO
193 Functions:
194 \fBcurs_attr\fP(3X),
195 \fBcurs_color\fP(3X),
196 \fBcurses\fP(3X),
197 \fBwcwidth\fP(3).