]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_kernel.3x
727a2721cf71caee2d61219fb55b245fd638e8a5
[ncurses.git] / man / curs_kernel.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2015,2016 Free Software Foundation, Inc.                        *
3 .\"                                                                          *
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 .\"
29 .\" $Id: curs_kernel.3x,v 1.21 2016/10/15 16:42:55 tom Exp $
30 .de bP
31 .IP \(bu 4
32 ..
33 .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,
47 \fBnapms\fR \- low-level \fBcurses\fR routines
48 .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
65 \fBvoid getsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
66 .br
67 \fBvoid setsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
68 .br
69 \fBint ripoffline(int \fP\fIline\fP\fB, int (*\fP\fIinit\fP\fB)(WINDOW *, int));\fR
70 .br
71 \fBint curs_set(int \fP\fIvisibility\fP\fB);\fR
72 .br
73 \fBint napms(int \fP\fIms\fP\fB);\fR
74 .br
75 .SH DESCRIPTION
76 The following routines give low-level access to various \fBcurses\fR
77 capabilities.  These routines typically are used inside library
78 routines.
79 .SS def_prog_mode, def_shell_mode
80 .PP
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
88 .PP
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
92 and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
93 not called.
94 .SS resetty, savetty
95 .PP
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.
100 .SS getsyx
101 .PP
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
107 \fBsetsyx\fR.
108 .SS setsyx
109 .PP
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
118 \fBdoupdate\fR.
119 .SS ripoffline
120 .PP
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:
125 .bP
126 If \fIline\fR is positive, a line is removed from the top of \fBstdscr\fR.
127 .bP
128 if \fIline\fR is negative, a line is removed from the bottom.
129 .PP
130 When the resulting initialization is done inside \fBinitscr\fR, the
131 routine \fBinit\fR (supplied by the user) is called with two
132 arguments:
133 .bP
134 a window pointer to the one-line window that has been
135 allocated and
136 .bP
137 an integer with the number of columns in the window.
138 .PP
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
143 routine.
144 .PP
145 \fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
146 \fBnewterm\fR.
147 .SS curs_set
148 .PP
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.
154 .SS napms
155 .PP
156 The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
157 .SH RETURN VALUE
158 Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
159 .PP
160 \fBcurs_set\fR
161 returns the previous cursor state, or \fBERR\fR if the
162 requested \fIvisibility\fR is not supported.
163 .PP
164 X/Open defines no error conditions.
165 In this implementation
166 .TP 5
167 .na
168 .hy 0
169 \fBdef_prog_mode\fR, \fBdef_shell_mode\fR, \fBreset_prog_mode\fR, \fBreset_shell_mode\fR
170 .hy
171 .ad
172 return an error
173 if the terminal was not initialized, or
174 if the I/O call to obtain the terminal settings fails.
175 .TP 5
176 \fBripoffline\fP
177 returns an error if the maximum number of ripped-off lines
178 exceeds the maximum (NRIPS = 5).
179 .SH NOTES
180 Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
181 the variables \fIy\fR and \fIx\fR.
182 .PP
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.
186 .PP
187 Both ncurses and SVr4 will call \fBcurs_set\fR in \fBendwin\fR
188 if \fBcurs_set\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
192 restore that.
193 .SH PORTABILITY
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.
196 .PP
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.
200 .SH SEE ALSO
201 \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).