]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getstr.3x
ncurses 6.0 - patch 20170812
[ncurses.git] / man / curs_getstr.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2010,2017 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_getstr.3x,v 1.22 2017/05/30 21:08:31 tom Exp $
30 .TH curs_getstr 3X ""
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .na
36 .hy 0
37 .SH NAME
38 \fBgetstr\fR,
39 \fBgetnstr\fR,
40 \fBwgetstr\fR,
41 \fBwgetnstr\fR,
42 \fBmvgetstr\fR,
43 \fBmvgetnstr\fR,
44 \fBmvwgetstr\fR,
45 \fBmvwgetnstr\fR \- accept character strings from \fBcurses\fR terminal keyboard
46 .ad
47 .hy
48 .SH SYNOPSIS
49 \fB#include <curses.h>\fR
50 .sp
51 \fBint getstr(char *str);\fR
52 .br
53 \fBint getnstr(char *str, int n);\fR
54 .br
55 \fBint wgetstr(WINDOW *win, char *str);\fR
56 .br
57 \fBint wgetnstr(WINDOW *win, char *str, int n);\fR
58 .br
59 \fBint mvgetstr(int y, int x, char *str);\fR
60 .br
61 \fBint mvwgetstr(WINDOW *win, int y, int x, char *str);\fR
62 .br
63 \fBint mvgetnstr(int y, int x, char *str, int n);\fR
64 .br
65 \fBint mvwgetnstr(WINDOW *, int y, int x, char *str, int n);\fR
66 .br
67 .SH DESCRIPTION
68 The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
69 until a newline or carriage return is received (the terminating character is
70 not included in the returned string).  The resulting value is placed in the
71 area pointed to by the character pointer \fIstr\fR.
72 .PP
73 \fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
74 overflow of the input buffer.  Any attempt to enter more characters (other
75 than the terminating newline or carriage return) causes a beep.  Function
76 keys also cause a beep and are ignored.  The \fBgetnstr\fR function reads
77 from the \fIstdscr\fR default window.
78 .PP
79 The user's erase and kill characters are interpreted.  If keypad
80 mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
81 are both considered equivalent to the user's kill character.
82 .PP
83 Characters input are echoed only if \fBecho\fR is currently on.  In that case,
84 backspace is echoed as deletion of the previous character (typically a left
85 motion).
86 .SH RETURN VALUE
87 All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
88 specifies only \*(``an integer value other than \fBERR\fR\*('') upon successful
89 completion.
90 .PP
91 X/Open defines no error conditions.
92 .PP
93 In this implementation,
94 these functions return an error
95 if the window pointer is null, or
96 if its timeout expires without having any data.
97 .PP
98 This implementation provides an extension as well.
99 If a \fBSIGWINCH\fP interrupts the function, it will return \fBKEY_RESIZE\fP
100 rather than \fBOK\fP or \fBERR\fP.
101 .PP
102 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
103 \fBwmove\fP, and return an error if the position is outside the window,
104 or if the window pointer is null.
105 .SH NOTES
106 Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
107 .SH PORTABILITY
108 These functions are described in the XSI Curses standard, Issue 4.
109 They read single-byte characters only.
110 The standard does not define any error conditions.
111 This implementation returns ERR if the window pointer is null,
112 or if the lower-level \fBwgetch\fR(3X) call returns an ERR.
113 .PP
114 SVr3 and early SVr4 curses implementations did not reject function keys;
115 the SVr4.0 documentation claimed that \*(``special keys\*(''
116 (such as function keys,
117 \*(``home\*('' key,
118 \*(``clear\*('' key,
119 \fIetc\fR.) are \*(``interpreted\*('',
120 without giving details.
121 It lied.
122 In fact, the \*(``character\*('' value appended to the
123 string by those implementations was predictable but not useful
124 (being, in fact, the low-order eight bits of the key's KEY_ value).
125 .PP
126 The functions \fBgetnstr\fR, \fBmvgetnstr\fR, and \fBmvwgetnstr\fR were
127 present but not documented in SVr4.
128 .SH SEE ALSO
129 \fBcurses\fR(3X),
130 \fBcurs_getch\fR(3X),
131 \fBcurs_variables\fR(3X).