]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_kernel.3x
ncurses 6.5 - patch 20240525
[ncurses.git] / man / curs_kernel.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,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_kernel.3x,v 1.63 2024/05/25 21:13:56 tom Exp $
31 .TH curs_kernel 3X 2024-05-25 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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\%def_prog_mode\fP,
49 \fB\%def_shell_mode\fP,
50 \fB\%reset_prog_mode\fP,
51 \fB\%reset_shell_mode\fP,
52 \fB\%resetty\fP,
53 \fB\%savetty\fP,
54 \fB\%getsyx\fP,
55 \fB\%setsyx\fP,
56 \fB\%curs_set\fP,
57 \fB\%mvcur\fP,
58 \fB\%napms\fP,
59 \fB\%ripoffline\fP \-
60 low-level \fIcurses\fR routines
61 .SH SYNOPSIS
62 .nf
63 \fB#include <curses.h>
64 .PP
65 \fBint def_prog_mode(void);
66 \fBint def_shell_mode(void);
67 .PP
68 \fBint reset_prog_mode(void);
69 \fBint reset_shell_mode(void);
70 .PP
71 \fBint resetty(void);
72 \fBint savetty(void);
73 .PP
74 \fBvoid getsyx(int \fIy\fP, int \fIx\fP);
75 \fBvoid setsyx(int \fIy\fP, int \fIx\fP);
76 .PP
77 \fBint curs_set(int \fIvisibility\fP);
78 \fBint mvcur(int \fIoldrow\fP, int \fIoldcol\fP, int \fInewrow\fP, int \fInewcol\fP);
79 \fBint napms(int \fIms\fP);
80 \fBint ripoffline(int \fIline\fP, int (*\fIinit\fP)(WINDOW *, int));
81 .fi
82 .SH DESCRIPTION
83 The following routines give low-level access
84 to various \fBcurses\fP capabilities.
85 These routines typically are used inside library routines.
86 .SS "def_prog_mode, def_shell_mode"
87 The \fBdef_prog_mode\fP and \fBdef_shell_mode\fP routines save the
88 current terminal modes as the \*(``program\*(''
89 (in \fBcurses\fP) or \*(``shell\*(''
90 (not in \fBcurses\fP) state for use by the \fBreset_prog_mode\fP and
91 \fBreset_shell_mode\fP routines.
92 This is done automatically by \fBinitscr\fP.
93 There is one such save area for each screen context
94 allocated by \fBnewterm\fP.
95 .SS "reset_prog_mode, reset_shell_mode"
96 The \fBreset_prog_mode\fP and \fBreset_shell_mode\fP routines restore
97 the terminal to \*(``program\*('' (in \fBcurses\fP) or \*(``shell\*('' (out of
98 \fBcurses\fP) state.
99 These are done automatically by \fBendwin\fP(3X) and,
100 after an \fBendwin\fP, by \fBdoupdate\fP,
101 so they normally are not called.
102 .SS "resetty, savetty"
103 The \fBresetty\fP and \fBsavetty\fP routines save and restore the
104 state of the terminal modes.
105 \fBsavetty\fP saves the current state in
106 a buffer and \fBresetty\fP restores the state to what it was at the
107 last call to \fBsavetty\fP.
108 .SS getsyx
109 The \fBgetsyx\fP routine returns the current coordinates
110 of the \fIvirtual screen\fP cursor in \fIy\fP and \fIx\fP.
111 If \fBleaveok\fP is currently \fBTRUE\fP, then
112 \fB\-1\fP,\fB\-1\fP is returned.
113 If lines have been removed from the top of the
114 screen, using \fBripoffline\fP, \fIy\fP and \fIx\fP include these lines;
115 therefore, \fIy\fP and \fIx\fP should be used only as arguments for
116 \fBsetsyx\fP.
117 .PP
118 Few applications will use this feature,
119 most use \fBgetyx\fP instead.
120 .SS setsyx
121 The \fBsetsyx\fP routine sets
122 the \fIvirtual screen\fP cursor to \fIy\fP, \fIx\fP.
123 If \fIy\fP and \fIx\fP are both \fB\-1\fP, then
124 \fBleaveok\fP is set.
125 The two routines \fBgetsyx\fP and \fBsetsyx\fP
126 are designed to be used by a library routine, which manipulates
127 \fBcurses\fP windows but does not want to change the current position
128 of the program's cursor.
129 The library routine would call \fBgetsyx\fP
130 at the beginning, do its manipulation of its own windows, do a
131 \fBwnoutrefresh\fP on its windows, call \fBsetsyx\fP, and then call
132 \fBdoupdate\fP.
133 .PP
134 Few applications will use this feature,
135 most use \fBwmove\fP instead.
136 .SS curs_set
137 The \fBcurs_set\fP routine sets the cursor state to invisible,
138 normal, or very visible for \fBvisibility\fP equal to \fB0\fP,
139 \fB1\fP, or \fB2\fP respectively.
140 If the terminal supports the \fIvisibility\fP requested,
141 the previous \fIcursor\fP state is returned;
142 otherwise, \fBERR\fP is returned.
143 .SS mvcur
144 .B \%mvcur
145 provides low-level cursor motion.
146 It takes effect immediately,
147 rather than at the next refresh.
148 Unlike the other low-level output functions,
149 which either write to the standard output stream
150 or are passed a function pointer to perform output,
151 .B \%mvcur
152 uses a file descriptor derived from the output stream parameter of
153 \fB\%newterm\fP(3X).
154 .PP
155 One application of
156 .B \%mvcur
157 accompanies the temporary use of another program to write to the
158 terminal screen.
159 For example,
160 first call \fB\%refresh\fP(3X) to ensure that the screen and the
161 library's model of it is up to date;
162 then call
163 .BR \%reset_shell_mode ";"
164 write to the screen with the external application;
165 call
166 .BR \%reset_prog_mode ";"
167 and finally call
168 .B \%mvcur
169 to set the cursor's location to where
170 .I \%curses
171 thinks it is,
172 since the library has no knowledge of how the external application
173 moved it.
174 .\" https://lists.gnu.org/archive/html/bug-ncurses/2016-10/msg00002.html
175 .SS napms
176 .B \%napms
177 sleeps for
178 .I ms
179 milliseconds.
180 If
181 .I ms
182 exceeds 30,000
183 (thirty seconds),
184 it is capped at that value.
185 .SS ripoffline
186 .B \%ripoffline
187 provides access to the same facility that \fB\%slk_init\fP(3X) uses to
188 reduce the size of the screen.
189 \fB\%ripoffline\fP must be called before \fBinitscr\fP or
190 \fBnewterm\fP is called, to prepare these initial actions:
191 .bP
192 If \fIline\fP is positive, a line is removed from the top of \fBstdscr\fP.
193 .bP
194 if \fIline\fP is negative, a line is removed from the bottom.
195 .PP
196 When the resulting initialization is done inside \fBinitscr\fP, the
197 routine \fBinit\fP (supplied by the user) is called with two
198 arguments:
199 .bP
200 a window pointer to the one-line window that has been
201 allocated and
202 .bP
203 an integer with the number of columns in the window.
204 .PP
205 Inside this initialization routine, the integer variables \fBLINES\fP
206 and \fBCOLS\fP (defined in \fB<curses.h>\fP) are not guaranteed to be
207 accurate and \fBwrefresh\fP or \fBdoupdate\fP must not be called.
208 It is allowable to call \fBwnoutrefresh\fP during the initialization routine.
209 .PP
210 \fBripoffline\fP can be called up to five times before calling \fBinitscr\fP or
211 \fBnewterm\fP.
212 .SH RETURN VALUE
213 Except for \fBcurs_set\fP, these routines always return \fBOK\fP.
214 .PP
215 \fBcurs_set\fP
216 returns the previous cursor state, or \fBERR\fP if the
217 requested \fIvisibility\fP is not supported.
218 .PP
219 X/Open defines no error conditions.
220 In this implementation
221 .TP 5
222 \fBdef_prog_mode\fP, \fBdef_shell_mode\fP, \fBreset_prog_mode\fP, \fBreset_shell_mode\fP
223 return
224 .B ERR
225 if the terminal was not initialized, or
226 if the I/O call to obtain the terminal settings fails.
227 .TP 5
228 \fBripoffline\fP
229 returns
230 .B ERR
231 if the maximum number of ripped-off lines
232 exceeds the maximum (5).
233 .SH NOTES
234 Note that \fBgetsyx\fP is a macro, so \fB&\fP is not necessary before
235 the variables \fIy\fP and \fIx\fP.
236 .PP
237 Older SVr4 man pages warn that the return value
238 of \fBcurs_set\fP \*(``is currently incorrect\*(''.
239 This implementation gets it right, but it may be unwise to count
240 on the correctness of the return value anywhere else.
241 .PP
242 Both \fI\%ncurses\fP and SVr4 will call \fBcurs_set\fP in \fBendwin\fP
243 if \fBcurs_set\fP
244 has been called to make the cursor other than normal, i.e., either
245 invisible or very visible.
246 There is no way for \fI\%ncurses\fP to determine the initial cursor
247 state to restore that.
248 .SH EXTENSIONS
249 In
250 .IR \%ncurses ","
251 .B \%mvcur
252 accepts
253 .B \-1
254 for either or both old coordinates.
255 This value tells
256 .I \%ncurses
257 that the old location is unknown,
258 and that it must use only absolute motion,
259 as with the
260 .B \%cursor_address
261 .RB ( cup )
262 capability,
263 rather than the least costly combination of absolute and relative
264 motion.
265 .SH PORTABILITY
266 The \fIvirtual screen\fP functions \fBsetsyx\fP and \fBgetsyx\fP
267 are not described in X/Open Curses, Issue 4.
268 All other functions are as described in X/Open Curses.
269 .PP
270 The SVr4 documentation describes \fBsetsyx\fP and \fBgetsyx\fP
271 as having return type int.
272 This is misleading, as they are macros with no documented semantics
273 for the return value.
274 .PP
275 X/Open Curses notes:
276 .RS
277 .PP
278 \*(``After use of
279 .IR \%mvcur "(),"
280 the model Curses maintains of the state of the terminal might not
281 match the actual state of the terminal.
282 An application should touch and refresh the window before
283 resuming conventional use of Curses.\*(''
284 .RE
285 .PP
286 Both
287 .I \%ncurses
288 and SVr4
289 .I curses
290 implement
291 .B \%mvcur
292 using the
293 .I SCREEN
294 data allocated in either \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X).
295 X/Open Curses states that the old location must be given for
296 .B \%mvcur
297 to accommodate terminals that lack absolute cursor positioning.
298 .\" X/Open Curses Issue 7, p. 161
299 .PP
300 If interrupted, \fI\%ncurses\fP restarts \fBnapms\fP.
301 That, and the limitation to 30 seconds,
302 are different from other implementations.
303 .SH SEE ALSO
304 \fB\%curses\fP(3X),
305 \fB\%curs_initscr\fP(3X),
306 \fB\%curs_outopts\fP(3X),
307 \fB\%curs_refresh\fP(3X),
308 \fB\%curs_scr_dump\fP(3X),
309 \fB\%curs_slk\fP(3X),
310 \fB\%curs_variables\fP(3X)