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