blob: e548cf145c2580fb6000d7843c91c6d4fb6fadcc [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002.\" Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303.\" *
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.\"
Steve Kondikae271bc2015-11-15 02:50:53 +010029.\" $Id: curs_getstr.3x,v 1.19 2010/12/04 18:36:44 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053030.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,
Steve Kondikae271bc2015-11-15 02:50:53 +010041\fBmvwgetnstr\fR \- accept character strings from \fBcurses\fR terminal keyboard
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053042.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
64The function \fBgetstr\fR is equivalent to a series of calls to \fBgetch\fR,
65until a newline or carriage return is received (the terminating character is
66not included in the returned string). The resulting value is placed in the
67area pointed to by the character pointer \fIstr\fR.
68.PP
69\fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
70overflow of the input buffer. Any attempt to enter more characters (other
71than the terminating newline or carriage return) causes a beep. Function
72keys also cause a beep and are ignored. The \fBgetnstr\fR function reads
73from the \fIstdscr\fR default window.
74.PP
75The user's erase and kill characters are interpreted. If keypad
76mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
77are both considered equivalent to the user's kill character.
78.PP
79Characters input are echoed only if \fBecho\fR is currently on. In that case,
80backspace is echoed as deletion of the previous character (typically a left
81motion).
82.SH RETURN VALUE
83All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
84specifies only "an integer value other than \fBERR\fR") upon successful
85completion.
86.PP
87X/Open defines no error conditions.
88.PP
89In this implementation,
90these functions return an error
91if the window pointer is null, or
92if its timeout expires without having any data.
93.PP
94This implementation provides an extension as well.
95If a SIGWINCH interrupts the function, it will return \fBKEY_RESIZE\fP
96rather than \fBOK\fP or \fBERR\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +010097.PP
98Functions with a "mv" prefix first perform a cursor movement using
99\fBwmove\fP, and return an error if the position is outside the window,
100or if the window pointer is null.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530101.SH NOTES
102Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
103.SH PORTABILITY
104These functions are described in the XSI Curses standard, Issue 4.
105They read single-byte characters only.
106The standard does not define any error conditions.
107This implementation returns ERR if the window pointer is null,
108or if the lower-level \fBwgetch\fR call returns an ERR.
109.PP
110SVr3 and early SVr4 curses implementations did not reject function keys;
111the SVr4.0 documentation claimed that "special keys" (such as function
112keys, "home" key, "clear" key, \fIetc\fR.) are "interpreted", without
113giving details. It lied. In fact, the `character' value appended to the
114string 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
117The functions \fBgetnstr\fR, \fBmvgetnstr\fR, and \fBmvwgetnstr\fR were
118present but not documented in SVr4.
119.SH SEE ALSO
Steve Kondikae271bc2015-11-15 02:50:53 +0100120\fBcurses\fR(3X),
121\fBcurs_getch\fR(3X),
122\fBcurs_variables\fR(3X).