summaryrefslogtreecommitdiff
path: root/man/curs_outopts.3x
blob: cdf814ef9422417bb51479171c3e2c8597943249 (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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
.\"***************************************************************************
.\" Copyright 2018-2024,2025 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_outopts.3x,v 1.106 2025/11/12 00:52:57 tom Exp $
.TH curs_outopts 3X 2025-11-11 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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\%clearok\fP,
\fB\%idcok\fP,
\fB\%idlok\fP,
\fB\%immedok\fP,
\fB\%leaveok\fP,
\fB\%scrollok\fP,
\fB\%setscrreg\fP,
\fB\%wsetscrreg\fP \-
set \fIcurses\fR output options
.SH SYNOPSIS
.nf
\fB#include <curses.h>
.PP
\fBint clearok(WINDOW * \fIwin\fP, bool \fIbf\fP);
\fBvoid idcok(WINDOW * \fIwin\fP, bool \fIbf\fP);
\fBint idlok(WINDOW * \fIwin\fP, bool \fIbf\fP);
\fBvoid immedok(WINDOW * \fIwin\fP, bool \fIbf\fP);
\fBint leaveok(WINDOW * \fIwin\fP, bool \fIbf\fP);
\fBint scrollok(WINDOW * \fIwin\fP, bool \fIbf\fP);
.PP
\fBint setscrreg(int \fItop\fP, int \fIbot\fP);
\fBint wsetscrreg(WINDOW * \fIwin\fP, int \fItop\fP, int \fIbot\fP);
.fi
.SH DESCRIPTION
These functions configure properties of
.I curses
windows that affect their manner of output.
Boolean-valued properties are initially
.B FALSE
except where noted.
\fBendwin\fP(3X) resets any terminal modes corresponding to these
properties;
an application need not restore their initial values.
.SS clearok
Setting
.IR win 's
.B \%clearok
property to
.B TRUE
causes the next
.B \%wrefresh
call on it to clear the terminal screen and redraw it entirely.
This property is useful to restore the contents of the screen
(perhaps because another process has written to the terminal),
or in some cases to achieve a more pleasing visual effect.
If
.I \%win
is
.B \%curscr
(see \fBcurs_variables\fP(3X)),
the next
.B \%wrefresh
call on
.I any
window causes the terminal screen to clear and redraw as above.
.B \%wrefresh
resets this property to
.BR FALSE "."
.SS idcok
(This property defaults
.BR TRUE ".)"
Setting
.IR win 's
.B \%idcok
property to
.B FALSE
prevents
.I curses
from using the insert/delete character capabilities of terminal types
possessing them according to the
.I \%term\%info
database.
.SS idlok
Setting
.IR win 's
.B \%idlok
property to
.B TRUE
causes
.I curses
to consider
using the insert/delete line capabilities of terminal types
possessing them according to the
.I \%term\%info
database.
Enable this option
if the application explicitly requires these operations,
as a full-screen text editor might;
otherwise the results may be visually annoying to the user.
.\" TODO: Substantiate that claim.
.SS immedok
If
.B \%immedok
is called with
.B TRUE
as second argument,
changes to the window image,
such as those caused by
.BR \%waddch ","
.BR \%wclrtobot ","
or
.BR \%wscrl ","
automatically cause a call to
.BR wrefresh "."
Setting a window's
.B \%immedok
property may degrade performance considerably
if writes are frequent.
Calling
.B \%immedok
with
.B FALSE
as second argument
restores the default behavior,
deferring screen updates until a refresh is needed
or explicitly directed by the application.
.SS leaveok
Normally,
.I curses
leaves the hardware cursor at the library's cursor location
of the window being refreshed.
The
.B \%leaveok
option allows the cursor to be left
wherever the update happens to leave it.
It is useful for applications that do not employ a visible cursor,
since it reduces the need for cursor motions.
.SS scrollok
The
.B \%scrollok
option controls what happens when a window's cursor
moves off the edge of the window or scrolling region,
as a result of either
(1) writing a newline anywhere on its bottom line,
or
(2) writing a character that advances the cursor to the last position
on its bottom line.
If disabled
.RI ( bf
is
.BR FALSE "),"
.I curses
leaves the cursor on the bottom line of the window.
If enabled
.RI ( bf
is
.BR TRUE "),"
.I curses
scrolls the window up one line.
(To get the physical scrolling effect on the terminal,
the application must also enable
.BR idlok ")."
.SS "setscrreg, wsetscrreg"
The
.B \%wsetscrreg
and
.B \%setscrreg
functions allow the application
to set a software scrolling region in the specified window or
.BR \%stdscr ","
respectively.
The
.I top
and
.I bot
parameters
are the line numbers of the top and bottom margin of the scrolling
region.
If this option and
.B scrollok
are enabled,
an attempt to move off the bottom margin line
causes all lines in the scrolling region
to scroll one line in the direction of the first line.
Only the text of the window is scrolled.
(This process has nothing to do
with the scrolling region capability of the terminal,
as found in the DEC VT100.)
If
.B \%idlok
is enabled and the terminal
has either a scrolling region or insert/delete line capability,
they will probably be used by the output routines.
.SH RETURN VALUE
The functions
.B \%setscrreg
and
.B \%wsetscrreg
return
.B OK
upon success
and
.B ERR
upon failure.
All other routines that return an integer always
return
.BR OK "."
.PP
In
.IR \%ncurses ","
these functions fail if
.bP
the
.I curses
screen has not been initialized,
.bP
(for functions taking a
.I \%WINDOW
pointer argument)
.I win
is a null pointer,
or
.bP
(for
.B \%setscrreg
and
.BR \%wsetscrreg ")"
the function is passed arguments describing a scrolling region
with limits that extend outside the window boundaries.
.SH NOTES
.BR \%clearok ","
.BR \%leaveok ","
.BR \%scrollok ","
.BR \%idcok ","
and
.B \%setscrreg
may be implemented as macros.
.PP
Unlike the other functions described by this page,
.B \%setscrreg
does not accept a
.RI pointer-to- WINDOW
parameter,
but operates on
.BR stdscr "."
Use
.B \%wsetscrreg
to configure the scrolling region of a selected window.
.PP
Historically,
applications used
.B \%idcok(FALSE)
to accommodate the \*(``magic cookie\*('' feature
of some terminal types;
see subsection \*(``Highlighting, Underlining, and Visible Bells\*(''
of \fB\%terminfo\fP(5).
When updating a line,
the presence of character cells with magic cookies in them
made the
.I curses
library's computations of characters to be rewritten inaccurate.
A better solution is to indicate the
.B \%magic_cookie_glitch
.RB ( xmc )
capability in the terminal's type description.
.PP
.B \%immedok
is useful for windows that are used as terminal emulators.
.SH PORTABILITY
X/Open Curses Issue\ 4 describes these functions.
It specifies no error conditions for them.
.PP
Some historic
.I curses
implementations,
as an undocumented feature,
did the equivalent of
.RB \*(`` \%clearok( .\|.\|. ", 1)" \*(''
when
.B \%touchwin(stdstr)
or
.B \%clear(stdstr)
were used.
This trick does not work with
.IR \%ncurses .
.PP
Early System\ V
.I curses
implementations specified that with
.I \%scrollok
enabled,
any window modification triggering a scroll
also forced a physical refresh.
X/Open Curses does not require this,
and
.I \%ncurses
avoids doing so to better optimize vertical motions upon a
.IR \%wrefresh "."
.PP
X/Open Curses does not mention that the cursor should be
made invisible as a side effect of
.IR \%leaveok "."
SVr4
.I curses
documentation notes this behavior,
but the code neglects to implement it.
Use \fB\%curs_set\fP(3X) to make the cursor invisible.
.SH HISTORY
4BSD (1980)
introduced
.IR \%clearok ","
.IR \%leaveok ","
and
.IR \%scrollok "."
.PP
SVr2 (1984)
supplied
.IR \%idlok ","
.IR \%setscrreg ","
and
.IR \%wsetscrreg "."
.PP
SVr3.1 (1987)
implemented
.I \%idcok
and
.IR \%immedok "."
.PP
.I \%ncurses
formerly treated
.I nl
and
.I nonl
as both input
.I and
output options,
but no longer;
see \fB\%curs_inopts\fP(3X).
.SH SEE ALSO
\fB\%curses\fP(3X),
\fB\%curs_addch\fP(3X),
\fB\%curs_clear\fP(3X),
\fB\%curs_initscr\fP(3X),
\fB\%curs_refresh\fP(3X),
\fB\%curs_scroll\fP(3X),
\fB\%curs_variables\fP(3X)