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