blob: e85c132768a3460e3d7fbac9a7c0bbc8ca11aa82 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_kernel.3x,v 1.61 2024/04/20 21:24:19 tom Exp $
31.TH curs_kernel 3X 2024-04-20 "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.
Steve Kondikae271bc2015-11-15 02:50:53 +010043.de bP
micky3879b9f5e72025-07-08 18:04:53 -040044.ie n .IP \(bu 4
45.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010046..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040048\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\%ripoffline\fP,
57\fB\%curs_set\fP,
58\fB\%napms\fP \-
59low-level \fIcurses\fR routines
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053060.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040061.nf
62\fB#include <curses.h>
63.PP
64\fBint def_prog_mode(void);
65\fBint def_shell_mode(void);
66.PP
67\fBint reset_prog_mode(void);
68\fBint reset_shell_mode(void);
69.PP
70\fBint resetty(void);
71\fBint savetty(void);
72.PP
73\fBvoid getsyx(int \fIy\fP, int \fIx\fP);
74\fBvoid setsyx(int \fIy\fP, int \fIx\fP);
75.PP
76\fBint ripoffline(int \fIline\fP, int (*\fIinit\fP)(WINDOW *, int));
77\fBint curs_set(int \fIvisibility\fP);
78\fBint napms(int \fIms\fP);
79.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053080.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040081The following routines give low-level access
82to various \fBcurses\fP capabilities.
83These routines typically are used inside library routines.
84.SS "def_prog_mode, def_shell_mode"
85The \fBdef_prog_mode\fP and \fBdef_shell_mode\fP routines save the
86current terminal modes as the \*(``program\*(''
87(in \fBcurses\fP) or \*(``shell\*(''
88(not in \fBcurses\fP) state for use by the \fBreset_prog_mode\fP and
89\fBreset_shell_mode\fP routines.
90This is done automatically by \fBinitscr\fP.
91There is one such save area for each screen context
92allocated by \fBnewterm\fP.
93.SS "reset_prog_mode, reset_shell_mode"
94The \fBreset_prog_mode\fP and \fBreset_shell_mode\fP routines restore
95the terminal to \*(``program\*('' (in \fBcurses\fP) or \*(``shell\*('' (out of
96\fBcurses\fP) state.
97These are done automatically by \fBendwin\fP(3X) and,
98after an \fBendwin\fP, by \fBdoupdate\fP,
99so they normally are not called.
100.SS "resetty, savetty"
101The \fBresetty\fP and \fBsavetty\fP routines save and restore the
102state of the terminal modes.
103\fBsavetty\fP saves the current state in
104a buffer and \fBresetty\fP restores the state to what it was at the
105last call to \fBsavetty\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +0100106.SS getsyx
micky3879b9f5e72025-07-08 18:04:53 -0400107The \fBgetsyx\fP routine returns the current coordinates
108of the \fIvirtual screen\fP cursor in \fIy\fP and \fIx\fP.
109If \fBleaveok\fP is currently \fBTRUE\fP, then
110\fB\-1\fP,\fB\-1\fP is returned.
111If lines have been removed from the top of the
112screen, using \fBripoffline\fP, \fIy\fP and \fIx\fP include these lines;
113therefore, \fIy\fP and \fIx\fP should be used only as arguments for
114\fBsetsyx\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530115.PP
micky3879b9f5e72025-07-08 18:04:53 -0400116Few applications will use this feature,
117most use \fBgetyx\fP instead.
Steve Kondikae271bc2015-11-15 02:50:53 +0100118.SS setsyx
micky3879b9f5e72025-07-08 18:04:53 -0400119The \fBsetsyx\fP routine sets
120the \fIvirtual screen\fP cursor to \fIy\fP, \fIx\fP.
121If \fIy\fP and \fIx\fP are both \fB\-1\fP, then
122\fBleaveok\fP is set.
123The two routines \fBgetsyx\fP and \fBsetsyx\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124are designed to be used by a library routine, which manipulates
micky3879b9f5e72025-07-08 18:04:53 -0400125\fBcurses\fP windows but does not want to change the current position
126of the program's cursor.
127The library routine would call \fBgetsyx\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530128at the beginning, do its manipulation of its own windows, do a
micky3879b9f5e72025-07-08 18:04:53 -0400129\fBwnoutrefresh\fP on its windows, call \fBsetsyx\fP, and then call
130\fBdoupdate\fP.
131.PP
132Few applications will use this feature,
133most use \fBwmove\fP instead.
Steve Kondikae271bc2015-11-15 02:50:53 +0100134.SS ripoffline
micky3879b9f5e72025-07-08 18:04:53 -0400135.B \%ripoffline
136provides access to the same facility that \fB\%slk_init\fP(3X) uses to
137reduce the size of the screen.
138\fB\%ripoffline\fP must be called before \fBinitscr\fP or
139\fBnewterm\fP is called, to prepare these initial actions:
Steve Kondikae271bc2015-11-15 02:50:53 +0100140.bP
micky3879b9f5e72025-07-08 18:04:53 -0400141If \fIline\fP is positive, a line is removed from the top of \fBstdscr\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +0100142.bP
micky3879b9f5e72025-07-08 18:04:53 -0400143if \fIline\fP is negative, a line is removed from the bottom.
Steve Kondikae271bc2015-11-15 02:50:53 +0100144.PP
micky3879b9f5e72025-07-08 18:04:53 -0400145When the resulting initialization is done inside \fBinitscr\fP, the
146routine \fBinit\fP (supplied by the user) is called with two
Steve Kondikae271bc2015-11-15 02:50:53 +0100147arguments:
148.bP
149a window pointer to the one-line window that has been
150allocated and
151.bP
152an integer with the number of columns in the window.
153.PP
micky3879b9f5e72025-07-08 18:04:53 -0400154Inside this initialization routine, the integer variables \fBLINES\fP
155and \fBCOLS\fP (defined in \fB<curses.h>\fP) are not guaranteed to be
156accurate and \fBwrefresh\fP or \fBdoupdate\fP must not be called.
157It is allowable to call \fBwnoutrefresh\fP during the initialization routine.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530158.PP
micky3879b9f5e72025-07-08 18:04:53 -0400159\fBripoffline\fP can be called up to five times before calling \fBinitscr\fP or
160\fBnewterm\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +0100161.SS curs_set
micky3879b9f5e72025-07-08 18:04:53 -0400162The \fBcurs_set\fP routine sets the cursor state to invisible,
163normal, or very visible for \fBvisibility\fP equal to \fB0\fP,
164\fB1\fP, or \fB2\fP respectively.
165If the terminal supports the \fIvisibility\fP requested,
166the previous \fIcursor\fP state is returned;
167otherwise, \fBERR\fP is returned.
Steve Kondikae271bc2015-11-15 02:50:53 +0100168.SS napms
micky3879b9f5e72025-07-08 18:04:53 -0400169.B \%napms
170sleeps for
171.I ms
172milliseconds.
173If
174.I ms
175exceeds 30,000
176(thirty seconds),
177it is capped at that value.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530178.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400179Except for \fBcurs_set\fP, these routines always return \fBOK\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530180.PP
micky3879b9f5e72025-07-08 18:04:53 -0400181\fBcurs_set\fP
182returns the previous cursor state, or \fBERR\fP if the
183requested \fIvisibility\fP is not supported.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530184.PP
185X/Open defines no error conditions.
186In this implementation
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530187.TP 5
micky3879b9f5e72025-07-08 18:04:53 -0400188\fBdef_prog_mode\fP, \fBdef_shell_mode\fP, \fBreset_prog_mode\fP, \fBreset_shell_mode\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530189return an error
190if the terminal was not initialized, or
191if the I/O call to obtain the terminal settings fails.
192.TP 5
193\fBripoffline\fP
194returns an error if the maximum number of ripped-off lines
micky3879b9f5e72025-07-08 18:04:53 -0400195exceeds the maximum (5).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530196.SH NOTES
micky3879b9f5e72025-07-08 18:04:53 -0400197Note that \fBgetsyx\fP is a macro, so \fB&\fP is not necessary before
198the variables \fIy\fP and \fIx\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530199.PP
micky3879b9f5e72025-07-08 18:04:53 -0400200Older SVr4 man pages warn that the return value
201of \fBcurs_set\fP \*(``is currently incorrect\*(''.
202This implementation gets it right, but it may be unwise to count
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530203on the correctness of the return value anywhere else.
204.PP
micky3879b9f5e72025-07-08 18:04:53 -0400205Both \fI\%ncurses\fP and SVr4 will call \fBcurs_set\fP in \fBendwin\fP
206if \fBcurs_set\fP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530207has been called to make the cursor other than normal, i.e., either
208invisible or very visible.
micky3879b9f5e72025-07-08 18:04:53 -0400209There is no way for \fI\%ncurses\fP to determine the initial cursor
210state to restore that.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530211.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400212The \fIvirtual screen\fP functions \fBsetsyx\fP and \fBgetsyx\fP
213are not described in X/Open Curses, Issue 4.
214All other functions are as described in X/Open Curses.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530215.PP
micky3879b9f5e72025-07-08 18:04:53 -0400216The SVr4 documentation describes \fBsetsyx\fP and \fBgetsyx\fP
217as having return type int.
218This is misleading, as they are macros with no documented semantics
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530219for the return value.
micky3879b9f5e72025-07-08 18:04:53 -0400220.PP
221If interrupted, \fI\%ncurses\fP restarts \fBnapms\fP.
222That, and the limitation to 30 seconds,
223are different from other implementations.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530224.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400225\fB\%curses\fP(3X),
226\fB\%curs_initscr\fP(3X),
227\fB\%curs_outopts\fP(3X),
228\fB\%curs_refresh\fP(3X),
229\fB\%curs_scr_dump\fP(3X),
230\fB\%curs_slk\fP(3X),
231\fB\%curs_variables\fP(3X)