.\"*************************************************************************** .\" Copyright 2018-2024,2025 Thomas E. Dickey * .\" Copyright 1998-2010,2017 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * .\" copy of this software and associated documentation files (the * .\" "Software"), to deal in the Software without restriction, including * .\" without limitation the rights to use, copy, modify, merge, publish, * .\" distribute, distribute with modifications, sublicense, and/or sell * .\" copies of the Software, and to permit persons to whom the Software is * .\" furnished to do so, subject to the following conditions: * .\" * .\" The above copyright notice and this permission notice shall be included * .\" in all copies or substantial portions of the Software. * .\" * .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * .\" * .\" Except as contained in this notice, the name(s) of the above copyright * .\" holders shall not be used in advertising or otherwise to promote the * .\" sale, use or other dealings in this Software without prior written * .\" authorization. * .\"*************************************************************************** .\" .\" $Id: curs_scr_dump.3x,v 1.55 2025/01/19 00:51:10 tom Exp $ .TH curs_scr_dump 3X 2025-01-18 "ncurses 6.5" "Library calls" .ie \n(.g \{\ .ds `` \(lq .ds '' \(rq .\} .el \{\ .ie t .ds `` `` .el .ds `` "" .ie t .ds '' '' .el .ds '' "" .\} . .de bP .ie n .IP \(bu 4 .el .IP \(bu 2 .. .SH NAME \fB\%scr_dump\fP, \fB\%scr_restore\fP, \fB\%scr_init\fP, \fB\%scr_set\fP \- read/write a \fIcurses\fR screen from/to a file .SH SYNOPSIS .nf \fB#include .PP \fBint scr_dump(const char * \fIfilename\fP); \fBint scr_restore(const char * \fIfilename\fP); \fBint scr_init(const char * \fIfilename\fP); \fBint scr_set(const char * \fIfilename\fP); .fi .SH DESCRIPTION .I curses provides applications the ability to write the contents of the screen to a file and read them back. To read/write a window (rather than the whole screen) from/to a file, use \fB\%getwin\fP(3X) and \fB\%putwin\fP(3X), respectively. .SS scr_dump .B \%scr_dump writes to .I filename the contents of the virtual screen; see \fB\%curscr\fP(3X). .SS scr_restore .B \%scr_restore updates the virtual screen to match the contents of .I filename (if validly written with .BR \%scr_dump ")." .I curses does not perform a refresh; after making any desired changes, call \fB\%doupdate\fP(3X) or similar. .SS scr_init .B \%scr_init reads .IR filename "," using it to initialize .I curses data structures describing the state of the terminal screen. .I curses then, if it decides the terminal state is valid, bases its next update of the screen on this information rather than clearing it and starting from scratch. .PP .I curses regards the terminal as in an invalid state for computation of updates based on the contents of .I filename if .bP .I curses knows that the terminal has been written to since the preceding .B \%scr_dump call, or .bP the terminal type supports the .I \%term\%info capabilities .B \%exit_ca_mode .RB \%( rmcup ) or .B \%non_rev_rmcup .RB \%( nrrmc ). .PP Either of the foregoing conditions means that .I curses cannot assume that the terminal's contents match their representation in .IR filename "." The former is due to terminal features (such as \fI\%xterm\fP(1)'s \*(``alternate screen\*('') that couple cursor-positioning mode with a local cache of screen contents. .I curses cannot know whether the terminal is displaying from that local cache at the time the application calls .BR \%scr_init "," so it makes a pessimistic assumption that a full redraw is required; see subsection \*(``Cursor Motions\*('' of \fB\%terminfo\fP(5). .PP .B \%scr_init could be used after \fB\%initscr\fP(3X) or \fI\%system\fP(3) to share the screen with another process that has done a .B \%scr_dump after \fB\%endwin\fP(3X). An application that supports suspending its state on exit and subsequent resumption upon later execution might use .B \%scr_dump and .B \%scr_init thus. .SS scr_set .B \%scr_set combines .B \%scr_restore and .BR \%scr_init "," synchronizing the contents of .I filename with the virtual screen. It can be regarded as a screen inheritance function; consider a real-time screen-sharing application. .SH RETURN VALUE These functions return .B OK on success and .B ERR on failure. .PP In .IR \%ncurses "," each function returns .B ERR if it cannot open .IR filename "." .BR \%scr_init "," .BR \%scr_restore "," and .B \%scr_set return .B ERR if the contents of .I filename are invalid. .SH NOTES .BR \%scr_init "," .BR \%scr_restore "," and .B \%scr_set may be implemented as macros. .SH PORTABILITY X/Open Curses Issue\ 4 describes these functions. It specifies no error conditions for them. .\" Unusually, SVID 4 explicitly indicated "OK" as a possible return .\" value, rather than the "integer other than ERR" refrain (p. 529). .PP .\" SVID 4, p. 529 SVr4 omitted the .I \%const qualifiers. .PP SVr4 documentation describes .I \%scr_init such that the dump data is also considered invalid \*(``if the time-stamp of the tty is old\*('' but does not define \*(``old\*(''. .PP As of 2024, .I \%PDCurses provides these functions. NetBSD .I curses does not. .PP Other implementations of .I curses store the window in binary form, which makes the dump dependent upon the .I curses library's internal data structures. .I \%ncurses avoids this drawback by storing the dump in textual form, allowing more flexible use of the data. For instance, the .I \%scr_restore of SVr4 .I curses requires that the dumped window have the same dimensions as the restored window. .I \%ncurses uses its \fB\%wresize\fP(3X) extension to adjust the restored window size. .SH HISTORY SVr3 (1987) introduced .IR \%scr_dump "," .IR \%scr_init "," and .IR \%scr_restore "." SVr3.1 added .IR \%scr_set "." .SH SEE ALSO .na \fB\%curses\fP(3X), \fB\%curs_initscr\fP(3X), \fB\%curs_refresh\fP(3X), \fB\%curs_util\fP(3X), \fB\%system\fP(3), \fB\%scr_dump\fP(5), \fB\%terminfo\fP(5), \fB\%wresize\fP(3X) .ad