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