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