]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_kernel.3x
ncurses 6.4 - patch 20230819
[ncurses.git] / man / curs_kernel.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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.37 2023/08/19 19:47:16 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 2023-08-19 "ncurses 6.4" "Library calls"
40 .na
41 .hy 0
42 .SH NAME
43 \fBdef_prog_mode\fP,
44 \fBdef_shell_mode\fP,
45 \fBreset_prog_mode\fP,
46 \fBreset_shell_mode\fP,
47 \fBresetty\fP,
48 \fBsavetty\fP,
49 \fBgetsyx\fP,
50 \fBsetsyx\fP,
51 \fBripoffline\fP,
52 \fBcurs_set\fP,
53 \fBnapms\fP \- low-level \fBcurses\fP routines
54 .ad
55 .hy
56 .SH SYNOPSIS
57 \fB#include <curses.h>\fP
58 .sp
59 \fBint def_prog_mode(void);\fP
60 .br
61 \fBint def_shell_mode(void);\fP
62 .sp
63 \fBint reset_prog_mode(void);\fP
64 .br
65 \fBint reset_shell_mode(void);\fP
66 .sp
67 \fBint resetty(void);\fP
68 .br
69 \fBint savetty(void);\fP
70 .sp
71 \fBvoid getsyx(int \fIy\fB, int \fIx\fB);\fR
72 .br
73 \fBvoid setsyx(int \fIy\fB, int \fIx\fB);\fR
74 .sp
75 \fBint ripoffline(int \fIline\fB, int (*\fIinit\fB)(WINDOW *, int));\fR
76 .br
77 \fBint curs_set(int \fIvisibility\fB);\fR
78 .br
79 \fBint napms(int \fIms\fB);\fR
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 The \fBripoffline\fP routine provides access to the same facility that
136 \fBslk_init\fP [see \fBcurs_slk\fP(3X)] uses to reduce the size of the
137 screen.
138 \fBripoffline\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 The \fBnapms\fP routine is used to sleep for \fIms\fP milliseconds.
170 .SH RETURN VALUE
171 Except for \fBcurs_set\fP, these routines always return \fBOK\fP.
172 .PP
173 \fBcurs_set\fP
174 returns the previous cursor state, or \fBERR\fP if the
175 requested \fIvisibility\fP is not supported.
176 .PP
177 X/Open defines no error conditions.
178 In this implementation
179 .TP 5
180 .na
181 .hy 0
182 \fBdef_prog_mode\fP, \fBdef_shell_mode\fP, \fBreset_prog_mode\fP, \fBreset_shell_mode\fP
183 .hy
184 .ad
185 return an error
186 if the terminal was not initialized, or
187 if the I/O call to obtain the terminal settings fails.
188 .TP 5
189 \fBripoffline\fP
190 returns an error if the maximum number of ripped-off lines
191 exceeds the maximum (NRIPS = 5).
192 .SH NOTES
193 Note that \fBgetsyx\fP is a macro, so \fB&\fP is not necessary before
194 the variables \fIy\fP and \fIx\fP.
195 .PP
196 Older SVr4 man pages warn that the return value
197 of \fBcurs_set\fP \*(``is currently incorrect\*(''.
198 This implementation gets it right, but it may be unwise to count
199 on the correctness of the return value anywhere else.
200 .PP
201 Both ncurses and SVr4 will call \fBcurs_set\fP in \fBendwin\fP
202 if \fBcurs_set\fP
203 has been called to make the cursor other than normal, i.e., either
204 invisible or very visible.
205 There is no way for ncurses to determine the initial cursor state to
206 restore that.
207 .SH PORTABILITY
208 The \fIvirtual screen\fP functions \fBsetsyx\fP and \fBgetsyx\fP
209 are not described in the XSI Curses standard, Issue 4.
210 All other functions are as described in XSI Curses.
211 .PP
212 The SVr4 documentation describes \fBsetsyx\fP and \fBgetsyx\fP
213 as having return type int.
214 This is misleading, as they are macros with no documented semantics
215 for the return value.
216 .SH SEE ALSO
217 \fBcurses\fP(3X),
218 \fBcurs_initscr\fP(3X),
219 \fBcurs_outopts\fP(3X),
220 \fBcurs_refresh\fP(3X),
221 \fBcurs_scr_dump\fP(3X),
222 \fBcurs_slk\fP(3X),
223 \fBcurs_variables\fP(3X).