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