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