]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_refresh.3x
ncurses 4.1
[ncurses.git] / man / curs_refresh.3x
1 .TH curs_refresh 3X ""
2 .SH NAME
3 \fBrefresh\fR, \fBwrefresh\fR, \fBwnoutrefresh\fR,
4 \fBdoupdate\fR, \fBredrawwin\fR, \fBwredrawln\fR - refresh
5 \fBcurses\fR windows and lines
6 .SH SYNOPSIS
7 \fB#include <curses.h>\fR
8
9 \fBint refresh(void);\fR
10 .br
11 \fBint wrefresh(WINDOW *win);\fR
12 .br
13 \fBint wnoutrefresh(WINDOW *win);\fR
14 .br
15 \fBint doupdate(void);\fR
16 .br
17 \fBint redrawwin(WINDOW *win);\fR
18 .br
19 \fBint wredrawln(WINDOW *win, int beg_line, int num_lines);\fR
20 .br
21 .SH DESCRIPTION
22 The \fBrefresh\fR and \fBwrefresh\fR routines (or \fBwnoutrefresh\fR and
23 \fBdoupdate\fR) must be called to get actual output to the terminal, as other
24 routines merely manipulate data structures.  The routine \fBwrefresh\fR copies
25 the named window to the physical terminal screen, taking into account what is
26 already there in order to do optimizations.  The \fBrefresh\fR routine is the
27 same, using \fBstdscr\fR as the default window.  Unless \fBleaveok\fR has been
28 enabled, the physical cursor of the terminal is left at the location of the
29 cursor for that window.
30
31 The \fBwnoutrefresh\fR and \fBdoupdate\fR routines allow multiple updates with
32 more efficiency than \fBwrefresh\fR alone.  In addition to all the window
33 structures, \fBcurses\fR keeps two data structures representing the terminal
34 screen: a physical screen, describing what is actually on the screen, and a
35 virtual screen, describing what the programmer wants to have on the screen.
36
37 The routine \fBwrefresh\fR works by first calling \fBwnoutrefresh\fR, which
38 copies the named window to the virtual screen, and then calling \fBdoupdate\fR,
39 which compares the virtual screen to the physical screen and does the actual
40 update.  If the programmer wishes to output several windows at once, a series
41 of calls to \fBwrefresh\fR results in alternating calls to \fBwnoutrefresh\fR
42 and \fBdoupdate\fR, causing several bursts of output to the screen.  By first
43 calling \fBwnoutrefresh\fR for each window, it is then possible to call
44 \fBdoupdate\fR once, resulting in only one burst of output, with fewer total
45 characters transmitted and less CPU time used.  If the \fIwin\fR argument to
46 \fBwrefresh\fR is the global variable \fBcurscr\fR, the screen is immediately
47 cleared and repainted from scratch.
48
49 The phrase "copies the named window to the virtual screen" above is ambiguous.
50 What actually happens is that all \fItouched\fR (changed) lines in the window
51 are copied to the virtual screen.  This affects programs that use overlapping
52 windows; it means that if two windows overlap, you can refresh them in either
53 order and the overlap region will be modified only when it is explicitly
54 changed.  (But see the section on \fBPORTABILITY\fR below for a warning about
55 exploiting this behavior.)
56
57 The \fBwredrawln\fR routine indicates to \fBcurses\fR that some screen lines
58 are corrupted and should be thrown away before anything is written over them
59 it touches the indicated lines (marking them changed) then does a refresh
60 of the window. The routine \fBredrawwin\fR() touches the entire window and then
61 refreshes it.
62 .SH RETURN VALUE
63 Routines that return an integer return \fBERR\fR upon failure, and \fBOK\fR
64 (SVr4 only specifies "an integer value other than \fBERR\fR") upon successful
65 completion.
66 .SH NOTES
67 Note that \fBrefresh\fR and \fBredrawwin\fR may be macros.
68 .SH PORTABILITY
69 The XSI Curses standard, Issue 4 describes these functions.
70
71 Whether \fBwnoutrefresh()\fR copies to the virtual screen the entire contents
72 of a window or just its changed portions has never been well-documented in
73 historic curses versions (including SVr4).  It might be unwise to rely on
74 either behavior in programs that might have to be linked with other curses
75 implementations.  Instead, you can do an explicit \fBtouchwin()\fR before the
76 \fBwnoutrefresh()\fR call to guarantee an entire-contents copy anywhere.
77 .SH SEE ALSO
78 \fBcurses\fR(3X), \fBcurs_outopts\fR(3X)
79 .\"#
80 .\"# The following sets edit modes for GNU EMACS
81 .\"# Local Variables:
82 .\"# mode:nroff
83 .\"# fill-column:79
84 .\"# End: