]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getstr.3x
74c690d2f97346612d7a036c9d0ccbfc1cd34258
[ncurses.git] / man / curs_getstr.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2017,2018 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.24 2018/07/28 21:34:56 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).
71 The resulting value is placed in the
72 area pointed to by the character pointer \fIstr\fR.
73 .PP
74 \fBwgetnstr\fR reads at most \fIn\fR characters, thus preventing a possible
75 overflow of the input buffer.
76 Any attempt to enter more characters (other
77 than the terminating newline or carriage return) causes a beep.
78 Function
79 keys also cause a beep and are ignored.
80 The \fBgetnstr\fR function reads
81 from the \fIstdscr\fR default window.
82 .PP
83 The user's erase and kill characters are interpreted.
84 If keypad
85 mode is on for the window, \fBKEY_LEFT\fR and \fBKEY_BACKSPACE\fR
86 are both considered equivalent to the user's kill character.
87 .PP
88 Characters input are echoed only if \fBecho\fR is currently on.
89 In that case,
90 backspace is echoed as deletion of the previous character (typically a left
91 motion).
92 .SH RETURN VALUE
93 All routines return the integer \fBERR\fR upon failure and an \fBOK\fR (SVr4
94 specifies only \*(``an integer value other than \fBERR\fR\*('') upon successful
95 completion.
96 .PP
97 X/Open defines no error conditions.
98 .PP
99 In this implementation,
100 these functions return an error
101 if the window pointer is null, or
102 if its timeout expires without having any data.
103 .PP
104 This implementation provides an extension as well.
105 If a \fBSIGWINCH\fP interrupts the function, it will return \fBKEY_RESIZE\fP
106 rather than \fBOK\fP or \fBERR\fP.
107 .PP
108 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
109 \fBwmove\fP, and return an error if the position is outside the window,
110 or if the window pointer is null.
111 .SH NOTES
112 Note that \fBgetstr\fR, \fBmvgetstr\fR, and \fBmvwgetstr\fR may be macros.
113 .SH PORTABILITY
114 These functions are described in the XSI Curses standard, Issue 4.
115 They read single-byte characters only.
116 The standard does not define any error conditions.
117 This implementation returns \fBERR\fP if the window pointer is null,
118 or if the lower-level \fBwgetch\fR(3X) call returns an \fBERR\fP.
119 .PP
120 SVr3 and early SVr4 curses implementations did not reject function keys;
121 the SVr4.0 documentation claimed that \*(``special keys\*(''
122 (such as function keys,
123 \*(``home\*('' key,
124 \*(``clear\*('' key,
125 \fIetc\fR.) are \*(``interpreted\*('',
126 without giving details.
127 It lied.
128 In fact, the \*(``character\*('' value appended to the
129 string by those implementations was predictable but not useful
130 (being, in fact, the low-order eight bits of the key's KEY_ value).
131 .PP
132 The functions \fBgetnstr\fR, \fBmvgetnstr\fR, and \fBmvwgetnstr\fR were
133 present but not documented in SVr4.
134 .SH SEE ALSO
135 \fBcurses\fR(3X),
136 \fBcurs_getch\fR(3X),
137 \fBcurs_variables\fR(3X).