Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2019-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 2001-2015,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 32 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 33 | .ie n .IP \(bu 4 |
| 34 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 35 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 36 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 37 | \fB\%getcchar\fP, |
| 38 | \fB\%setcchar\fP \- |
| 39 | convert between a wide-character string and a \fIcurses\fR complex character |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 40 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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," |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .B " attr_t *\fIattrs\fP," |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 48 | .B " short *\fIcolor_pair\fP," |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | .B " void *\fIopts\fP );" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 50 | .PP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 51 | .B "int setcchar(" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 52 | .B " cchar_t *\fIwch\fP," |
| 53 | .B " const wchar_t *\fIwc\fP," |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 54 | .B " const attr_t \fIattrs\fP," |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .B " short \fIcolor_pair\fP," |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 56 | .B " const void *\fIopts\fP );" |
| 57 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 58 | .SH DESCRIPTION |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 59 | .SS getcchar |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 60 | The \fBgetcchar\fP function gets a wide-character string |
| 61 | and rendition from a \fBcchar_t\fP argument. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 62 | When \fIwc\fP is not a null pointer, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 63 | the \fBgetcchar\fP function does the following: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 64 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 65 | Extracts information from a \fBcchar_t\fP value \fIwch\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 66 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 67 | Stores the character attributes in the location pointed to by \fIattrs\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 68 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 69 | Stores the color pair in the location pointed to by \fIcolor_pair\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 70 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 71 | Stores the wide-character string, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 72 | characters referenced by \fIwch\fP, into the array pointed to by \fIwc\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 73 | .PP |
| 74 | When |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 75 | \fIwc\fP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 76 | is a null pointer, the |
| 77 | \fBgetcchar\fP |
| 78 | function does the following: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 79 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 80 | Obtains the number of wide characters pointed to by \fIwch\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 81 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 82 | Does not change the data referenced by |
| 83 | \fIattrs\fP |
| 84 | or |
| 85 | \fIcolor_pair\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 86 | .SS setcchar |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 87 | The \fBsetcchar\fP function initializes the location pointed to by \fIwch\fP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 88 | by using: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 89 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 90 | The character attributes in |
| 91 | \fIattrs\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 92 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 93 | The color pair in |
| 94 | \fIcolor_pair\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 95 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 96 | The wide-character string pointed to by \fIwc\fP. |
| 97 | The string must be L'\e0' terminated, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 98 | contain at most one spacing character, |
| 99 | which must be the first. |
| 100 | .IP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 101 | Up to \fBCCHARW_MAX\fP\-1 non-spacing characters may follow. |
| 102 | Additional non-spacing characters are ignored. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 103 | .IP |
| 104 | The string may contain a single control character instead. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 105 | In that case, no non-spacing characters are allowed. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 106 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 107 | When \fIwc\fP is a null pointer, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 108 | \fBgetcchar\fP returns the number of wide characters referenced by |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 109 | \fIwch\fP, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 110 | including one for a trailing null. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 111 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 112 | When \fIwc\fP is not a null pointer, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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). |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 150 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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) |