blob: 664d15d2505eb92bb20a7bd600353feffb82f2c5 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002.\" Copyright (c) 1998-2010,2015 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303.\" *
4.\" Permission is hereby granted, free of charge, to any person obtaining a *
5.\" copy of this software and associated documentation files (the *
6.\" "Software"), to deal in the Software without restriction, including *
7.\" without limitation the rights to use, copy, modify, merge, publish, *
8.\" distribute, distribute with modifications, sublicense, and/or sell *
9.\" copies of the Software, and to permit persons to whom the Software is *
10.\" furnished to do so, subject to the following conditions: *
11.\" *
12.\" The above copyright notice and this permission notice shall be included *
13.\" in all copies or substantial portions of the Software. *
14.\" *
15.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22.\" *
23.\" Except as contained in this notice, the name(s) of the above copyright *
24.\" holders shall not be used in advertising or otherwise to promote the *
25.\" sale, use or other dealings in this Software without prior written *
26.\" authorization. *
27.\"***************************************************************************
28.\"
Steve Kondikae271bc2015-11-15 02:50:53 +010029.\" $Id: curs_kernel.3x,v 1.20 2015/07/21 01:10:11 tom Exp $
30.de bP
31.IP \(bu 4
32..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053033.TH curs_kernel 3X ""
34.na
35.hy 0
36.SH NAME
37\fBdef_prog_mode\fR,
38\fBdef_shell_mode\fR,
39\fBreset_prog_mode\fR,
40\fBreset_shell_mode\fR,
41\fBresetty\fR,
42\fBsavetty\fR,
43\fBgetsyx\fR,
44\fBsetsyx\fR,
45\fBripoffline\fR,
46\fBcurs_set\fR,
Steve Kondikae271bc2015-11-15 02:50:53 +010047\fBnapms\fR \- low-level \fBcurses\fR routines
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053048.ad
49.hy
50.SH SYNOPSIS
51\fB#include <curses.h>\fR
52.sp
53\fBint def_prog_mode(void);\fR
54.br
55\fBint def_shell_mode(void);\fR
56.br
57\fBint reset_prog_mode(void);\fR
58.br
59\fBint reset_shell_mode(void);\fR
60.br
61\fBint resetty(void);\fR
62.br
63\fBint savetty(void);\fR
64.br
Steve Kondikae271bc2015-11-15 02:50:53 +010065\fBvoid getsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053066.br
Steve Kondikae271bc2015-11-15 02:50:53 +010067\fBvoid setsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053068.br
Steve Kondikae271bc2015-11-15 02:50:53 +010069\fBint ripoffline(int \fP\fIline\fP\fB, int (*\fP\fIinit\fP\fB)(WINDOW *, int));\fR
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053070.br
Steve Kondikae271bc2015-11-15 02:50:53 +010071\fBint curs_set(int \fP\fIvisibility\fP\fB);\fR
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053072.br
Steve Kondikae271bc2015-11-15 02:50:53 +010073\fBint napms(int \fP\fIms\fP\fB);\fR
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053074.br
75.SH DESCRIPTION
76The following routines give low-level access to various \fBcurses\fR
Steve Kondikae271bc2015-11-15 02:50:53 +010077capabilities. These routines typically are used inside library
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053078routines.
Steve Kondikae271bc2015-11-15 02:50:53 +010079.SS def_prog_mode, def_shell_mode
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053080.PP
81The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
82current terminal modes as the "program" (in \fBcurses\fR) or "shell"
83(not in \fBcurses\fR) state for use by the \fBreset_prog_mode\fR and
84\fBreset_shell_mode\fR routines. This is done automatically by
85\fBinitscr\fR. There is one such save area for each screen context
86allocated by \fBnewterm()\fR.
Steve Kondikae271bc2015-11-15 02:50:53 +010087.SS reset_prog_mode, reset_shell_mode
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053088.PP
89The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
90the terminal to "program" (in \fBcurses\fR) or "shell" (out of
91\fBcurses\fR) state. These are done automatically by \fBendwin\fR
92and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
93not called.
Steve Kondikae271bc2015-11-15 02:50:53 +010094.SS resetty, savetty
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053095.PP
96The \fBresetty\fR and \fBsavetty\fR routines save and restore the
97state of the terminal modes. \fBsavetty\fR saves the current state in
98a buffer and \fBresetty\fR restores the state to what it was at the
99last call to \fBsavetty\fR.
Steve Kondikae271bc2015-11-15 02:50:53 +0100100.SS getsyx
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530101.PP
102The \fBgetsyx\fR routine returns the current coordinates of the virtual screen
103cursor in \fIy\fR and \fIx\fR. If \fBleaveok\fR is currently \fBTRUE\fR, then
Steve Kondikae271bc2015-11-15 02:50:53 +0100104\fB\-1\fR,\fB\-1\fR is returned. If lines have been removed from the top of the
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530105screen, using \fBripoffline\fR, \fIy\fR and \fIx\fR include these lines;
106therefore, \fIy\fR and \fIx\fR should be used only as arguments for
107\fBsetsyx\fR.
Steve Kondikae271bc2015-11-15 02:50:53 +0100108.SS setsyx
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530109.PP
110The \fBsetsyx\fR routine sets the virtual screen cursor to
Steve Kondikae271bc2015-11-15 02:50:53 +0100111\fIy\fR, \fIx\fR. If \fIy\fR and \fIx\fR are both \fB\-1\fR, then
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530112\fBleaveok\fR is set. The two routines \fBgetsyx\fR and \fBsetsyx\fR
113are designed to be used by a library routine, which manipulates
114\fBcurses\fR windows but does not want to change the current position
115of the program's cursor. The library routine would call \fBgetsyx\fR
116at the beginning, do its manipulation of its own windows, do a
117\fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
118\fBdoupdate\fR.
Steve Kondikae271bc2015-11-15 02:50:53 +0100119.SS ripoffline
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530120.PP
121The \fBripoffline\fR routine provides access to the same facility that
122\fBslk_init\fR [see \fBcurs_slk\fR(3X)] uses to reduce the size of the
123screen. \fBripoffline\fR must be called before \fBinitscr\fR or
Steve Kondikae271bc2015-11-15 02:50:53 +0100124\fBnewterm\fR is called, to prepare these initial actions:
125.bP
126If \fIline\fR is positive, a line is removed from the top of \fBstdscr\fR.
127.bP
128if \fIline\fR is negative, a line is removed from the bottom.
129.PP
130When the resulting initialization is done inside \fBinitscr\fR, the
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131routine \fBinit\fR (supplied by the user) is called with two
Steve Kondikae271bc2015-11-15 02:50:53 +0100132arguments:
133.bP
134a window pointer to the one-line window that has been
135allocated and
136.bP
137an integer with the number of columns in the window.
138.PP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530139Inside this initialization routine, the integer variables \fBLINES\fR
140and \fBCOLS\fR (defined in \fB<curses.h>\fR) are not guaranteed to be
141accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called. It
142is allowable to call \fBwnoutrefresh\fR during the initialization
143routine.
144.PP
145\fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
146\fBnewterm\fR.
Steve Kondikae271bc2015-11-15 02:50:53 +0100147.SS curs_set
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530148.PP
Steve Kondikae271bc2015-11-15 02:50:53 +0100149The \fBcurs_set\fR routine sets the cursor state to invisible,
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530150normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
151\fB1\fR, or \fB2\fR respectively. If the terminal supports the
152\fIvisibility\fR requested, the previous \fIcursor\fR state is
153returned; otherwise, \fBERR\fR is returned.
Steve Kondikae271bc2015-11-15 02:50:53 +0100154.SS napms
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155.PP
156The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
157.SH RETURN VALUE
158Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
159.PP
160\fBcurs_set\fR
161returns the previous cursor state, or \fBERR\fR if the
162requested \fIvisibility\fR is not supported.
163.PP
164X/Open defines no error conditions.
165In this implementation
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530166.TP 5
Steve Kondikae271bc2015-11-15 02:50:53 +0100167.na
168.hy 0
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530169\fBdef_prog_mode\fR, \fBdef_shell_mode\fR, \fBreset_prog_mode\fR, \fBreset_shell_mode\fR
Steve Kondikae271bc2015-11-15 02:50:53 +0100170.hy
171.ad
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530172return an error
173if the terminal was not initialized, or
174if the I/O call to obtain the terminal settings fails.
175.TP 5
176\fBripoffline\fP
177returns an error if the maximum number of ripped-off lines
178exceeds the maximum (NRIPS = 5).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530179.SH NOTES
180Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
181the variables \fIy\fR and \fIx\fR.
182.PP
183Older SVr4 man pages warn that the return value of \fBcurs_set\fR "is currently
184incorrect". This implementation gets it right, but it may be unwise to count
185on the correctness of the return value anywhere else.
186.PP
187Both ncurses and SVr4 will call \fBcurs_set\fR in \fBendwin\fR
188if \fBcurs_set\fR
189has been called to make the cursor other than normal, i.e., either
190invisible or very visible.
191There is no way for ncurses to determine the initial cursor state to
192restore that.
193.SH PORTABILITY
194The functions \fBsetsyx\fR and \fBgetsyx\fR are not described in the XSI
195Curses standard, Issue 4. All other functions are as described in XSI Curses.
196.PP
197The SVr4 documentation describes \fBsetsyx\fR and \fBgetsyx\fR as having return
198type int. This is misleading, as they are macros with no documented semantics
199for the return value.
200.SH SEE ALSO
Steve Kondikae271bc2015-11-15 02:50:53 +0100201\fBcurses\fR(3X),
202\fBcurs_initscr\fR(3X),
203\fBcurs_outopts\fR(3X),
204\fBcurs_refresh\fR(3X),
205\fBcurs_scr_dump\fR(3X),
206\fBcurs_slk\fR(3X),
207\fBcurs_variables\fR(3X).