]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_get_wstr.3x
ncurses 6.1 - patch 20190907
[ncurses.git] / man / curs_get_wstr.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2002-2018,2019 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_get_wstr.3x,v 1.18 2019/07/20 19:14:56 tom Exp $
30 .TH curs_get_wstr 3X ""
31 .de bP
32 .ie n  .IP \(bu 4
33 .el    .IP \(bu 2
34 ..
35 .na
36 .hy 0
37 .SH NAME
38 \fBget_wstr\fR,
39 \fBgetn_wstr\fR,
40 \fBwget_wstr\fR,
41 \fBwgetn_wstr\fR,
42 \fBmvget_wstr\fR,
43 \fBmvgetn_wstr\fR,
44 \fBmvwget_wstr\fR,
45 \fBmvwgetn_wstr\fR \- get an array of wide characters from a curses terminal keyboard
46 .ad
47 .hy
48 .SH SYNOPSIS
49 .nf
50 \fB#include <curses.h>\fR
51 .sp
52 \fBint get_wstr(wint_t *\fR\fIwstr\fR\fB);\fR
53 .br
54 \fBint getn_wstr(wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
55 .br
56 \fBint wget_wstr(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR
57 .br
58 \fBint wgetn_wstr(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
59 .br
60 \fBint mvget_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR
61 .br
62 \fBint mvgetn_wstr(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
63 .br
64 \fBint mvwget_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB);\fR
65 .br
66 \fBint mvwgetn_wstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
67 .fi
68 .SH DESCRIPTION
69 The effect of
70 \fBget_wstr\fR
71 is as though a series of calls
72 to
73 \fBget_wch\fR(3X)
74 were made, until a newline, other end-of-line,
75 or end-of-file condition is processed.
76 An end-of-file condition is represented by \fBWEOF\fR,
77 as defined in \fB<wchar.h>\fR.
78 The newline and end-of-line conditions are represented
79 by the \fB\\n\fR \fBwchar_t\fR value.
80 In all instances, the end of the string is terminated by a null \fBwchar_t\fR.
81 The routine places resulting values in the area pointed to by \fIwstr\fR.
82 .PP
83 The user's erase and kill characters are interpreted.
84 If keypad
85 mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
86 are both considered equivalent to the user's kill character.
87 .PP
88 Characters input are echoed only if \fBecho\fR is currently on.
89 In that case,
90 backspace is echoed as deletion of the previous character (typically a left
91 motion).
92 .PP
93 The effect of
94 \fBwget_wstr\fR
95 is as though a series of
96 calls to
97 \fBwget_wch\fR
98 were made.
99 .PP
100 The effect of
101 \fBmvget_wstr\fR
102 is as though a call to
103 \fBmove\fR
104 and then a series of calls to
105 \fBget_wch\fR
106 were
107 made.
108 .PP
109 The effect of
110 \fBmvwget_wstr\fR
111 is as though a call to
112 \fBwmove\fR
113 and then a series of calls to
114 \fBwget_wch\fR
115 were made.
116 .PP
117 The
118 \fBgetn_wstr\fR,
119 \fBmvgetn_wstr\fR,
120 \fBmvwgetn_wstr\fR, and
121 \fBwgetn_wstr\fR
122 functions are identical
123 to the
124 \fBget_wstr\fR,
125 \fBmvget_wstr\fR,
126 \fBmvwget_wstr\fR, and
127 \fBwget_wstr\fR
128 functions, respectively,
129 except that the
130 \fB*n_*\fR
131 versions read at most
132 \fIn\fR
133 characters, letting the application prevent overflow of the
134 input buffer.
135 .SH NOTES
136 Using
137 \fBget_wstr\fR,
138 \fBmvget_wstr\fR,
139 \fBmvwget_wstr\fR, or
140 \fBwget_wstr\fR
141 to read a line that
142 overflows the array pointed to by
143 \fBwstr\fR
144 causes undefined
145 results.
146 The use of
147 \fBgetn_wstr\fR,
148 \fBmvgetn_wstr\fR,
149 \fBmvwgetn_wstr\fR, or
150 \fBwgetn_wstr\fR, respectively, is recommended.
151 .PP
152 These functions cannot return \fBKEY_\fR values because there
153 is no way to distinguish a \fBKEY_\fR value from a valid \fBwchar_t\fR value.
154 .PP
155 All of these routines except \fBwgetn_wstr\fR may be macros.
156 .SH RETURN VALUE
157 All of these functions return \fBOK\fR upon successful completion.
158 Otherwise, they return \fBERR\fR.
159 .PP
160 Functions using a window parameter return an error if it is null.
161 .RS
162 .TP 5
163 \fBwgetn_wstr\fP
164 returns an error if the associated call to \fBwget_wch\fP failed.
165 .RE
166 .PP
167 Functions with a "mv" prefix first perform a cursor movement using
168 \fBwmove\fP, and return an error if the position is outside the window,
169 or if the window pointer is null.
170 .SH PORTABILITY
171 These functions are described in The Single Unix Specification, Version 2.
172 No error conditions are defined.
173 This implementation returns \fBERR\fP if the window pointer is null,
174 or if the lower-level \fBwget_wch\fR call returns an \fBERR\fP.
175 In the latter case,
176 an \fBERR\fP return without other data is treated as an end-of-file condition,
177 and the returned array contains a \fBWEOF\fR followed by a null \fBwchar_t\fR.
178 .PP
179 X/Open curses documented these functions to pass an array of \fBwchar_t\fR
180 in 1997, but that was an error because of this part of the description:
181 .RS
182 .PP
183 The effect of \fIget_wstr()\fP is as though a series of calls to
184 \fIget_wch()\fP were made, until a newline character, end-of-line character, or
185 end-of-file character is processed.
186 .RE
187 .PP
188 The latter function \fIget_wch()\fP can return a negative value,
189 while \fBwchar_t\fP is a unsigned type.
190 All of the vendors implement this using \fBwint_t\fR, following the standard.
191 .PP
192 X/Open Curses, Issue 7 (2009) is unclear regarding whether
193 the terminating \fInull \fP\fBwchar_t\fP
194 value is counted in the length parameter \fIn\fP.
195 X/Open Curses, Issue 7 revised the corresponding description
196 of \fBwgetnstr\fP to address this issue.
197 The unrevised description of \fBwget_nwstr\fP can be interpreted either way.
198 This implementation counts the terminator in the length.
199 .PP
200 X/Open Curses does not specify what happens if the length \fIn\fP is negative.
201 .bP
202 For analogy with \fBwgetnstr\fP,
203 ncurses 6.2 uses a limit (based on \fBLINE_MAX\fP).
204 .bP
205 Some other implementations (such as Solaris xcurses) do the same,
206 while others (PDCurses) do not allow this.
207 .bP
208 NetBSD 7 curses imitates ncurses 6.1 in this regard,
209 treating a \fB\-1\fP as an indefinite number of characters.
210 .SH SEE ALSO
211 Functions:
212 \fBcurses\fR(3X),
213 \fBcurs_get_wch\fR(3X),
214 \fBcurs_getstr\fR(3X).