]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/curs_getstr.3x.html
ncurses 6.2 - patch 20200222
[ncurses.git] / doc / html / man / curs_getstr.3x.html
1 <!-- 
2   ****************************************************************************
3   * Copyright 2018-2019,2020 Thomas E. Dickey                                *
4   * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
5   *                                                                          *
6   * Permission is hereby granted, free of charge, to any person obtaining a  *
7   * copy of this software and associated documentation files (the            *
8   * "Software"), to deal in the Software without restriction, including      *
9   * without limitation the rights to use, copy, modify, merge, publish,      *
10   * distribute, distribute with modifications, sublicense, and/or sell       *
11   * copies of the Software, and to permit persons to whom the Software is    *
12   * furnished to do so, subject to the following conditions:                 *
13   *                                                                          *
14   * The above copyright notice and this permission notice shall be included  *
15   * in all copies or substantial portions of the Software.                   *
16   *                                                                          *
17   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24   *                                                                          *
25   * Except as contained in this notice, the name(s) of the above copyright   *
26   * holders shall not be used in advertising or otherwise to promote the     *
27   * sale, use or other dealings in this Software without prior written       *
28   * authorization.                                                           *
29   ****************************************************************************
30   * @Id: curs_getstr.3x,v 1.29 2020/02/02 23:34:34 tom Exp @
31   * X/Open says also until EOf
32   * X/Open says then an EOS is added to the result
33   * X/Open doesn't mention n&lt;0
34 -->
35 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
36 <HTML>
37 <HEAD>
38 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
39 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
40 <TITLE>curs_getstr 3x</TITLE>
41 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
43 </HEAD>
44 <BODY>
45 <H1 class="no-header">curs_getstr 3x</H1>
46 <PRE>
47 <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>                                                <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>
48
49
50
51
52 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
53        <STRONG>getstr</STRONG>, <STRONG>getnstr</STRONG>, <STRONG>wgetstr</STRONG>, <STRONG>wgetnstr</STRONG>, <STRONG>mvgetstr</STRONG>, <STRONG>mvgetnstr</STRONG>, <STRONG>mvwgetstr</STRONG>,
54        <STRONG>mvwgetnstr</STRONG> - accept character strings from <STRONG>curses</STRONG> terminal keyboard
55
56
57 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
58        <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
59
60        <STRONG>int</STRONG> <STRONG>getstr(char</STRONG> <STRONG>*str);</STRONG>
61        <STRONG>int</STRONG> <STRONG>getnstr(char</STRONG> <STRONG>*str,</STRONG> <STRONG>int</STRONG> <STRONG>n);</STRONG>
62        <STRONG>int</STRONG> <STRONG>wgetstr(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>char</STRONG> <STRONG>*str);</STRONG>
63        <STRONG>int</STRONG> <STRONG>wgetnstr(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>char</STRONG> <STRONG>*str,</STRONG> <STRONG>int</STRONG> <STRONG>n);</STRONG>
64        <STRONG>int</STRONG> <STRONG>mvgetstr(int</STRONG> <STRONG>y,</STRONG> <STRONG>int</STRONG> <STRONG>x,</STRONG> <STRONG>char</STRONG> <STRONG>*str);</STRONG>
65        <STRONG>int</STRONG> <STRONG>mvwgetstr(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>int</STRONG> <STRONG>y,</STRONG> <STRONG>int</STRONG> <STRONG>x,</STRONG> <STRONG>char</STRONG> <STRONG>*str);</STRONG>
66        <STRONG>int</STRONG> <STRONG>mvgetnstr(int</STRONG> <STRONG>y,</STRONG> <STRONG>int</STRONG> <STRONG>x,</STRONG> <STRONG>char</STRONG> <STRONG>*str,</STRONG> <STRONG>int</STRONG> <STRONG>n);</STRONG>
67        <STRONG>int</STRONG> <STRONG>mvwgetnstr(WINDOW</STRONG> <STRONG>*,</STRONG> <STRONG>int</STRONG> <STRONG>y,</STRONG> <STRONG>int</STRONG> <STRONG>x,</STRONG> <STRONG>char</STRONG> <STRONG>*str,</STRONG> <STRONG>int</STRONG> <STRONG>n);</STRONG>
68
69
70 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
71        The function <STRONG>getstr</STRONG> is equivalent to a series of calls to <STRONG>getch</STRONG>,  until
72        a  newline or carriage return is received (the terminating character is
73        not included in the returned string).  The resulting value is placed in
74        the area pointed to by the character pointer <EM>str</EM>, followed by a NUL.
75
76        <STRONG>wgetnstr</STRONG>  reads  at most <EM>n</EM> characters, thus preventing a possible over-
77        flow of the input buffer.  Any attempt to enter more characters  (other
78        than  the terminating newline or carriage return) causes a beep.  Func-
79        tion keys also cause a beep and  are  ignored.   The  <STRONG>getnstr</STRONG>  function
80        reads from the <EM>stdscr</EM> default window.
81
82        The  user's  erase and kill characters are interpreted.  If keypad mode
83        is on for the window, <STRONG>KEY_LEFT</STRONG> and <STRONG>KEY_BACKSPACE</STRONG>  are  both  considered
84        equivalent to the user's kill character.
85
86        Characters  input  are  echoed  only  if <STRONG>echo</STRONG> is currently on.  In that
87        case, backspace is echoed as deletion of the previous character  (typi-
88        cally a left motion).
89
90
91 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
92        All routines return the integer <STRONG>ERR</STRONG> upon failure and an <STRONG>OK</STRONG> (SVr4 speci-
93        fies only "an integer value other than <STRONG>ERR</STRONG>")  upon  successful  comple-
94        tion.
95
96        X/Open defines no error conditions.
97
98        In  this  implementation, these functions return an error if the window
99        pointer is null, or if its timeout expires without having any data.
100
101        This implementation provides an extension as well.  If a  <STRONG>SIGWINCH</STRONG>  in-
102        terrupts the function, it will return <STRONG>KEY_RESIZE</STRONG> rather than <STRONG>OK</STRONG> or <STRONG>ERR</STRONG>.
103
104        Functions  with  a  "mv"  prefix  first perform a cursor movement using
105        <STRONG>wmove</STRONG>, and return an error if the position is outside the window, or if
106        the window pointer is null.
107
108
109 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
110        Note that <STRONG>getstr</STRONG>, <STRONG>mvgetstr</STRONG>, and <STRONG>mvwgetstr</STRONG> may be macros.
111
112
113 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
114        These  functions  are  described  in  the XSI Curses standard, Issue 4.
115        They read single-byte characters only.  The standard  does  not  define
116        any  error  conditions.   This implementation returns <STRONG>ERR</STRONG> if the window
117        pointer is null, or if the lower-level <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG> call returns an <STRONG>ERR</STRONG>.
118
119        SVr3 and early SVr4 curses  implementations  did  not  reject  function
120        keys;  the  SVr4.0  documentation  claimed that "special keys" (such as
121        function keys, "home" key, "clear" key, <EM>etc</EM>.) are "interpreted",  with-
122        out  giving details.  It lied.  In fact, the "character" value appended
123        to the 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
126        The  functions  <STRONG>getnstr</STRONG>, <STRONG>mvgetnstr</STRONG>, and <STRONG>mvwgetnstr</STRONG> were present but not
127        documented in SVr4.
128
129        X/Open Curses, Issue 5 (2007) stated that these functions "read at most
130        <EM>n</EM>  bytes"  but  did not state whether the terminating NUL is counted in
131        that limit.  X/Open Curses, Issue 7 (2009) changed  that  to  say  they
132        "read at most <EM>n</EM>-1 bytes" to allow for the terminating NUL.  As of 2018,
133        some implementations do, some do not count it:
134
135        <STRONG>o</STRONG>   ncurses 6.1 and PDCurses do not count the NUL in the  given  limit,
136            while
137
138        <STRONG>o</STRONG>   Solaris SVr4 and NetBSD curses count the NUL as part of the limit.
139
140        <STRONG>o</STRONG>   Solaris  xcurses  provides  both:  its wide-character <STRONG>wget_nstr</STRONG> re-
141            serves a NUL, but its <STRONG>wgetnstr</STRONG> does not count the NUL consistently.
142
143        In SVr4 curses, a negative value of <EM>n</EM> tells <STRONG>wgetnstr</STRONG> to assume that the
144        caller's  buffer  is large enough to hold the result, i.e., to act like
145        <STRONG>wgetstr</STRONG>.  X/Open Curses does not mention this (or anything  related  to
146        negative  or  zero  values  of <EM>n</EM>), however most implementations use the
147        feature, with different limits:
148
149        <STRONG>o</STRONG>   Solaris SVr4 curses and PDCurses limit the  result  to  255  bytes.
150            Other Unix systems than Solaris are likely to use the same limit.
151
152        <STRONG>o</STRONG>   Solaris xcurses limits the result to <STRONG>LINE_MAX</STRONG> bytes.
153
154        <STRONG>o</STRONG>   NetBSD  7  assumes no particular limit for the result from <STRONG>wgetstr</STRONG>.
155            However, it limits the <STRONG>wgetnstr</STRONG> parameter <EM>n</EM> to ensure  that  it  is
156            greater than zero.
157
158            A  comment in NetBSD's source code states that this is specified in
159            SUSv2.
160
161        <STRONG>o</STRONG>   ncurses (before 6.2) assumes no particular  limit  for  the  result
162            from  <STRONG>wgetstr</STRONG>,  and  treats  the  <EM>n</EM> parameter of <STRONG>wgetnstr</STRONG> like SVr4
163            curses.
164
165        <STRONG>o</STRONG>   ncurses 6.2 uses <STRONG>LINE_MAX</STRONG>, or  a  larger  (system-dependent)  value
166            which  the  <STRONG>sysconf</STRONG>  function  may provide.  If neither <STRONG>LINE_MAX</STRONG> or
167            <STRONG>sysconf</STRONG> is available, ncurses uses the POSIX value for <STRONG>LINE_MAX</STRONG>  (a
168            2048  byte limit).  In either case, it reserves a byte for the ter-
169            minating NUL.
170
171
172 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
173        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>, <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>.
174
175
176
177                                                                <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>
178 </PRE>
179 <div class="nav">
180 <ul>
181 <li><a href="#h2-NAME">NAME</a></li>
182 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
183 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
184 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
185 <li><a href="#h2-NOTES">NOTES</a></li>
186 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
187 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
188 </ul>
189 </div>
190 </BODY>
191 </HTML>