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