1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. *
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: *
12 .\" The above copyright notice and this permission notice shall be included *
13 .\" in all copies or substantial portions of the Software. *
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. *
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 *
27 .\"***************************************************************************
29 .\" $Id: curs_kernel.3x,v 1.22 2017/01/07 19:25:15 tom Exp $
39 \fBreset_prog_mode\fR,
40 \fBreset_shell_mode\fR,
47 \fBnapms\fR \- low-level \fBcurses\fR routines
51 \fB#include <curses.h>\fR
53 \fBint def_prog_mode(void);\fR
55 \fBint def_shell_mode(void);\fR
57 \fBint reset_prog_mode(void);\fR
59 \fBint reset_shell_mode(void);\fR
61 \fBint resetty(void);\fR
63 \fBint savetty(void);\fR
65 \fBvoid getsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
67 \fBvoid setsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
69 \fBint ripoffline(int \fP\fIline\fP\fB, int (*\fP\fIinit\fP\fB)(WINDOW *, int));\fR
71 \fBint curs_set(int \fP\fIvisibility\fP\fB);\fR
73 \fBint napms(int \fP\fIms\fP\fB);\fR
76 The following routines give low-level access to various \fBcurses\fR
77 capabilities. These routines typically are used inside library
79 .SS def_prog_mode, def_shell_mode
81 The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
82 current 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
86 allocated by \fBnewterm\fR.
87 .SS reset_prog_mode, reset_shell_mode
89 The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
90 the terminal to "program" (in \fBcurses\fR) or "shell" (out of
91 \fBcurses\fR) state. These are done automatically by \fBendwin\fR(3X)
92 and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
96 The \fBresetty\fR and \fBsavetty\fR routines save and restore the
97 state of the terminal modes. \fBsavetty\fR saves the current state in
98 a buffer and \fBresetty\fR restores the state to what it was at the
99 last call to \fBsavetty\fR.
102 The \fBgetsyx\fR routine returns the current coordinates of the virtual screen
103 cursor in \fIy\fR and \fIx\fR. If \fBleaveok\fR is currently \fBTRUE\fR, then
104 \fB\-1\fR,\fB\-1\fR is returned. If lines have been removed from the top of the
105 screen, using \fBripoffline\fR, \fIy\fR and \fIx\fR include these lines;
106 therefore, \fIy\fR and \fIx\fR should be used only as arguments for
110 The \fBsetsyx\fR routine sets the virtual screen cursor to
111 \fIy\fR, \fIx\fR. If \fIy\fR and \fIx\fR are both \fB\-1\fR, then
112 \fBleaveok\fR is set. The two routines \fBgetsyx\fR and \fBsetsyx\fR
113 are designed to be used by a library routine, which manipulates
114 \fBcurses\fR windows but does not want to change the current position
115 of the program's cursor. The library routine would call \fBgetsyx\fR
116 at the beginning, do its manipulation of its own windows, do a
117 \fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
121 The \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
123 screen. \fBripoffline\fR must be called before \fBinitscr\fR or
124 \fBnewterm\fR is called, to prepare these initial actions:
126 If \fIline\fR is positive, a line is removed from the top of \fBstdscr\fR.
128 if \fIline\fR is negative, a line is removed from the bottom.
130 When the resulting initialization is done inside \fBinitscr\fR, the
131 routine \fBinit\fR (supplied by the user) is called with two
134 a window pointer to the one-line window that has been
137 an integer with the number of columns in the window.
139 Inside this initialization routine, the integer variables \fBLINES\fR
140 and \fBCOLS\fR (defined in \fB<curses.h>\fR) are not guaranteed to be
141 accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called. It
142 is allowable to call \fBwnoutrefresh\fR during the initialization
145 \fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
149 The \fBcurs_set\fR routine sets the cursor state to invisible,
150 normal, 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
153 returned; otherwise, \fBERR\fR is returned.
156 The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
158 Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
161 returns the previous cursor state, or \fBERR\fR if the
162 requested \fIvisibility\fR is not supported.
164 X/Open defines no error conditions.
165 In this implementation
169 \fBdef_prog_mode\fR, \fBdef_shell_mode\fR, \fBreset_prog_mode\fR, \fBreset_shell_mode\fR
173 if the terminal was not initialized, or
174 if the I/O call to obtain the terminal settings fails.
177 returns an error if the maximum number of ripped-off lines
178 exceeds the maximum (NRIPS = 5).
180 Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
181 the variables \fIy\fR and \fIx\fR.
183 Older SVr4 man pages warn that the return value of \fBcurs_set\fR "is currently
184 incorrect". This implementation gets it right, but it may be unwise to count
185 on the correctness of the return value anywhere else.
187 Both ncurses and SVr4 will call \fBcurs_set\fR in \fBendwin\fR
189 has been called to make the cursor other than normal, i.e., either
190 invisible or very visible.
191 There is no way for ncurses to determine the initial cursor state to
194 The functions \fBsetsyx\fR and \fBgetsyx\fR are not described in the XSI
195 Curses standard, Issue 4. All other functions are as described in XSI Curses.
197 The SVr4 documentation describes \fBsetsyx\fR and \fBgetsyx\fR as having return
198 type int. This is misleading, as they are macros with no documented semantics
199 for the return value.
202 \fBcurs_initscr\fR(3X),
203 \fBcurs_outopts\fR(3X),
204 \fBcurs_refresh\fR(3X),
205 \fBcurs_scr_dump\fR(3X),
207 \fBcurs_variables\fR(3X).