blob: 5f14a2287268818ad2915351956c5637d4100e63 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2010,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: curs_scr_dump.3x,v 1.43 2024/04/20 18:54:36 tom Exp $
31.TH curs_scr_dump 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 Kachhape6a01f52011-07-20 11:45:59 +053047.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040048\fB\%scr_dump\fP,
49\fB\%scr_restore\fP,
50\fB\%scr_init\fP,
51\fB\%scr_set\fP \-
52read/write a \fIcurses\fR screen from/to a file
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053053.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040054.nf
55\fB#include <curses.h>
56.PP
57\fBint scr_dump(const char *\fIfilename\fP);
58\fBint scr_restore(const char *\fIfilename\fP);
59\fBint scr_init(const char *\fIfilename\fP);
60\fBint scr_set(const char *\fIfilename\fP);
61.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053062.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040063.I curses
64provides applications the ability to write the contents of the screen
65to a file and read them back.
66To read/write a window
67(rather than the whole screen)
68from/to a file,
69use \fB\%getwin\fP(3X) and
70\fB\%putwin\fP(3X),
71respectively.
72.SS scr_dump
73\fB\%scr_dump\fP writes to
74.I filename
75the contents of the virtual screen;
76see \fB\%curscr\fP(3X).
77.SS scr_restore
78\fB\%scr_restore\fP updates the virtual screen to contain the contents
79of
80.I filename
81(if it was validly written with \fB\%scr_dump\fP).
82No refresh is performed;
83after performing any further desired updates,
84call \fB\%doupdate\fP(3X) or similar.
85.SS scr_init
86\fB\%scr_init\fP reads
87.IR filename ,
88using it to initialize
89.I curses
90data structures describing the state of the terminal screen.
91If these data are valid,
92.I curses
93bases its next update of the screen on this information rather than
94clearing it and starting from scratch.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053095.PP
micky3879b9f5e72025-07-08 18:04:53 -040096The data fail the validity check
97.bP
98if the terminal employs
99.I \%term\%info
100capabilities
101.B \%exit_ca_mode
102.RB ( \%rmcup )
103or
104.B \%non_rev_rmcup
105.RB ( \%nrrmc )
106are defined,
107or
108.bP
109if
110.I curses
111knows that the terminal has been written to since the preceding
112\fB\%scr_dump\fP call.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530113.PP
micky3879b9f5e72025-07-08 18:04:53 -0400114\fB\%scr_init\fP could be used after \fB\%initscr\fP(3X) or
115\fB\%system\fP(3) to share the screen with another process that has
116done a \fBscr_dump\fP after \fB\%endwin\fP(3X).
117.SS scr_set
118The \fBscr_set\fP routine is a combination of \fBscr_restore\fP and
119\fBscr_init\fP. It tells the program that the information in \fIfilename\fP is
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530120what is currently on the screen, and also what the program wants on the screen.
121This can be thought of as a screen inheritance function.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530122.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400123These functions return \fBOK\fP on success and \fBERR\fP on failure.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124.PP
micky3879b9f5e72025-07-08 18:04:53 -0400125X/Open defines no failure conditions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530126In this implementation,
micky3879b9f5e72025-07-08 18:04:53 -0400127each function fails if it cannot open
128.IR filename .
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530129.SH NOTES
micky3879b9f5e72025-07-08 18:04:53 -0400130\fB\%scr_init\fP,
131\fB\%scr_set\fP,
132and
133\fB\%scr_restore\fP may be macros.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530134.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400135X/Open Curses,
136Issue 4 describes these functions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530137.PP
micky3879b9f5e72025-07-08 18:04:53 -0400138.\" SVID 4, p. 529
139SVr4 omitted the
140.I \%const
141qualifiers.
142.PP
143SVr4 documentation describes \fB\%scr_init\fP such that the dump data is
144also considered invalid \*(``if the time-stamp of the tty is old\*(''
145but does not define \*(``old\*(''.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530146.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400147\fB\%curses\fP(3X),
148\fB\%curs_initscr\fP(3X),
149\fB\%curs_refresh\fP(3X),
150\fB\%curs_util\fP(3X),
151\fB\%system\fP(3),
152\fB\%scr_dump\fP(5)