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