]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_get_wstr.3x
ncurses 6.4 - patch 20230805
[ncurses.git] / man / curs_get_wstr.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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_get_wstr.3x,v 1.30 2023/08/05 12:14:30 tom Exp $
31 .TH curs_get_wstr 3X 2023-08-05 "ncurses 6.4" "Library calls"
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .na
41 .hy 0
42 .SH NAME
43 \fBget_wstr\fP,
44 \fBgetn_wstr\fP,
45 \fBwget_wstr\fP,
46 \fBwgetn_wstr\fP,
47 \fBmvget_wstr\fP,
48 \fBmvgetn_wstr\fP,
49 \fBmvwget_wstr\fP,
50 \fBmvwgetn_wstr\fP \- get an array of wide characters from a curses terminal keyboard
51 .ad
52 .hy
53 .SH SYNOPSIS
54 .nf
55 \fB#include <curses.h>\fP
56 .sp
57 \fBint get_wstr(wint_t *\fIwstr\fB);\fR
58 .br
59 \fBint getn_wstr(wint_t *\fIwstr\fB, int \fIn\fB);\fR
60 .br
61 \fBint wget_wstr(WINDOW *\fIwin\fB, wint_t *\fIwstr\fB);\fR
62 .br
63 \fBint wgetn_wstr(WINDOW *\fIwin\fB, wint_t *\fIwstr\fB, int \fIn\fB);\fR
64 .sp
65 \fBint mvget_wstr(int \fIy\fB, int \fIx\fB, wint_t *\fIwstr\fB);\fR
66 .br
67 \fBint mvgetn_wstr(int \fIy\fB, int \fIx\fB, wint_t *\fIwstr\fB, int \fIn\fB);\fR
68 .br
69 \fBint mvwget_wstr(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, wint_t *\fIwstr\fB);\fR
70 .br
71 \fBint mvwgetn_wstr(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, wint_t *\fIwstr\fB, int \fIn\fB);\fR
72 .fi
73 .SH DESCRIPTION
74 The function
75 \fBwgetn_wstr\fP
76 is equivalent to a series of calls to
77 \fBwget_wch\fP(3X)
78 until a newline or carriage return terminates the series:
79 .bP
80 The terminating character is not included in the returned string.
81 .bP
82 An end-of-file condition is represented by \fBWEOF\fP,
83 as defined in \fB<wchar.h>\fP.
84 .bP
85 In all instances, the end of the string is terminated
86 by a null \fBwchar_t\fP.
87 .bP
88 The function stores the result in the area pointed to
89 by the \fIwstr\fP parameter.
90 .bP
91 The function reads at most \fIn\fP characters,
92 thus preventing a possible overflow of the input buffer.
93 .IP
94 Any attempt to enter more characters
95 (other than the terminating newline or carriage return)
96 causes a beep.
97 .IP
98 Function keys also cause a beep and are ignored.
99 .PP
100 The user's \fIerase\fP and \fIkill\fP characters are interpreted:
101 .bP
102 The \fIerase\fP character (e.g., \fB^H\fP) erases the character
103 at the end of the buffer, moving the cursor to the left.
104 .IP
105 If \fIkeypad\fP mode is on for the window,
106 \fBKEY_LEFT\fP and \fBKEY_BACKSPACE\fP
107 are both considered equivalent to the user's \fIerase\fP character.
108 .bP
109 The \fIkill\fP character (e.g., \fB^U\fP) erases the entire buffer,
110 leaving the cursor at the beginning of the buffer.
111 .PP
112 Characters input are echoed only if \fBecho\fP is currently on.
113 In that case,
114 backspace is echoed as deletion of the previous character
115 (typically a left motion).
116 .PP
117 The
118 \fBgetn_wstr\fP,
119 \fBmvgetn_wstr\fP,
120 \fBmvwgetn_wstr\fP, and
121 \fBwgetn_wstr\fP
122 functions are identical
123 to the
124 \fBget_wstr\fP,
125 \fBmvget_wstr\fP,
126 \fBmvwget_wstr\fP, and
127 \fBwget_wstr\fP
128 functions, respectively,
129 except that the
130 \fB*n_*\fP
131 versions read at most
132 \fIn\fP
133 characters, letting the application prevent overflow of the
134 input buffer.
135 .SH NOTES
136 Any of these functions other than
137 \fBwgetn_wstr\fP
138 may be macros.
139 .PP
140 Using
141 \fBget_wstr\fP,
142 \fBmvget_wstr\fP,
143 \fBmvwget_wstr\fP, or
144 \fBwget_wstr\fP
145 to read a line that
146 overflows the array pointed to by
147 \fBwstr\fP
148 causes undefined
149 results.
150 The use of
151 \fBgetn_wstr\fP,
152 \fBmvgetn_wstr\fP,
153 \fBmvwgetn_wstr\fP, or
154 \fBwgetn_wstr\fP,
155 respectively, is recommended.
156 .PP
157 These functions cannot return \fBKEY_\fP values because there
158 is no way to distinguish a \fBKEY_\fP value from a valid \fBwchar_t\fP value.
159 may be macros.
160 .SH RETURN VALUE
161 All of these functions return the integer \fBOK\fP upon successful completion.
162 If unsuccessful, they return \fBERR\fP.
163 .PP
164 X/Open defines no error conditions.
165 .PP
166 In this implementation,
167 these functions return an error
168 .bP
169 if the window pointer is null,
170 .bP
171 if its timeout expires without having any data, or
172 .bP
173 if the associated call to
174 \fBwget_wch\fP
175 failed.
176 .PP
177 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
178 \fBwmove\fP, and return an error if the position is outside the window,
179 or if the window pointer is null.
180 .SH PORTABILITY
181 These functions are described in The Single Unix Specification, Version 2.
182 No error conditions are defined.
183 .PP
184 This implementation returns \fBERR\fP if the window pointer is null,
185 or if the lower-level \fBwget_wch\fP call returns an \fBERR\fP.
186 In the latter case,
187 an \fBERR\fP return without other data is treated as an end-of-file condition,
188 and the returned array contains a \fBWEOF\fP followed by a null \fBwchar_t\fP.
189 .PP
190 X/Open curses documented these functions to pass an array of \fBwchar_t\fP
191 in 1997, but that was an error because of this part of the description:
192 .RS
193 .PP
194 The effect of \fBget_wstr\fP is as though a series of calls to
195 \fBget_wch\fP were made, until a newline character, end-of-line character, or
196 end-of-file character is processed.
197 .RE
198 .PP
199 The latter function \fIget_wch\fP can return a negative value,
200 while \fBwchar_t\fP is a unsigned type.
201 All of the vendors implement this using \fBwint_t\fP, following the standard.
202 .PP
203 X/Open Curses, Issue 7 (2009) is unclear regarding whether
204 the terminating \fInull \fBwchar_t\fR
205 value is counted in the length parameter \fIn\fP.
206 X/Open Curses, Issue 7 revised the corresponding description
207 of \fBwgetnstr\fP to address this issue.
208 The unrevised description of \fBwget_nwstr\fP can be interpreted either way.
209 This implementation counts the terminator in the length.
210 .PP
211 X/Open Curses does not specify what happens if the length \fIn\fP is negative.
212 .bP
213 For analogy with \fBwgetnstr\fP,
214 ncurses 6.2 uses a limit (based on \fBLINE_MAX\fP).
215 .bP
216 Some other implementations (such as Solaris xcurses) do the same,
217 while others (PDCurses) do not allow this.
218 .bP
219 NetBSD 7 curses imitates ncurses 6.1 in this regard,
220 treating a \fB\-1\fP as an indefinite number of characters.
221 .SH SEE ALSO
222 Functions:
223 \fBcurses\fP(3X),
224 \fBcurs_get_wch\fP(3X),
225 \fBcurs_getstr\fP(3X).