Debian Codegraph @

upstream/mageia-cauldron/man3/curs_instr.3x

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