Debian Codegraph @

upstream/debian-unstable/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.82 2025/10/21 00:04:35 tom Exp $
31 .TH instr 3NCURSES 2025-10-20 "ncurses 6.6" "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, int \fIn\fP);
70 .fi
71 .SH DESCRIPTION
72 .B \%winstr
73 extracts a string from a
74 .I curses
75 window
76 .IR win ","
77 starting at the cursor and stopping at the end of the line,
78 and stores it in
79 .IR str ","
80 terminating it with a null character
81 and
82 omitting any attributes and color pair identifier
83 that
84 .I curses
85 associates with each character.
86 .B \%winnstr
87 does the same,
88 but copies at most
89 .I n
90 characters from
91 .IR win "."
92 A negative
93 .I n
94 implies no limit;
95 .B \%winnstr
96 then works like
97 .BR \%winstr "."
98 \fB\%ncurses\fP(3NCURSES) describes the variants of these functions.
99 .SH RETURN VALUE
100 These functions return the count of characters copied from
101 .I win
102 to
103 .I str
104 (not including the null terminator),
105 or
106 .B ERR
107 upon failure.
108 .PP
109 In
110 .IR \%ncurses ","
111 these functions fail if
112 .bP
113 the
114 .I curses
115 screen has not been initialized,
116 .bP
117 (for functions taking a
118 .I \%WINDOW
119 pointer argument)
120 .I win
121 is a null pointer,
122 or
123 .bP
124 .I str
125 is a null pointer.
126 .PP
127 Functions prefixed with \*(``mv\*('' first perform cursor movement and
128 fail if the position
129 .RI ( y ,
130 .IR x )
131 is outside the window boundaries.
132 .SH NOTES
133 All of these functions except
134 .B \%winnstr
135 may be implemented as macros.
136 .PP
137 Reading a line that overflows the array pointed to by
138 .I str
139 with
140 and its variants causes undefined results.
141 Instead,
142 use the
143 .IR n -infixed
144 functions with a positive
145 .I n
146 argument no larger than the size of the buffer backing
147 .IR str "."
148 .SH EXTENSIONS
149 .BR \%innstr ","
150 .BR \%winnstr ","
151 .BR \%mvinnstr ","
152 and
153 .BR \%mvwinnstr "'s"
154 acceptance of negative
155 .I n
156 values is an
157 .I \%ncurses
158 extension.
159 .SH PORTABILITY
160 Applications employing
161 .I \%ncurses
162 extensions should condition their use on the visibility of the
163 .B \%NCURSES_VERSION
164 preprocessor macro.
165 .PP
166 X/Open Curses Issue\ 4 describes these functions.
167 It specifies no error conditions for them.
168 .PP
169 X/Open Curses Issues 4 and 7 both state that
170 .IR \%instr ","
171 .IR \%winstr ","
172 .IR \%mvinstr ","
173 and
174 .I \%mvwinstr
175 return
176 .I OK
177 rather than a character count.
178 .\" X/Open Issue 4, Version 2, p. 117, PDF p. 137
179 .\" Issue 7 makes the same claim.
180 This is likely an erratum.
181 .bP
182 SVr3.1 and SVr4 implemented
183 .I \%winstr
184 as a wrapper around
185 .IR \%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 .SH SEE ALSO
211 \fB\%inwstr\fP(3NCURSES) describes comparable functions of the
212 .I \%ncurses
213 library in its wide-character configuration
214 .RI \%( ncursesw ).
215 .PP
216 \fB\%ncurses\fP(3NCURSES),
217 \fB\%inch\fP(3NCURSES),
218 \fB\%inchstr\fP(3NCURSES)