blob: 523cc99df92c9c73b7192c1cfe7243fd8fa51a10 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2019-2023,2024 Thomas E. Dickey *
3.\" Copyright 2001-2015,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $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"
Steve Kondikae271bc2015-11-15 02:50:53 +010032.de bP
micky3879b9f5e72025-07-08 18:04:53 -040033.ie n .IP \(bu 4
34.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010035..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053036.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040037\fB\%getcchar\fP,
38\fB\%setcchar\fP \-
39convert between a wide-character string and a \fIcurses\fR complex character
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053040.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040041.nf
42\fB#include <curses.h>
43.PP
44\fBint getcchar(
45.B " const cchar_t *\fIwch\fP,"
46.B " wchar_t *\fIwc\fP,"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047.B " attr_t *\fIattrs\fP,"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053048.B " short *\fIcolor_pair\fP,"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049.B " void *\fIopts\fP );"
micky3879b9f5e72025-07-08 18:04:53 -040050.PP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053051.B "int setcchar("
micky3879b9f5e72025-07-08 18:04:53 -040052.B " cchar_t *\fIwch\fP,"
53.B " const wchar_t *\fIwc\fP,"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053054.B " const attr_t \fIattrs\fP,"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053055.B " short \fIcolor_pair\fP,"
micky3879b9f5e72025-07-08 18:04:53 -040056.B " const void *\fIopts\fP );"
57.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053058.SH DESCRIPTION
Steve Kondikae271bc2015-11-15 02:50:53 +010059.SS getcchar
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053060The \fBgetcchar\fP function gets a wide-character string
61and rendition from a \fBcchar_t\fP argument.
micky3879b9f5e72025-07-08 18:04:53 -040062When \fIwc\fP is not a null pointer,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053063the \fBgetcchar\fP function does the following:
Steve Kondikae271bc2015-11-15 02:50:53 +010064.bP
micky3879b9f5e72025-07-08 18:04:53 -040065Extracts information from a \fBcchar_t\fP value \fIwch\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010066.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053067Stores the character attributes in the location pointed to by \fIattrs\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010068.bP
micky3879b9f5e72025-07-08 18:04:53 -040069Stores the color pair in the location pointed to by \fIcolor_pair\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010070.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053071Stores the wide-character string,
micky3879b9f5e72025-07-08 18:04:53 -040072characters referenced by \fIwch\fP, into the array pointed to by \fIwc\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053073.PP
74When
micky3879b9f5e72025-07-08 18:04:53 -040075\fIwc\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053076is a null pointer, the
77\fBgetcchar\fP
78function does the following:
Steve Kondikae271bc2015-11-15 02:50:53 +010079.bP
micky3879b9f5e72025-07-08 18:04:53 -040080Obtains the number of wide characters pointed to by \fIwch\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010081.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053082Does not change the data referenced by
83\fIattrs\fP
84or
85\fIcolor_pair\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010086.SS setcchar
micky3879b9f5e72025-07-08 18:04:53 -040087The \fBsetcchar\fP function initializes the location pointed to by \fIwch\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053088by using:
Steve Kondikae271bc2015-11-15 02:50:53 +010089.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053090The character attributes in
91\fIattrs\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010092.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053093The color pair in
94\fIcolor_pair\fP
Steve Kondikae271bc2015-11-15 02:50:53 +010095.bP
micky3879b9f5e72025-07-08 18:04:53 -040096The wide-character string pointed to by \fIwc\fP.
97The string must be L'\e0' terminated,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053098contain at most one spacing character,
99which must be the first.
100.IP
micky3879b9f5e72025-07-08 18:04:53 -0400101Up to \fBCCHARW_MAX\fP\-1 non-spacing characters may follow.
102Additional non-spacing characters are ignored.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530103.IP
104The string may contain a single control character instead.
micky3879b9f5e72025-07-08 18:04:53 -0400105In that case, no non-spacing characters are allowed.
Steve Kondikae271bc2015-11-15 02:50:53 +0100106.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400107When \fIwc\fP is a null pointer,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530108\fBgetcchar\fP returns the number of wide characters referenced by
micky3879b9f5e72025-07-08 18:04:53 -0400109\fIwch\fP,
Steve Kondikae271bc2015-11-15 02:50:53 +0100110including one for a trailing null.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530111.PP
micky3879b9f5e72025-07-08 18:04:53 -0400112When \fIwc\fP is not a null pointer,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530113\fBgetcchar\fP returns \fBOK\fP upon successful completion,
114and \fBERR\fP otherwise.
115.PP
116Upon successful completion, \fBsetcchar\fP returns \fBOK\fP.
117Otherwise, it returns \fBERR\fP.
micky3879b9f5e72025-07-08 18:04:53 -0400118.SH NOTES
119The \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.
121If \fIwch\fP is constructed by any other means, the effect is unspecified.
122.SH EXTENSIONS
123X/Open Curses documents the \fIopts\fP argument as reserved for future use,
124saying that it must be null.
125This implementation
126uses that parameter in ABI 6 for the functions which have a color pair
127parameter to support extended color pairs:
128.bP
129For functions which modify the color, e.g., \fBsetcchar\fP,
130if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
131and used to set the color pair instead of the \fBshort\fP pair parameter.
132.bP
133For functions which retrieve the color, e.g., \fBgetcchar\fP,
134if \fIopts\fP is set it is treated as a pointer to \fBint\fP,
135and used to retrieve the color pair as an \fBint\fP value,
136in addition retrieving it via the standard pointer to \fBshort\fP parameter.
137.SH PORTABILITY
138The \fBCCHARW_MAX\fP symbol is specific to \fI\%ncurses\fP.
139X/Open Curses does not provide details for the layout of the \fBcchar_t\fP
140structure.
141It tells what data are stored in it:
142.bP
143a spacing character (\fBwchar_t\fP, i.e., 32-bits).
144.bP
145non-spacing characters (again, \fBwchar_t\fP's).
146.bP
147attributes (at least 16 bits, inferred from the various ACS- and WACS-flags).
148.bP
149color pair (at least 16 bits, inferred from the \fBunsigned short\fP type).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530150.PP
micky3879b9f5e72025-07-08 18:04:53 -0400151The non-spacing characters are optional,
152in the sense that zero or more may be stored in a \fBcchar_t\fP.
153XOpen/Curses specifies a limit:
154.RS 4
155.PP
156Implementations may limit the number of non-spacing characters that can be
157associated with a spacing character, provided any limit is at least 5.
158.RE
159.PP
160The Unix implementations at the time follow that limit:
161.bP
162AIX\ 4 and OSF1\ 4 use the same declaration with an array of 5 non-spacing
163characters \fIz\fP and a single spacing character \fIc\fP.
164.bP
165HP-UX\ 10 uses an opaque structure with 28 bytes,
166which is large enough for the 6 \fBwchar_t\fP values.
167.bP
168Solaris \fIxpg4\fP curses uses a single array of 6 \fBwchar_t\fP values.
169.PP
170This implementation's \fBcchar_t\fP was defined in 1995
171using \fB5\fP for the total of spacing and non-spacing characters
172(\fBCCHARW_MAX\fP).
173That was probably due to a misreading of the AIX\ 4 header files,
174because the X/Open Curses document was not generally available at that time.
175Later (in 2002), this detail was overlooked when beginning to implement
176the functions using the structure.
177.PP
178In practice, even four non-spacing characters may seem enough.
179X/Open Curses documents possible uses for non-spacing characters,
180including using them for ligatures between characters
181(a feature apparently not supported by any curses implementation).
182Unicode does not limit the (analogous) number of combining characters,
183so 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)