blob: ac81d1e6393e7644eec68624c3eca995365f5f36 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2010,2016 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_refresh.3x,v 1.46 2024/04/20 21:20:07 tom Exp $
31.TH curs_refresh 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32.ie \n(.g \{\
33.ds `` \(lq
34.ds '' \(rq
35.\}
36.el \{\
37.ie t .ds `` ``
38.el .ds `` ""
39.ie t .ds '' ''
40.el .ds '' ""
41.\}
42.
43.de bP
44.ie n .IP \(bu 4
45.el .IP \(bu 2
46..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040048\fB\%doupdate\fP,
49\fB\%redrawwin\fP,
50\fB\%refresh\fP,
51\fB\%wnoutrefresh\fP,
52\fB\%wredrawln\fP,
53\fB\%wrefresh\fP \-
54refresh \fIcurses\fR windows or lines thereupon
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053055.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040056.nf
57\fB#include <curses.h>
58.PP
59\fBint refresh(void);
60\fBint wrefresh(WINDOW *\fIwin\fP);
61\fBint wnoutrefresh(WINDOW *\fIwin\fP);
62\fBint doupdate(void);
63.PP
64\fBint redrawwin(WINDOW *\fIwin\fP);
65\fBint wredrawln(WINDOW *\fIwin\fP, int \fIbeg_line\fP, int \fInum_lines\fP);
66.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053067.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040068.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(3X) has been
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053078enabled, the physical cursor of the terminal is left at the location of the
79cursor for that window.
micky3879b9f5e72025-07-08 18:04:53 -040080.SS "wnoutrefresh, doupdate"
81The \fBwnoutrefresh\fP and \fBdoupdate\fP routines allow multiple updates with
82more efficiency than \fBwrefresh\fP alone.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053083In addition to all the window
micky3879b9f5e72025-07-08 18:04:53 -040084structures, \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.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053092.PP
micky3879b9f5e72025-07-08 18:04:53 -040093The 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
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530102If the programmer wishes to output several windows at once, a series
micky3879b9f5e72025-07-08 18:04:53 -0400103of calls to \fBwrefresh\fP results in alternating calls to \fBwnoutrefresh\fP
104and \fBdoupdate\fP, causing several bursts of output to the screen.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530105By first
micky3879b9f5e72025-07-08 18:04:53 -0400106calling \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
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530108characters transmitted and less CPU time used.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530109.PP
micky3879b9f5e72025-07-08 18:04:53 -0400110If 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
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530118are 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.
micky3879b9f5e72025-07-08 18:04:53 -0400123(But see the section on \fBPORTABILITY\fP below for a warning about
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124exploiting this behavior.)
micky3879b9f5e72025-07-08 18:04:53 -0400125.SS "wredrawln, redrawwin"
126The \fBwredrawln\fP routine indicates to \fBcurses\fP that some screen lines
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530127are corrupted and should be thrown away before anything is written over them.
128It touches the indicated lines (marking them changed).
micky3879b9f5e72025-07-08 18:04:53 -0400129The routine \fBredrawwin\fP touches the entire window.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530130.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400131These routines return the integer \fBERR\fP upon failure and \fBOK\fP
132(SVr4 specifies only
133\*(``an integer value other than \fBERR\fP\*('')
134upon successful completion.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530135.PP
micky3879b9f5e72025-07-08 18:04:53 -0400136X/Open Curses does not specify any error conditions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530137In this implementation
micky3879b9f5e72025-07-08 18:04:53 -0400138.RS 3
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530139.TP 5
140\fBwnoutrefresh\fP
141returns an error
142if the window pointer is null, or
143if the window is really a pad.
144.TP 5
145\fBwredrawln\fP
146returns an error
147if the associated call to \fBtouchln\fP returns an error.
148.RE
149.SH NOTES
micky3879b9f5e72025-07-08 18:04:53 -0400150Note that \fBrefresh\fP and \fBredrawwin\fP may be macros.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530151.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400152X/Open Curses, Issue 4 describes these functions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530153.PP
micky3879b9f5e72025-07-08 18:04:53 -0400154Whether \fBwnoutrefresh\fP copies to the virtual screen the entire contents
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155of a window or just its changed portions has never been well-documented in
156historic curses versions (including SVr4).
157It might be unwise to rely on
158either behavior in programs that might have to be linked with other curses
159implementations.
micky3879b9f5e72025-07-08 18:04:53 -0400160Instead, you can do an explicit \fBtouchwin\fP before the
161\fBwnoutrefresh\fP call to guarantee an entire-contents copy anywhere.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530162.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400163\fB\%curses\fP(3X),
164\fB\%curs_outopts\fP(3X)
165\fB\%curs_variables\fP(3X)