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