jcs's openbsd hax
openbsd
1.\" $OpenBSD: curs_refresh.3,v 1.8 2023/10/17 09:52:08 nicm Exp $
2.\"
3.\"***************************************************************************
4.\" Copyright 2018-2022,2023 Thomas E. Dickey *
5.\" Copyright 1998-2010,2016 Free Software Foundation, Inc. *
6.\" *
7.\" Permission is hereby granted, free of charge, to any person obtaining a *
8.\" copy of this software and associated documentation files (the *
9.\" "Software"), to deal in the Software without restriction, including *
10.\" without limitation the rights to use, copy, modify, merge, publish, *
11.\" distribute, distribute with modifications, sublicense, and/or sell *
12.\" copies of the Software, and to permit persons to whom the Software is *
13.\" furnished to do so, subject to the following conditions: *
14.\" *
15.\" The above copyright notice and this permission notice shall be included *
16.\" in all copies or substantial portions of the Software. *
17.\" *
18.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25.\" *
26.\" Except as contained in this notice, the name(s) of the above copyright *
27.\" holders shall not be used in advertising or otherwise to promote the *
28.\" sale, use or other dealings in this Software without prior written *
29.\" authorization. *
30.\"***************************************************************************
31.\"
32.\" $Id: curs_refresh.3,v 1.8 2023/10/17 09:52:08 nicm Exp $
33.TH curs_refresh 3 2023-08-19 "ncurses 6.4" "Library calls"
34.ie \n(.g .ds `` \(lq
35.el .ds `` ``
36.ie \n(.g .ds '' \(rq
37.el .ds '' ''
38.de bP
39.ie n .IP \(bu 4
40.el .IP \(bu 2
41..
42.na
43.hy 0
44.SH NAME
45\fBdoupdate\fP,
46\fBredrawwin\fP,
47\fBrefresh\fP,
48\fBwnoutrefresh\fP,
49\fBwredrawln\fP,
50\fBwrefresh\fP \- refresh \fBcurses\fP windows and lines
51.ad
52.hy
53.SH SYNOPSIS
54\fB#include <curses.h>\fP
55.sp
56\fBint refresh(void);\fP
57.br
58\fBint wrefresh(WINDOW *\fIwin\fB);\fR
59.br
60\fBint wnoutrefresh(WINDOW *\fIwin\fB);\fR
61.br
62\fBint doupdate(void);\fP
63.sp
64\fBint redrawwin(WINDOW *\fIwin\fB);\fR
65.br
66\fBint wredrawln(WINDOW *\fIwin\fB, int \fIbeg_line\fB, int \fInum_lines\fB);\fR
67.SH DESCRIPTION
68.SS refresh/wrefresh
69The \fBrefresh\fP and \fBwrefresh\fP routines (or \fBwnoutrefresh\fP and
70\fBdoupdate\fP) must be called to get actual output to the terminal,
71as other routines merely manipulate data structures.
72The routine \fBwrefresh\fP copies
73the named window to the \fIphysical screen\fP,
74taking into account what is already there to do optimizations.
75The \fBrefresh\fP routine is the
76same, using \fBstdscr\fP as the default window.
77Unless \fBleaveok\fP(3) has been
78enabled, the physical cursor of the terminal is left at the location of the
79cursor for that window.
80.SS wnoutrefresh/doupdate
81The \fBwnoutrefresh\fP and \fBdoupdate\fP routines allow multiple updates with
82more efficiency than \fBwrefresh\fP alone.
83In addition to all the window
84structures, \fBcurses\fP keeps two data structures representing the terminal
85screen:
86.bP
87a \fIphysical screen\fP,
88describing what is actually on the screen, and
89.bP
90a \fIvirtual screen\fP,
91describing what the programmer wants to have on the screen.
92.PP
93The routine \fBwrefresh\fP works by
94.bP
95first calling \fBwnoutrefresh\fP,
96which copies the named window to the \fIvirtual screen\fP, and
97.bP
98then calling \fBdoupdate\fP, which compares
99the \fIvirtual screen\fP to the \fIphysical screen\fP
100and does the actual update.
101.PP
102If the programmer wishes to output several windows at once, a series
103of calls to \fBwrefresh\fP results in alternating calls to \fBwnoutrefresh\fP
104and \fBdoupdate\fP, causing several bursts of output to the screen.
105By first
106calling \fBwnoutrefresh\fP for each window, it is then possible to call
107\fBdoupdate\fP once, resulting in only one burst of output, with fewer total
108characters transmitted and less CPU time used.
109.PP
110If the \fIwin\fP argument to
111\fBwrefresh\fP is the \fIphysical screen\fP
112(i.e., the global variable \fBcurscr\fP),
113the screen is immediately cleared and repainted from scratch.
114.PP
115The phrase \*(``copies the named window
116to the virtual screen\*('' above is ambiguous.
117What actually happens is that all \fItouched\fP (changed) lines in the window
118are copied to the virtual screen.
119This affects programs that use overlapping
120windows; it means that if two windows overlap, you can refresh them in either
121order and the overlap region will be modified only when it is explicitly
122changed.
123(But see the section on \fBPORTABILITY\fP below for a warning about
124exploiting this behavior.)
125.SS wredrawln/redrawwin
126The \fBwredrawln\fP routine indicates to \fBcurses\fP that some screen lines
127are corrupted and should be thrown away before anything is written over them.
128It touches the indicated lines (marking them changed).
129The routine \fBredrawwin\fP touches the entire window.
130.SH RETURN VALUE
131Routines that return an integer return \fBERR\fP upon failure, and \fBOK\fP
132(SVr4 only specifies "an integer value other than \fBERR\fP") upon successful
133completion.
134.PP
135X/Open does not define any error conditions.
136In this implementation
137.RS 3
138.TP 5
139\fBwnoutrefresh\fP
140returns an error
141if the window pointer is null, or
142if the window is really a pad.
143.TP 5
144\fBwredrawln\fP
145returns an error
146if the associated call to \fBtouchln\fP returns an error.
147.RE
148.SH NOTES
149Note that \fBrefresh\fP and \fBredrawwin\fP may be macros.
150.SH PORTABILITY
151The XSI Curses standard, Issue 4 describes these functions.
152.PP
153Whether \fBwnoutrefresh\fP copies to the virtual screen the entire contents
154of a window or just its changed portions has never been well-documented in
155historic curses versions (including SVr4).
156It might be unwise to rely on
157either behavior in programs that might have to be linked with other curses
158implementations.
159Instead, you can do an explicit \fBtouchwin\fP before the
160\fBwnoutrefresh\fP call to guarantee an entire-contents copy anywhere.
161.SH SEE ALSO
162\fBcurses\fP(3),
163\fBcurs_outopts\fP(3)
164\fBcurs_variables\fP(3).