1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 Thomas E. Dickey *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
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: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
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. *
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 *
28 .\"***************************************************************************
30 .\" $Id: curs_kernel.3x,v 1.67 2024/06/22 21:24:26 tom Exp $
31 .TH curs_kernel 3X 2024-06-22 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
48 \fB\%def_prog_mode\fP,
49 \fB\%def_shell_mode\fP,
50 \fB\%reset_prog_mode\fP,
51 \fB\%reset_shell_mode\fP,
60 low-level \fIcurses\fR routines
63 \fB#include <curses.h>
65 \fBint def_prog_mode(void);
66 \fBint def_shell_mode(void);
68 \fBint reset_prog_mode(void);
69 \fBint reset_shell_mode(void);
74 \fBvoid getsyx(int \fIy\fP, int \fIx\fP);
75 \fBvoid setsyx(int \fIy\fP, int \fIx\fP);
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));
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
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.
110 stores the coordinates of virtual screen
118 \fB\%leaveok\fP(3X) output option is
127 If lines have been removed from the top of the screen using
130 includes these lines;
137 should be used only as arguments for
140 Few applications use this feature;
141 most call \fB\%getyx\fP(3X) instead.
144 sets the virtual screen
149 .B "\%setsyx(\-1, \-1)"
151 .BR "\%leaveok(newscr, TRUE)" "."
156 are designed to be used by a function that manipulates
158 windows but seeks to avoid changing the cursor position.
159 Such a function would first call
161 modify its windows' content,
162 call \fB\%wnoutrefresh\fP(3X) on them,
165 then call \fB\%doupdate\fP(3X).
167 Few applications use this feature;
168 most call \fB\%wmove\fP(3X) instead.
170 The \fBcurs_set\fP routine sets the cursor state to invisible,
171 normal, or very visible for \fBvisibility\fP equal to \fB0\fP,
172 \fB1\fP, or \fB2\fP respectively.
173 If the terminal supports the \fIvisibility\fP requested,
174 the previous \fIcursor\fP state is returned;
175 otherwise, \fBERR\fP is returned.
178 provides low-level cursor motion.
179 It takes effect immediately,
180 rather than at the next refresh.
181 Unlike the other low-level output functions,
182 which either write to the standard output stream
183 or are passed a function pointer to perform output,
185 uses a file descriptor derived from the output stream parameter of
190 accompanies the temporary use of another program to write to the
193 first call \fB\%refresh\fP(3X) to ensure that the screen and the
194 library's model of it is up to date;
196 .BR \%reset_shell_mode ";"
197 write to the screen with the external application;
199 .BR \%reset_prog_mode ";"
201 .BR \%mvcur( ".\|.\|." ,
204 to move the terminal cursor to where
207 since the library has no knowledge of how the external application
209 .\" https://lists.gnu.org/archive/html/bug-ncurses/2016-10/msg00002.html
219 it is capped at that value.
222 provides access to the same facility that \fB\%slk_init\fP(3X) uses to
223 reduce the size of the screen.
224 \fB\%ripoffline\fP must be called before \fBinitscr\fP or
225 \fBnewterm\fP is called, to prepare these initial actions:
227 If \fIline\fP is positive, a line is removed from the top of \fBstdscr\fP.
229 if \fIline\fP is negative, a line is removed from the bottom.
231 When the resulting initialization is done inside \fBinitscr\fP, the
232 routine \fBinit\fP (supplied by the user) is called with two
235 a window pointer to the one-line window that has been
238 an integer with the number of columns in the window.
240 Inside this initialization routine, the integer variables \fBLINES\fP
241 and \fBCOLS\fP (defined in \fB<curses.h>\fP) are not guaranteed to be
242 accurate and \fBwrefresh\fP or \fBdoupdate\fP must not be called.
243 It is allowable to call \fBwnoutrefresh\fP during the initialization routine.
245 \fBripoffline\fP can be called up to five times before calling \fBinitscr\fP or
248 Except for \fBcurs_set\fP, these routines always return \fBOK\fP.
251 returns the previous cursor state, or \fBERR\fP if the
252 requested \fIvisibility\fP is not supported.
254 X/Open defines no error conditions.
255 In this implementation
257 \fBdef_prog_mode\fP, \fBdef_shell_mode\fP, \fBreset_prog_mode\fP, \fBreset_shell_mode\fP
260 if the terminal was not initialized, or
261 if the I/O call to obtain the terminal settings fails.
266 if the maximum number of ripped-off lines
267 exceeds the maximum (5).
269 Note that \fBgetsyx\fP is a macro, so \fB&\fP is not necessary before
270 the variables \fIy\fP and \fIx\fP.
272 Older SVr4 man pages warn that the return value
273 of \fBcurs_set\fP \*(``is currently incorrect\*(''.
274 This implementation gets it right, but it may be unwise to count
275 on the correctness of the return value anywhere else.
277 Both \fI\%ncurses\fP and SVr4 will call \fBcurs_set\fP in \fBendwin\fP
279 has been called to make the cursor other than normal, i.e., either
280 invisible or very visible.
281 There is no way for \fI\%ncurses\fP to determine the initial cursor
282 state to restore that.
289 for either or both old coordinates.
292 that the old location is unknown,
293 and that it must use only absolute motion,
298 rather than the least costly combination of absolute and relative
301 Applications employing
303 extensions should condition their use on the visibility of the
307 The \fIvirtual screen\fP functions \fBsetsyx\fP and \fBgetsyx\fP
308 are not described in X/Open Curses, Issue 4.
309 All other functions are as described in X/Open Curses.
311 The SVr4 documentation describes \fBsetsyx\fP and \fBgetsyx\fP
312 as having return type int.
313 This is misleading, as they are macros with no documented semantics
314 for the return value.
321 the model Curses maintains of the state of the terminal might not
322 match the actual state of the terminal.
323 An application should touch and refresh the window before
324 resuming conventional use of Curses.\*(''
335 data allocated in either \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X).
336 X/Open Curses states that the old location must be given for
338 to accommodate terminals that lack absolute cursor positioning.
339 .\" X/Open Curses Issue 7, p. 161
341 If interrupted, \fI\%ncurses\fP restarts \fBnapms\fP.
342 That, and the limitation to 30 seconds,
343 are different from other implementations.
346 \fB\%curs_initscr\fP(3X),
347 \fB\%curs_outopts\fP(3X),
348 \fB\%curs_refresh\fP(3X),
349 \fB\%curs_scr_dump\fP(3X),
350 \fB\%curs_slk\fP(3X),
351 \fB\%curs_variables\fP(3X)