]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_inwstr.3x
a557cbe3c8cbbaf059ddd578810050afa2112860
[ncurses.git] / man / curs_inwstr.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 2002-2012,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_inwstr.3x,v 1.45 2024/06/08 21:19:18 tom Exp $
31 .TH curs_inwstr 3X 2024-06-08 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el   .ds `` ""
39 .ie t .ds '' ''
40 .el   .ds '' ""
41 .\}
42 .de bP
43 .ie n  .IP \(bu 4
44 .el    .IP \(bu 2
45 ..
46 .SH NAME
47 \fB\%inwstr\fP,
48 \fB\%innwstr\fP,
49 \fB\%winwstr\fP,
50 \fB\%winnwstr\fP,
51 \fB\%mvinwstr\fP,
52 \fB\%mvinnwstr\fP,
53 \fB\%mvwinwstr\fP,
54 \fB\%mvwinnwstr\fP \-
55 get a wide-character string from a \fIcurses\fR window
56 .SH SYNOPSIS
57 .nf
58 \fB#include <curses.h>
59 .PP
60 \fBint inwstr(wchar_t *\ \fIwstr\fP);
61 \fBint winwstr(WINDOW *\ \fIwin\fP, wchar_t *\ \fIwstr\fP);
62 \fBint mvinwstr(int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP);
63 \fBint mvwinwstr(WINDOW *\ \fIwin\fP, int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP);
64 .PP
65 \fBint innwstr(wchar_t *\ \fIwstr\fP, int \fIn\fP);
66 \fBint winnwstr(WINDOW *\ \fIwin\fP, wchar_t *\ \fIwstr\fP, int \fIn\fP);
67 \fBint mvinnwstr(int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP, int \fIn\fP);
68 \fBint mvwinnwstr(WINDOW *\ \fIwin\fP, int \fIy\fP, int \fIx\fP, wchar_t *\ \fIwstr\fP, int \fIn\fP);
69 .fi
70 .SH DESCRIPTION
71 .B \%winwstr
72 extracts a wide-character string from a
73 .I curses
74 window
75 .IR win ","
76 starting at the cursor and stopping at the end of the line,
77 and stores it in
78 .IR wstr ","
79 terminating it with a wide null character
80 and
81 omitting any attributes and color pair identifier
82 that
83 .I curses
84 associates with each character.
85 .B \%winnwstr
86 does the same,
87 but copies at most
88 .I n
89 characters from
90 .IR win "."
91 An
92 .I n
93 of
94 .B \-1
95 implies no limit;
96 .B \%winnwstr
97 then works like
98 .BR \%winwstr "."
99 \fB\%ncurses\fP(3X) describes the variants of these functions.
100 .SH RETURN VALUE
101 On successful operation,
102 these functions return the count of wide characters copied from
103 .I win
104 to
105 .IR wstr "."
106 They return
107 .B ERR
108 upon failure.
109 .BR \%innwstr ","
110 .BR \%winnwstr ","
111 .BR \%mvinnwstr ","
112 and
113 .B \%mvwinnwstr
114 return
115 .B ERR
116 if
117 .I n
118 is insufficiently large to store a complete wide character string.
119 (Recall that a
120 .I curses
121 complex character can contain multiple wide characters,
122 some of which may be non-spacing.)
123 .PP
124 In
125 .IR \%ncurses ","
126 these functions return
127 .B ERR
128 if
129 .bP
130 .I win
131 is
132 .B NULL
133 or
134 .bP
135 .I wstr
136 is
137 .BR NULL "."
138 .PP
139 Functions prefixed with \*(``mv\*('' first perform cursor movement and
140 fail if the position
141 .RI ( y ,
142 .IR x )
143 is outside the window boundaries.
144 .SH NOTES
145 All of these functions except
146 .B \%winnwstr
147 may be implemented as macros.
148 .PP
149 Reading a line that overflows the array pointed to by
150 .I str
151 with
152 .BR \%inwstr ","
153 .BR \%winwstr ","
154 .BR \%mvinwstr ","
155 or
156 .B \%mvwinwstr
157 causes undefined results.
158 Use of
159 .BR \%innwstr ","
160 .BR \%winnwstr ","
161 .BR \%mvinnwstr ","
162 and
163 .B \%mvwinnwstr
164 is recommended instead.
165 .SH EXTENSIONS
166 .BR \%innwstr ","
167 .BR \%winnwstr ","
168 .BR \%mvinnwstr ","
169 and
170 .BR \%mvwinnwstr "'s"
171 treatment of
172 .B \-1
173 as a valid value of
174 .I n
175 is an
176 .I \%ncurses
177 extension.
178 .SH PORTABILITY
179 Applications employing
180 .I \%ncurses
181 extensions should condition their use on the visibility of the
182 .B \%NCURSES_VERSION
183 preprocessor macro.
184 .PP
185 X/Open Curses,
186 Issue 4 describes these functions.
187 It specifies no error conditions for them.
188 .PP
189 Notwithstanding the foregoing,
190 X/Open Curses Issues 4 and 7 both state that
191 .BR \%innwstr ","
192 .BR \%winnwstr ","
193 .BR \%mvinnwstr ","
194 and
195 .B \%mvwinnwstr
196 \*(``fail .\|.\|. [i]f the array is not large enough to contain any
197 complete characters\*(''.
198 Strictly interpreted,
199 this means that a caller of these functions cannot use their return
200 values to detect truncation of a wide-character string copied from more
201 than one character cell in
202 .IR win "."
203 .I \%ncurses
204 reports any truncation with
205 .BR ERR "."
206 .PP
207 X/Open Curses specifies
208 .BR \%inwstr ","
209 .BR \%winwstr ","
210 .BR \%mvinwstr ","
211 and
212 .B \%mvwinwstr
213 as returning
214 .B OK
215 rather than a (wide) character count,
216 unlike their non-wide counterparts
217 .BR \%instr ","
218 .BR \%winstr ","
219 .BR \%mvinstr ","
220 and
221 .BR \%mvwinstr "."
222 .I \%ncurses
223 regards this inconsistency as an error in the standard.
224 .SH SEE ALSO
225 \fB\%curs_instr\fP(3X) describes comparable functions of the
226 .I \%ncurses
227 library in its non-wide-character configuration.
228 .PP
229 \fB\%curses\fP(3X),
230 \fB\%curs_in_wch\fP(3X),
231 \fB\%curs_in_wchstr\fP(3X)