]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_refresh.3x
ncurses 6.1 - patch 20190302
[ncurses.git] / man / curs_refresh.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2016,2018 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_refresh.3x,v 1.19 2018/07/28 22:59:02 tom Exp $
30 .TH curs_refresh 3X ""
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .de bP
36 .ie n  .IP \(bu 4
37 .el    .IP \(bu 2
38 ..
39 .na
40 .hy 0
41 .SH NAME
42 \fBdoupdate\fR,
43 \fBredrawwin\fR,
44 \fBrefresh\fR,
45 \fBwnoutrefresh\fR,
46 \fBwredrawln\fR,
47 \fBwrefresh\fR \- refresh \fBcurses\fR windows and lines
48 .ad
49 .hy
50 .SH SYNOPSIS
51 \fB#include <curses.h>\fR
52 .sp
53 \fBint refresh(void);\fR
54 .br
55 \fBint wrefresh(WINDOW *win);\fR
56 .br
57 \fBint wnoutrefresh(WINDOW *win);\fR
58 .br
59 \fBint doupdate(void);\fR
60 .br
61 \fBint redrawwin(WINDOW *win);\fR
62 .br
63 \fBint wredrawln(WINDOW *win, int beg_line, int num_lines);\fR
64 .br
65 .SH DESCRIPTION
66 .SS refresh/wrefresh
67 The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
68 \fBdoupdate\fR) must be called to get actual output to the terminal,
69 as other routines merely manipulate data structures.
70 The routine \fBwrefresh\fR copies
71 the named window to the \fIphysical screen\fP,
72 taking into account what is already there to do optimizations.
73 The \fBrefresh\fR routine is the
74 same, using \fBstdscr\fR as the default window.
75 Unless \fBleaveok\fR 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 .PP
80 The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
81 more efficiency than \fBwrefresh\fR alone.
82 In addition to all the window
83 structures, \fBcurses\fR keeps two data structures representing the terminal
84 screen:
85 .bP
86 a \fIphysical screen\fP, describing what is actually on the screen, and
87 .bP
88 a \fIvirtual screen\fP, describing what the programmer wants to have on the screen.
89 .PP
90 The routine \fBwrefresh\fR works by
91 .bP
92 first calling \fBwnoutrefresh\fR,
93 which copies the named window to the \fIvirtual screen\fP, and
94 .bP
95 then calling \fBdoupdate\fR, which compares
96 the \fIvirtual screen\fP to the \fIphysical screen\fP
97 and does the actual update.
98 .PP
99 If the programmer wishes to output several windows at once, a series
100 of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
101 and \fBdoupdate\fR, causing several bursts of output to the screen.
102 By first
103 calling \fBwnoutrefresh\fR for each window, it is then possible to call
104 \fBdoupdate\fR once, resulting in only one burst of output, with fewer total
105 characters transmitted and less CPU time used.
106 .PP
107 If the \fIwin\fR argument to
108 \fBwrefresh\fR is the \fIphysical screen\fP
109 (i.e., the global variable \fBcurscr\fR),
110 the screen is immediately cleared and repainted from scratch.
111 .PP
112 The phrase \*(``copies the named window to the virtual screen\*('' above is ambiguous.
113 What actually happens is that all \fItouched\fR (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\fR below for a warning about
120 exploiting this behavior.)
121 .SS wredrawln/redrawwin
122 .PP
123 The \fBwredrawln\fR routine indicates to \fBcurses\fR that some screen lines
124 are corrupted and should be thrown away before anything is written over them.
125 It touches the indicated lines (marking them changed).
126 The routine \fBredrawwin\fR touches the entire window.
127 .SH RETURN VALUE
128 Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
129 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
130 completion.
131 .PP
132 X/Open does not define any error conditions.
133 In this implementation
134 .RS 3
135 .TP 5
136 \fBwnoutrefresh\fP
137 returns an error
138 if the window pointer is null, or
139 if the window is really a pad.
140 .TP 5
141 \fBwredrawln\fP
142 returns an error
143 if the associated call to \fBtouchln\fP returns an error.
144 .RE
145 .SH NOTES
146 Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
147 .SH PORTABILITY
148 The XSI Curses standard, Issue 4 describes these functions.
149 .PP
150 Whether \fBwnoutrefresh\fR copies to the virtual screen the entire contents
151 of a window or just its changed portions has never been well-documented in
152 historic curses versions (including SVr4).
153 It might be unwise to rely on
154 either behavior in programs that might have to be linked with other curses
155 implementations.
156 Instead, you can do an explicit \fBtouchwin\fR before the
157 \fBwnoutrefresh\fR call to guarantee an entire-contents copy anywhere.
158 .SH SEE ALSO
159 \fBcurses\fR(3X),
160 \fBcurs_outopts\fR(3X)
161 \fBcurs_variables\fR(3X).