]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_refresh.3x
ncurses 6.4 - patch 20240420
[ncurses.git] / man / curs_refresh.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 1998-2010,2016 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_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 ..
47 .SH NAME
48 \fB\%doupdate\fP,
49 \fB\%redrawwin\fP,
50 \fB\%refresh\fP,
51 \fB\%wnoutrefresh\fP,
52 \fB\%wredrawln\fP,
53 \fB\%wrefresh\fP \-
54 refresh \fIcurses\fR windows or lines thereupon
55 .SH SYNOPSIS
56 .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
67 .SH DESCRIPTION
68 .SS "refresh, wrefresh"
69 The \fBrefresh\fP and \fBwrefresh\fP routines (or \fBwnoutrefresh\fP and
70 \fBdoupdate\fP) must be called to get actual output to the terminal,
71 as other routines merely manipulate data structures.
72 The routine \fBwrefresh\fP copies
73 the named window to the \fIphysical screen\fP,
74 taking into account what is already there to do optimizations.
75 The \fBrefresh\fP routine is the
76 same, using \fBstdscr\fP as the default window.
77 Unless \fBleaveok\fP(3X) has been
78 enabled, the physical cursor of the terminal is left at the location of the
79 cursor for that window.
80 .SS "wnoutrefresh, doupdate"
81 The \fBwnoutrefresh\fP and \fBdoupdate\fP routines allow multiple updates with
82 more efficiency than \fBwrefresh\fP alone.
83 In addition to all the window
84 structures, \fBcurses\fP keeps two data structures representing the terminal
85 screen:
86 .bP
87 a \fIphysical screen\fP,
88 describing what is actually on the screen, and
89 .bP
90 a \fIvirtual screen\fP,
91 describing what the programmer wants to have on the screen.
92 .PP
93 The routine \fBwrefresh\fP works by
94 .bP
95 first calling \fBwnoutrefresh\fP,
96 which copies the named window to the \fIvirtual screen\fP, and
97 .bP
98 then calling \fBdoupdate\fP, which compares
99 the \fIvirtual screen\fP to the \fIphysical screen\fP
100 and does the actual update.
101 .PP
102 If the programmer wishes to output several windows at once, a series
103 of calls to \fBwrefresh\fP results in alternating calls to \fBwnoutrefresh\fP
104 and \fBdoupdate\fP, causing several bursts of output to the screen.
105 By first
106 calling \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
108 characters transmitted and less CPU time used.
109 .PP
110 If the \fIwin\fP argument to
111 \fBwrefresh\fP is the \fIphysical screen\fP
112 (i.e., the global variable \fBcurscr\fP),
113 the screen is immediately cleared and repainted from scratch.
114 .PP
115 The phrase \*(``copies the named window
116 to the virtual screen\*('' above is ambiguous.
117 What actually happens is that all \fItouched\fP (changed) lines in the window
118 are copied to the virtual screen.
119 This affects programs that use overlapping
120 windows; it means that if two windows overlap, you can refresh them in either
121 order and the overlap region will be modified only when it is explicitly
122 changed.
123 (But see the section on \fBPORTABILITY\fP below for a warning about
124 exploiting this behavior.)
125 .SS "wredrawln, redrawwin"
126 The \fBwredrawln\fP routine indicates to \fBcurses\fP that some screen lines
127 are corrupted and should be thrown away before anything is written over them.
128 It touches the indicated lines (marking them changed).
129 The routine \fBredrawwin\fP touches the entire window.
130 .SH RETURN VALUE
131 These routines return the integer \fBERR\fP upon failure and \fBOK\fP
132 (SVr4 specifies only
133 \*(``an integer value other than \fBERR\fP\*('')
134 upon successful completion.
135 .PP
136 X/Open Curses does not specify any error conditions.
137 In this implementation
138 .RS 3
139 .TP 5
140 \fBwnoutrefresh\fP
141 returns an error
142 if the window pointer is null, or
143 if the window is really a pad.
144 .TP 5
145 \fBwredrawln\fP
146 returns an error
147 if the associated call to \fBtouchln\fP returns an error.
148 .RE
149 .SH NOTES
150 Note that \fBrefresh\fP and \fBredrawwin\fP may be macros.
151 .SH PORTABILITY
152 X/Open Curses, Issue 4 describes these functions.
153 .PP
154 Whether \fBwnoutrefresh\fP copies to the virtual screen the entire contents
155 of a window or just its changed portions has never been well-documented in
156 historic curses versions (including SVr4).
157 It might be unwise to rely on
158 either behavior in programs that might have to be linked with other curses
159 implementations.
160 Instead, you can do an explicit \fBtouchwin\fP before the
161 \fBwnoutrefresh\fP call to guarantee an entire-contents copy anywhere.
162 .SH SEE ALSO
163 \fB\%curses\fP(3X),
164 \fB\%curs_outopts\fP(3X)
165 \fB\%curs_variables\fP(3X)