]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_kernel.3x
ncurses 6.1 - patch 20180203
[ncurses.git] / man / curs_kernel.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2016,2017 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.23 2017/11/18 23:47:37 tom Exp $
30 .de bP
31 .ie n  .IP \(bu 4
32 .el    .IP \(bu 2
33 ..
34 .TH curs_kernel 3X ""
35 .na
36 .hy 0
37 .SH NAME
38 \fBdef_prog_mode\fR,
39 \fBdef_shell_mode\fR,
40 \fBreset_prog_mode\fR,
41 \fBreset_shell_mode\fR,
42 \fBresetty\fR,
43 \fBsavetty\fR,
44 \fBgetsyx\fR,
45 \fBsetsyx\fR,
46 \fBripoffline\fR,
47 \fBcurs_set\fR,
48 \fBnapms\fR \- low-level \fBcurses\fR routines
49 .ad
50 .hy
51 .SH SYNOPSIS
52 \fB#include <curses.h>\fR
53 .sp
54 \fBint def_prog_mode(void);\fR
55 .br
56 \fBint def_shell_mode(void);\fR
57 .br
58 \fBint reset_prog_mode(void);\fR
59 .br
60 \fBint reset_shell_mode(void);\fR
61 .br
62 \fBint resetty(void);\fR
63 .br
64 \fBint savetty(void);\fR
65 .br
66 \fBvoid getsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
67 .br
68 \fBvoid setsyx(int \fP\fIy\fP\fB, int \fP\fIx\fP\fB);\fR
69 .br
70 \fBint ripoffline(int \fP\fIline\fP\fB, int (*\fP\fIinit\fP\fB)(WINDOW *, int));\fR
71 .br
72 \fBint curs_set(int \fP\fIvisibility\fP\fB);\fR
73 .br
74 \fBint napms(int \fP\fIms\fP\fB);\fR
75 .br
76 .SH DESCRIPTION
77 The following routines give low-level access to various \fBcurses\fR
78 capabilities.  These routines typically are used inside library
79 routines.
80 .SS def_prog_mode, def_shell_mode
81 .PP
82 The \fBdef_prog_mode\fR and \fBdef_shell_mode\fR routines save the
83 current terminal modes as the "program" (in \fBcurses\fR) or "shell"
84 (not in \fBcurses\fR) state for use by the \fBreset_prog_mode\fR and
85 \fBreset_shell_mode\fR routines.  This is done automatically by
86 \fBinitscr\fR.  There is one such save area for each screen context
87 allocated by \fBnewterm\fR.
88 .SS reset_prog_mode, reset_shell_mode
89 .PP
90 The \fBreset_prog_mode\fR and \fBreset_shell_mode\fR routines restore
91 the terminal to "program" (in \fBcurses\fR) or "shell" (out of
92 \fBcurses\fR) state.  These are done automatically by \fBendwin\fR(3X)
93 and, after an \fBendwin\fR, by \fBdoupdate\fR, so they normally are
94 not called.
95 .SS resetty, savetty
96 .PP
97 The \fBresetty\fR and \fBsavetty\fR routines save and restore the
98 state of the terminal modes.  \fBsavetty\fR saves the current state in
99 a buffer and \fBresetty\fR restores the state to what it was at the
100 last call to \fBsavetty\fR.
101 .SS getsyx
102 .PP
103 The \fBgetsyx\fR routine returns the current coordinates of the virtual screen
104 cursor in \fIy\fR and \fIx\fR.  If \fBleaveok\fR is currently \fBTRUE\fR, then
105 \fB\-1\fR,\fB\-1\fR is returned.  If lines have been removed from the top of the
106 screen, using \fBripoffline\fR, \fIy\fR and \fIx\fR include these lines;
107 therefore, \fIy\fR and \fIx\fR should be used only as arguments for
108 \fBsetsyx\fR.
109 .SS setsyx
110 .PP
111 The \fBsetsyx\fR routine sets the virtual screen cursor to
112 \fIy\fR, \fIx\fR.  If \fIy\fR and \fIx\fR are both \fB\-1\fR, then
113 \fBleaveok\fR is set.  The two routines \fBgetsyx\fR and \fBsetsyx\fR
114 are designed to be used by a library routine, which manipulates
115 \fBcurses\fR windows but does not want to change the current position
116 of the program's cursor.  The library routine would call \fBgetsyx\fR
117 at the beginning, do its manipulation of its own windows, do a
118 \fBwnoutrefresh\fR on its windows, call \fBsetsyx\fR, and then call
119 \fBdoupdate\fR.
120 .SS ripoffline
121 .PP
122 The \fBripoffline\fR routine provides access to the same facility that
123 \fBslk_init\fR [see \fBcurs_slk\fR(3X)] uses to reduce the size of the
124 screen.  \fBripoffline\fR must be called before \fBinitscr\fR or
125 \fBnewterm\fR is called, to prepare these initial actions:
126 .bP
127 If \fIline\fR is positive, a line is removed from the top of \fBstdscr\fR.
128 .bP
129 if \fIline\fR is negative, a line is removed from the bottom.
130 .PP
131 When the resulting initialization is done inside \fBinitscr\fR, the
132 routine \fBinit\fR (supplied by the user) is called with two
133 arguments:
134 .bP
135 a window pointer to the one-line window that has been
136 allocated and
137 .bP
138 an integer with the number of columns in the window.
139 .PP
140 Inside this initialization routine, the integer variables \fBLINES\fR
141 and \fBCOLS\fR (defined in \fB<curses.h>\fR) are not guaranteed to be
142 accurate and \fBwrefresh\fR or \fBdoupdate\fR must not be called.  It
143 is allowable to call \fBwnoutrefresh\fR during the initialization
144 routine.
145 .PP
146 \fBripoffline\fR can be called up to five times before calling \fBinitscr\fR or
147 \fBnewterm\fR.
148 .SS curs_set
149 .PP
150 The \fBcurs_set\fR routine sets the cursor state to invisible,
151 normal, or very visible for \fBvisibility\fR equal to \fB0\fR,
152 \fB1\fR, or \fB2\fR respectively.  If the terminal supports the
153 \fIvisibility\fR requested, the previous \fIcursor\fR state is
154 returned; otherwise, \fBERR\fR is returned.
155 .SS napms
156 .PP
157 The \fBnapms\fR routine is used to sleep for \fIms\fR milliseconds.
158 .SH RETURN VALUE
159 Except for \fBcurs_set\fR, these routines always return \fBOK\fR.
160 .PP
161 \fBcurs_set\fR
162 returns the previous cursor state, or \fBERR\fR if the
163 requested \fIvisibility\fR is not supported.
164 .PP
165 X/Open defines no error conditions.
166 In this implementation
167 .TP 5
168 .na
169 .hy 0
170 \fBdef_prog_mode\fR, \fBdef_shell_mode\fR, \fBreset_prog_mode\fR, \fBreset_shell_mode\fR
171 .hy
172 .ad
173 return an error
174 if the terminal was not initialized, or
175 if the I/O call to obtain the terminal settings fails.
176 .TP 5
177 \fBripoffline\fP
178 returns an error if the maximum number of ripped-off lines
179 exceeds the maximum (NRIPS = 5).
180 .SH NOTES
181 Note that \fBgetsyx\fR is a macro, so \fB&\fR is not necessary before
182 the variables \fIy\fR and \fIx\fR.
183 .PP
184 Older SVr4 man pages warn that the return value of \fBcurs_set\fR "is currently
185 incorrect".  This implementation gets it right, but it may be unwise to count
186 on the correctness of the return value anywhere else.
187 .PP
188 Both ncurses and SVr4 will call \fBcurs_set\fR in \fBendwin\fR
189 if \fBcurs_set\fR
190 has been called to make the cursor other than normal, i.e., either
191 invisible or very visible.
192 There is no way for ncurses to determine the initial cursor state to
193 restore that.
194 .SH PORTABILITY
195 The functions \fBsetsyx\fR and \fBgetsyx\fR are not described in the XSI
196 Curses standard, Issue 4.  All other functions are as described in XSI Curses.
197 .PP
198 The SVr4 documentation describes \fBsetsyx\fR and \fBgetsyx\fR as having return
199 type int. This is misleading, as they are macros with no documented semantics
200 for the return value.
201 .SH SEE ALSO
202 \fBcurses\fR(3X),
203 \fBcurs_initscr\fR(3X),
204 \fBcurs_outopts\fR(3X),
205 \fBcurs_refresh\fR(3X),
206 \fBcurs_scr_dump\fR(3X),
207 \fBcurs_slk\fR(3X),
208 \fBcurs_variables\fR(3X).