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