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