Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2010,2016 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: curs_refresh.3x,v 1.46 2024/04/20 21:20:07 tom Exp $ |
| 31 | .TH curs_refresh 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 67 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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(3X) has been |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 78 | enabled, the physical cursor of the terminal is left at the location of the |
| 79 | cursor for that window. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 80 | .SS "wnoutrefresh, doupdate" |
| 81 | The \fBwnoutrefresh\fP and \fBdoupdate\fP routines allow multiple updates with |
| 82 | more efficiency than \fBwrefresh\fP alone. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 83 | In addition to all the window |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 92 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 102 | If the programmer wishes to output several windows at once, a series |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 105 | By first |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 108 | characters transmitted and less CPU time used. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 109 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | (But see the section on \fBPORTABILITY\fP below for a warning about |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 124 | exploiting this behavior.) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 125 | .SS "wredrawln, redrawwin" |
| 126 | The \fBwredrawln\fP routine indicates to \fBcurses\fP that some screen lines |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 127 | are corrupted and should be thrown away before anything is written over them. |
| 128 | It touches the indicated lines (marking them changed). |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 129 | The routine \fBredrawwin\fP touches the entire window. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 130 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 131 | These routines return the integer \fBERR\fP upon failure and \fBOK\fP |
| 132 | (SVr4 specifies only |
| 133 | \*(``an integer value other than \fBERR\fP\*('') |
| 134 | upon successful completion. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 135 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 136 | X/Open Curses does not specify any error conditions. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 137 | In this implementation |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 138 | .RS 3 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 139 | .TP 5 |
| 140 | \fBwnoutrefresh\fP |
| 141 | returns an error |
| 142 | if the window pointer is null, or |
| 143 | if the window is really a pad. |
| 144 | .TP 5 |
| 145 | \fBwredrawln\fP |
| 146 | returns an error |
| 147 | if the associated call to \fBtouchln\fP returns an error. |
| 148 | .RE |
| 149 | .SH NOTES |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 150 | Note that \fBrefresh\fP and \fBredrawwin\fP may be macros. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 151 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 152 | X/Open Curses, Issue 4 describes these functions. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 153 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 154 | Whether \fBwnoutrefresh\fP copies to the virtual screen the entire contents |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 155 | of a window or just its changed portions has never been well-documented in |
| 156 | historic curses versions (including SVr4). |
| 157 | It might be unwise to rely on |
| 158 | either behavior in programs that might have to be linked with other curses |
| 159 | implementations. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 160 | Instead, you can do an explicit \fBtouchwin\fP before the |
| 161 | \fBwnoutrefresh\fP call to guarantee an entire-contents copy anywhere. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 162 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 163 | \fB\%curses\fP(3X), |
| 164 | \fB\%curs_outopts\fP(3X) |
| 165 | \fB\%curs_variables\fP(3X) |