summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-tumbleweed/man3/kernel.3ncurses
blob: 9b31a869be225eaf08c59ece3ff064c29d96f5fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
.\"***************************************************************************
.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
.\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
.\"                                                                          *
.\" Permission is hereby granted, free of charge, to any person obtaining a  *
.\" copy of this software and associated documentation files (the            *
.\" "Software"), to deal in the Software without restriction, including      *
.\" without limitation the rights to use, copy, modify, merge, publish,      *
.\" distribute, distribute with modifications, sublicense, and/or sell       *
.\" copies of the Software, and to permit persons to whom the Software is    *
.\" furnished to do so, subject to the following conditions:                 *
.\"                                                                          *
.\" The above copyright notice and this permission notice shall be included  *
.\" in all copies or substantial portions of the Software.                   *
.\"                                                                          *
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
.\"                                                                          *
.\" Except as contained in this notice, the name(s) of the above copyright   *
.\" holders shall not be used in advertising or otherwise to promote the     *
.\" sale, use or other dealings in this Software without prior written       *
.\" authorization.                                                           *
.\"***************************************************************************
.\"
.\" $Id: curs_kernel.3x,v 1.61 2024/04/20 21:24:19 tom Exp $
.TH kernel 3NCURSES 2024-04-20 "ncurses 6.5" "Library calls"
.ie \n(.g \{\
.ds `` \(lq
.ds '' \(rq
.\}
.el \{\
.ie t .ds `` ``
.el   .ds `` ""
.ie t .ds '' ''
.el   .ds '' ""
.\}
.
.de bP
.ie n  .IP \(bu 4
.el    .IP \(bu 2
..
.SH NAME
\fB\%def_prog_mode\fP,
\fB\%def_shell_mode\fP,
\fB\%reset_prog_mode\fP,
\fB\%reset_shell_mode\fP,
\fB\%resetty\fP,
\fB\%savetty\fP,
\fB\%getsyx\fP,
\fB\%setsyx\fP,
\fB\%ripoffline\fP,
\fB\%curs_set\fP,
\fB\%napms\fP \-
low-level \fIcurses\fR routines
.SH SYNOPSIS
.nf
\fB#include <ncursesw/curses.h>
.PP
\fBint def_prog_mode(void);
\fBint def_shell_mode(void);
.PP
\fBint reset_prog_mode(void);
\fBint reset_shell_mode(void);
.PP
\fBint resetty(void);
\fBint savetty(void);
.PP
\fBvoid getsyx(int \fIy\fP, int \fIx\fP);
\fBvoid setsyx(int \fIy\fP, int \fIx\fP);
.PP
\fBint ripoffline(int \fIline\fP, int (*\fIinit\fP)(WINDOW *, int));
\fBint curs_set(int \fIvisibility\fP);
\fBint napms(int \fIms\fP);
.fi
.SH DESCRIPTION
The following routines give low-level access
to various \fBcurses\fP capabilities.
These routines typically are used inside library routines.
.SS "def_prog_mode, def_shell_mode"
The \fBdef_prog_mode\fP and \fBdef_shell_mode\fP routines save the
current terminal modes as the \*(``program\*(''
(in \fBcurses\fP) or \*(``shell\*(''
(not in \fBcurses\fP) state for use by the \fBreset_prog_mode\fP and
\fBreset_shell_mode\fP routines.
This is done automatically by \fBinitscr\fP.
There is one such save area for each screen context
allocated by \fBnewterm\fP.
.SS "reset_prog_mode, reset_shell_mode"
The \fBreset_prog_mode\fP and \fBreset_shell_mode\fP routines restore
the terminal to \*(``program\*('' (in \fBcurses\fP) or \*(``shell\*('' (out of
\fBcurses\fP) state.
These are done automatically by \fB\%endwin\fP(3NCURSES) and,
after an \fBendwin\fP, by \fBdoupdate\fP,
so they normally are not called.
.SS "resetty, savetty"
The \fBresetty\fP and \fBsavetty\fP routines save and restore the
state of the terminal modes.
\fBsavetty\fP saves the current state in
a buffer and \fBresetty\fP restores the state to what it was at the
last call to \fBsavetty\fP.
.SS getsyx
The \fBgetsyx\fP routine returns the current coordinates
of the \fIvirtual screen\fP cursor in \fIy\fP and \fIx\fP.
If \fBleaveok\fP is currently \fBTRUE\fP, then
\fB\-1\fP,\fB\-1\fP is returned.
If lines have been removed from the top of the
screen, using \fBripoffline\fP, \fIy\fP and \fIx\fP include these lines;
therefore, \fIy\fP and \fIx\fP should be used only as arguments for
\fBsetsyx\fP.
.PP
Few applications will use this feature,
most use \fBgetyx\fP instead.
.SS setsyx
The \fBsetsyx\fP routine sets
the \fIvirtual screen\fP cursor to \fIy\fP, \fIx\fP.
If \fIy\fP and \fIx\fP are both \fB\-1\fP, then
\fBleaveok\fP is set.
The two routines \fBgetsyx\fP and \fBsetsyx\fP
are designed to be used by a library routine, which manipulates
\fBcurses\fP windows but does not want to change the current position
of the program's cursor.
The library routine would call \fBgetsyx\fP
at the beginning, do its manipulation of its own windows, do a
\fBwnoutrefresh\fP on its windows, call \fBsetsyx\fP, and then call
\fBdoupdate\fP.
.PP
Few applications will use this feature,
most use \fBwmove\fP instead.
.SS ripoffline
.B \%ripoffline
provides access to the same facility that \fB\%slk_init\fP(3NCURSES) uses to
reduce the size of the screen.
\fB\%ripoffline\fP must be called before \fBinitscr\fP or
\fBnewterm\fP is called, to prepare these initial actions:
.bP
If \fIline\fP is positive, a line is removed from the top of \fBstdscr\fP.
.bP
if \fIline\fP is negative, a line is removed from the bottom.
.PP
When the resulting initialization is done inside \fBinitscr\fP, the
routine \fBinit\fP (supplied by the user) is called with two
arguments:
.bP
a window pointer to the one-line window that has been
allocated and
.bP
an integer with the number of columns in the window.
.PP
Inside this initialization routine, the integer variables \fBLINES\fP
and \fBCOLS\fP (defined in \fB<curses.h>\fP) are not guaranteed to be
accurate and \fBwrefresh\fP or \fBdoupdate\fP must not be called.
It is allowable to call \fBwnoutrefresh\fP during the initialization routine.
.PP
\fBripoffline\fP can be called up to five times before calling \fBinitscr\fP or
\fBnewterm\fP.
.SS curs_set
The \fBcurs_set\fP routine sets the cursor state to invisible,
normal, or very visible for \fBvisibility\fP equal to \fB0\fP,
\fB1\fP, or \fB2\fP respectively.
If the terminal supports the \fIvisibility\fP requested,
the previous \fIcursor\fP state is returned;
otherwise, \fBERR\fP is returned.
.SS napms
.B \%napms
sleeps for
.I ms
milliseconds.
If
.I ms
exceeds 30,000
(thirty seconds),
it is capped at that value.
.SH RETURN VALUE
Except for \fBcurs_set\fP, these routines always return \fBOK\fP.
.PP
\fBcurs_set\fP
returns the previous cursor state, or \fBERR\fP if the
requested \fIvisibility\fP is not supported.
.PP
X/Open defines no error conditions.
In this implementation
.TP 5
\fBdef_prog_mode\fP, \fBdef_shell_mode\fP, \fBreset_prog_mode\fP, \fBreset_shell_mode\fP
return an error
if the terminal was not initialized, or
if the I/O call to obtain the terminal settings fails.
.TP 5
\fBripoffline\fP
returns an error if the maximum number of ripped-off lines
exceeds the maximum (5).
.SH NOTES
Note that \fBgetsyx\fP is a macro, so \fB&\fP is not necessary before
the variables \fIy\fP and \fIx\fP.
.PP
Older SVr4 man pages warn that the return value
of \fBcurs_set\fP \*(``is currently incorrect\*(''.
This implementation gets it right, but it may be unwise to count
on the correctness of the return value anywhere else.
.PP
Both \fI\%ncurses\fP and SVr4 will call \fBcurs_set\fP in \fBendwin\fP
if \fBcurs_set\fP
has been called to make the cursor other than normal, i.e., either
invisible or very visible.
There is no way for \fI\%ncurses\fP to determine the initial cursor
state to restore that.
.SH PORTABILITY
The \fIvirtual screen\fP functions \fBsetsyx\fP and \fBgetsyx\fP
are not described in X/Open Curses, Issue 4.
All other functions are as described in X/Open Curses.
.PP
The SVr4 documentation describes \fBsetsyx\fP and \fBgetsyx\fP
as having return type int.
This is misleading, as they are macros with no documented semantics
for the return value.
.PP
If interrupted, \fI\%ncurses\fP restarts \fBnapms\fP.
That, and the limitation to 30 seconds,
are different from other implementations.
.SH SEE ALSO
\fB\%ncurses\fP(3NCURSES),
\fB\%initscr\fP(3NCURSES),
\fB\%outopts\fP(3NCURSES),
\fB\%refresh\fP(3NCURSES),
\fB\%scr_dump\fP(3NCURSES),
\fB\%slk\fP(3NCURSES),
\fB\%curses_variables\fP(3NCURSES)