Debian Codegraph @

upstream/opensuse-leap-16-1/man3/instr.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 1998-2010,2017 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 .\"
30 .\" $Id: curs_instr.3x,v 1.74 2025/03/01 21:29:42 tom Exp $
31 .TH instr 3NCURSES 2025-03-01 "ncurses 6.5" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el .ds `` ""
39 .ie t .ds '' ''
40 .el .ds '' ""
41 .\}
42 .
43 .de bP
44 .ie n .IP \(bu 4
45 .el .IP \(bu 2
46 ..
47 .SH NAME
48 \fB\%instr\fP,
49 \fB\%winstr\fP,
50 \fB\%mvinstr\fP,
51 \fB\%mvwinstr\fP,
52 \fB\%innstr\fP,
53 \fB\%winnstr\fP,
54 \fB\%mvinnstr\fP,
55 \fB\%mvwinnstr\fP \-
56 get a string from a \fIcurses\fR window
57 .SH SYNOPSIS
58 .nf
59 \fB#include <ncursesw/curses.h>
60 .PP
61 \fBint instr(char * \fIstr\fP);
62 \fBint winstr(WINDOW * \fIwin\fP, char * \fIstr\fP);
63 \fBint mvinstr(int \fIy\fP, int \fIx\fP, char * \fIstr\fP);
64 \fBint mvwinstr(WINDOW * \fIwin\fP, int \fIy\fP, int \fIx\fP, char * \fIstr\fP);
65 .PP
66 \fBint innstr(char * \fIstr\fP, int \fIn\fP);
67 \fBint winnstr(WINDOW * \fIwin\fP, char * \fIstr\fP, int \fIn\fP);
68 \fBint mvinnstr(int \fIy\fP, int \fIx\fP, char * \fIstr\fP, int \fIn\fP);
69 \fBint mvwinnstr(WINDOW * \fIwin\fP, int \fIy\fP, int \fIx\fP, char * \fIstr\fP,
70 int \fIn\fP);
71 .fi
72 .SH DESCRIPTION
73 .B \%winstr
74 extracts a string from a
75 .I curses
76 window
77 .IR win ","
78 starting at the cursor and stopping at the end of the line,
79 and stores it in
80 .IR str ","
81 terminating it with a null character
82 and
83 omitting any attributes and color pair identifier
84 that
85 .I curses
86 associates with each character.
87 .B \%winnstr
88 does the same,
89 but copies at most
90 .I n
91 characters from
92 .IR win "."
93 A negative
94 .I n
95 implies no limit;
96 .B \%winnstr
97 then works like
98 .BR \%winstr "."
99 \fB\%ncurses\fP(3NCURSES) describes the variants of these functions.
100 .SH RETURN VALUE
101 These functions return the count of characters copied from
102 .I win
103 to
104 .IR str ","
105 or
106 .B ERR
107 upon failure.
108 .PP
109 In
110 .IR \%ncurses ","
111 these functions return
112 .B ERR
113 if
114 .bP
115 the
116 .I curses
117 screen has not been initialized,
118 .bP
119 (for functions taking a
120 .I \%WINDOW
121 pointer argument)
122 .I win
123 is a null pointer,
124 or
125 .bP
126 .I str
127 is a null pointer.
128 .PP
129 Functions prefixed with \*(``mv\*('' first perform cursor movement and
130 fail if the position
131 .RI ( y ,
132 .IR x )
133 is outside the window boundaries.
134 .SH NOTES
135 All of these functions except
136 .B \%winnstr
137 may be implemented as macros.
138 .PP
139 Reading a line that overflows the array pointed to by
140 .I str
141 with
142 .BR \%instr ","
143 .BR \%winstr ","
144 .BR \%mvinstr ","
145 or
146 .B \%mvwinstr
147 causes undefined results.
148 Use of
149 .BR \%innstr ","
150 .BR \%winnstr ","
151 .BR \%mvinnstr ","
152 and
153 .B \%mvwinnstr
154 is recommended instead.
155 .SH EXTENSIONS
156 .BR \%innstr ","
157 .BR \%winnstr ","
158 .BR \%mvinnstr ","
159 and
160 .BR \%mvwinnstr "'s"
161 acceptance of negative
162 .I n
163 values is an
164 .I \%ncurses
165 extension.
166 .SH PORTABILITY
167 Applications employing
168 .I \%ncurses
169 extensions should condition their use on the visibility of the
170 .B \%NCURSES_VERSION
171 preprocessor macro.
172 .PP
173 X/Open Curses Issue\ 4 describes these functions.
174 It specifies no error conditions for them.
175 .PP
176 X/Open Curses Issues 4 and 7 both state that
177 .IR \%instr ","
178 .IR \%winstr ","
179 .IR \%mvinstr ","
180 and
181 .I \%mvwinstr
182 return
183 .I OK
184 rather than a character count.
185 This is likely an erratum.
186 .bP
187 SVr3.1 and SVr4 implemented
188 .I \%winstr
189 as a wrapper around
190 .IR \%winnstr ","
191 returning the latter's return value.
192 X/Open Curses's specification thus may have been an editorial solecism
193 copied from System\ V's documentation
194 (see below)
195 by X/Open,
196 rather than an intentional change.
197 .bP
198 .I \%ncurses
199 retains compatibility with System\ V
200 .I curses
201 behavior.
202 .PP
203 SVr4 describes a successful return value only as
204 \*(``an integer value other than
205 .IR ERR \*(''. \" Courier roman in source; SVID 4, vol. 3, p. 503
206 .PP
207 SVr4 does not
208 document whether
209 .I n
210 counts the null terminator that these functions write to
211 .IR str "."
212 .SH HISTORY
213 SVr3.1 (1987)
214 introduced these functions.
215 .SH SEE ALSO
216 \fB\%inwstr\fP(3NCURSES) describes comparable functions of the
217 .I \%ncurses
218 library in its wide-character configuration
219 .RI \%( ncursesw ).
220 .PP
221 \fB\%ncurses\fP(3NCURSES),
222 \fB\%inch\fP(3NCURSES),
223 \fB\%inchstr\fP(3NCURSES)