Debian Codegraph @

upstream/debian-trixie/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.70 2025/02/01 22:54:06 tom Exp $
31 .TH instr 3NCURSES 2025-02-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 <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 they return
112 .B ERR
113 if
114 .bP
115 .I win
116 is
117 .I NULL
118 or
119 .bP
120 .I str
121 is
122 .IR NULL "."
123 .PP
124 Functions prefixed with \*(``mv\*('' first perform cursor movement and
125 fail if the position
126 .RI ( y ,
127 .IR x )
128 is outside the window boundaries.
129 .SH NOTES
130 All of these functions except
131 .B \%winnstr
132 may be implemented as macros.
133 .PP
134 Reading a line that overflows the array pointed to by
135 .I str
136 with
137 .BR \%instr ","
138 .BR \%winstr ","
139 .BR \%mvinstr ","
140 or
141 .B \%mvwinstr
142 causes undefined results.
143 Use of
144 .BR \%innstr ","
145 .BR \%winnstr ","
146 .BR \%mvinnstr ","
147 and
148 .B \%mvwinnstr
149 is recommended instead.
150 .SH EXTENSIONS
151 .BR \%innstr ","
152 .BR \%winnstr ","
153 .BR \%mvinnstr ","
154 and
155 .BR \%mvwinnstr "'s"
156 acceptance of negative
157 .I n
158 values is an
159 .I \%ncurses
160 extension.
161 .SH PORTABILITY
162 Applications employing
163 .I \%ncurses
164 extensions should condition their use on the visibility of the
165 .B \%NCURSES_VERSION
166 preprocessor macro.
167 .PP
168 X/Open Curses Issue\ 4 describes these functions.
169 It specifies no error conditions for them.
170 .PP
171 X/Open Curses Issues 4 and 7 both state that
172 .BR \%instr ","
173 .BR \%winstr ","
174 .BR \%mvinstr ","
175 and
176 .B \%mvwinstr
177 return
178 .B OK
179 rather than a character count.
180 This is likely an erratum.
181 .bP
182 SVr3.1 and SVr4 implemented
183 .B \%winstr
184 as a wrapper around
185 .BR \%winnstr ","
186 returning the latter's return value.
187 X/Open Curses's specification thus may have been an editorial solecism
188 copied from System\ V's documentation
189 (see below)
190 by X/Open,
191 rather than an intentional change.
192 .bP
193 .I \%ncurses
194 retains compatibility with System\ V
195 .I curses
196 behavior.
197 .PP
198 SVr4 describes a successful return value only as
199 \*(``an integer value other than
200 .IR ERR \*(''. \" Courier roman in source; SVID 4, vol. 3, p. 503
201 .PP
202 SVr4 does not
203 document whether
204 .I n
205 counts the null terminator that these functions write to
206 .IR str "."
207 .SH HISTORY
208 SVr3.1 (1987)
209 introduced these functions.
210 .IR winstr ","
211 .IR winnstr ","
212 and their variants.
213 .SH SEE ALSO
214 \fB\%inwstr\fP(3NCURSES) describes comparable functions of the
215 .I \%ncurses
216 library in its wide-character configuration
217 .RI \%( ncursesw ).
218 .PP
219 \fB\%ncurses\fP(3NCURSES),
220 \fB\%inch\fP(3NCURSES),
221 \fB\%inchstr\fP(3NCURSES)