]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getcchar.3x
ncurses 6.4 - patch 20240420
[ncurses.git] / man / curs_getcchar.3x
1 .\"***************************************************************************
2 .\" Copyright 2019-2023,2024 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.49 2024/04/20 18:55:09 tom Exp $
31 .TH curs_getcchar 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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
40 .SH SYNOPSIS
41 .nf
42 \fB#include <curses.h>
43 .PP
44 \fBint getcchar(
45 .B "        const cchar_t *\fIwch\fP,"
46 .B "        wchar_t *\fIwc\fP,"
47 .B "        attr_t *\fIattrs\fP,"
48 .B "        short *\fIcolor_pair\fP,"
49 .B "        void *\fIopts\fP );"
50 .PP
51 .B "int setcchar("
52 .B "        cchar_t *\fIwch\fP,"
53 .B "        const wchar_t *\fIwc\fP,"
54 .B "        const attr_t \fIattrs\fP,"
55 .B "        short \fIcolor_pair\fP,"
56 .B "        const void *\fIopts\fP );"
57 .fi
58 .SH DESCRIPTION
59 .SS getcchar
60 The \fBgetcchar\fP function gets a wide-character string
61 and rendition from a \fBcchar_t\fP argument.
62 When \fIwc\fP is not a null pointer,
63 the \fBgetcchar\fP function does the following:
64 .bP
65 Extracts information from a \fBcchar_t\fP value \fIwch\fP
66 .bP
67 Stores the character attributes in the location pointed to by \fIattrs\fP
68 .bP
69 Stores the color pair in the location pointed to by \fIcolor_pair\fP
70 .bP
71 Stores the wide-character string,
72 characters referenced by \fIwch\fP, into the array pointed to by \fIwc\fP.
73 .PP
74 When
75 \fIwc\fP
76 is a null pointer, the
77 \fBgetcchar\fP
78 function does the following:
79 .bP
80 Obtains the number of wide characters pointed to by \fIwch\fP
81 .bP
82 Does not change the data referenced by
83 \fIattrs\fP
84 or
85 \fIcolor_pair\fP
86 .SS setcchar
87 The \fBsetcchar\fP function initializes the location pointed to by \fIwch\fP
88 by using:
89 .bP
90 The character attributes in
91 \fIattrs\fP
92 .bP
93 The color pair in
94 \fIcolor_pair\fP
95 .bP
96 The wide-character string pointed to by \fIwc\fP.
97 The string must be L'\e0' terminated,
98 contain at most one spacing character,
99 which must be the first.
100 .IP
101 Up to \fBCCHARW_MAX\fP\-1 non-spacing characters may follow.
102 Additional non-spacing characters are ignored.
103 .IP
104 The string may contain a single control character instead.
105 In that case, no non-spacing characters are allowed.
106 .SH RETURN VALUE
107 When \fIwc\fP is a null pointer,
108 \fBgetcchar\fP returns the number of wide characters referenced by
109 \fIwch\fP,
110 including one for a trailing null.
111 .PP
112 When \fIwc\fP is not a null pointer,
113 \fBgetcchar\fP returns \fBOK\fP upon successful completion,
114 and \fBERR\fP otherwise.
115 .PP
116 Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
117 Otherwise, it returns \fBERR\fP.
118 .SH NOTES
119 The \fIwch\fP argument may be a value generated by a call to
120 \fBsetcchar\fP or by a function that has a \fBcchar_t\fP output argument.
121 If \fIwch\fP is constructed by any other means, the effect is unspecified.
122 .SH EXTENSIONS
123 X/Open Curses documents the \fIopts\fP argument as reserved for future use,
124 saying that it must be null.
125 This implementation
126 uses that parameter in ABI 6 for the functions which have a color pair
127 parameter to support extended color pairs:
128 .bP
129 For  functions  which modify the color, e.g., \fBsetcchar\fP,
130 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
131 and used to  set  the  color pair instead of the \fBshort\fP pair parameter.
132 .bP
133 For functions which retrieve the color, e.g., \fBgetcchar\fP,
134 if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
135 and  used  to  retrieve  the color pair as an \fBint\fP value,
136 in addition retrieving it via the standard pointer to \fBshort\fP parameter.
137 .SH PORTABILITY
138 The \fBCCHARW_MAX\fP symbol is specific to \fI\%ncurses\fP.
139 X/Open Curses does not provide details for the layout of the \fBcchar_t\fP
140 structure.
141 It tells what data are stored in it:
142 .bP
143 a spacing character (\fBwchar_t\fP, i.e., 32-bits).
144 .bP
145 non-spacing characters (again, \fBwchar_t\fP's).
146 .bP
147 attributes (at least 16 bits, inferred from the various ACS- and WACS-flags).
148 .bP
149 color pair (at least 16 bits, inferred from the \fBunsigned short\fP type).
150 .PP
151 The non-spacing characters are optional,
152 in the sense that zero or more may be stored in a \fBcchar_t\fP.
153 XOpen/Curses specifies a limit:
154 .RS 4
155 .PP
156 Implementations may limit the number of non-spacing characters that can be
157 associated with a spacing character, provided any limit is at least 5.
158 .RE
159 .PP
160 The Unix implementations at the time follow that limit:
161 .bP
162 AIX\ 4 and OSF1\ 4 use the same declaration with an array of 5 non-spacing
163 characters \fIz\fP and a single spacing character \fIc\fP.
164 .bP
165 HP-UX\ 10 uses an opaque structure with 28 bytes,
166 which is large enough for the 6 \fBwchar_t\fP values.
167 .bP
168 Solaris \fIxpg4\fP curses uses a single array of 6 \fBwchar_t\fP values.
169 .PP
170 This implementation's \fBcchar_t\fP was defined in 1995
171 using \fB5\fP for the total of spacing and non-spacing characters
172 (\fBCCHARW_MAX\fP).
173 That was probably due to a misreading of the AIX\ 4 header files,
174 because the X/Open Curses document was not generally available at that time.
175 Later (in 2002), this detail was overlooked when beginning to implement
176 the functions using the structure.
177 .PP
178 In practice, even four non-spacing characters may seem enough.
179 X/Open Curses documents possible uses for non-spacing characters,
180 including using them for ligatures between characters
181 (a feature apparently not supported by any curses implementation).
182 Unicode does not limit the (analogous) number of combining characters,
183 so some applications may be affected.
184 .SH SEE ALSO
185 \fB\%curses\fP(3X),
186 \fB\%curs_attr\fP(3X),
187 \fB\%curs_color\fP(3X),
188 \fB\%wcwidth\fP(3)