Debian Codegraph @

upstream/debian-unstable/man3/refresh.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 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.58 2025/01/19 00:51:10 tom Exp $
31 .TH refresh 3NCURSES 2025-01-18 "ncurses 6.6" "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(3NCURSES) 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 .PP
133 In this implementation
134 .RS 3
135 .TP 5
136 \fBwnoutrefresh\fP
137 returns
138 .B ERR
139 if the window pointer is null, or
140 if the window is really a pad.
141 .TP 5
142 \fBwredrawln\fP
143 return
144 .B ERR
145 if the associated call to \fBtouchln\fP returns
146 .BR ERR "."
147 .RE
148 .SH NOTES
149 .B \%refresh
150 and
151 .B \%redrawwin
152 may be implemented as macros.
153 .SH PORTABILITY
154 X/Open Curses Issue\ 4 describes these functions.
155 It specifies no error conditions for them.
156 .PP
157 SVr4 describes a successful return value only as
158 \*(``an integer value other than
159 .IR ERR \*(''. \" Courier roman in source; SVID 4, vol. 3, p. 527
160 .PP
161 Whether \fBwnoutrefresh\fP copies to the virtual screen the entire contents
162 of a window or just its changed portions has never been well-documented in
163 historic curses versions (including SVr4).
164 It might be unwise to rely on
165 either behavior in programs that might have to be linked with other curses
166 implementations.
167 Instead, you can do an explicit \fBtouchwin\fP before the
168 \fBwnoutrefresh\fP call to guarantee an entire-contents copy anywhere.
169 .SH SEE ALSO
170 \fB\%ncurses\fP(3NCURSES),
171 \fB\%outopts\fP(3NCURSES),
172 \fB\%curses_variables\fP(3NCURSES)