]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_scr_dump.3x
ncurses 6.4 - patch 20240414
[ncurses.git] / man / curs_scr_dump.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 1998-2010,2017 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_scr_dump.3x,v 1.41 2024/03/23 20:41:15 tom Exp $
31 .TH curs_scr_dump 3X 2024-03-23 "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 ..
47 .SH NAME
48 \fB\%scr_dump\fP,
49 \fB\%scr_restore\fP,
50 \fB\%scr_init\fP,
51 \fB\%scr_set\fP \-
52 read/write a \fIcurses\fR screen from/to a file
53 .SH SYNOPSIS
54 .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
62 .SH DESCRIPTION
63 .I curses
64 provides applications the ability to write the contents of the screen
65 to a file and read them back.
66 To read/write a window
67 (rather than the whole screen)
68 from/to a file,
69 use \fB\%getwin\fP(3X) and
70 \fB\%putwin\fP(3X),
71 respectively.
72 .SS scr_dump
73 \fB\%scr_dump\fP writes to
74 .I filename
75 the contents of the virtual screen;
76 see \fB\%curscr\fP(3X).
77 .SS scr_restore
78 \fB\%scr_restore\fP updates the virtual screen to contain the contents
79 of
80 .I filename
81 (if it was validly written with \fB\%scr_dump\fP).
82 No refresh is performed;
83 after performing any further desired updates,
84 call \fB\%doupdate\fP(3X) or similar.
85 .SS scr_init
86 \fB\%scr_init\fP reads
87 .IR filename ,
88 using it to initialize
89 .I curses
90 data structures describing the state of the terminal screen.
91 If these data are valid,
92 .I curses
93 bases its next update of the screen on this information rather than
94 clearing it and starting from scratch.
95 .PP
96 The data fail the validity check
97 .bP
98 if the terminal employs
99 .I \%term\%info
100 capabilities
101 .B \%exit_ca_mode
102 .RB ( \%rmcup )
103 or
104 .B \%non_rev_rmcup
105 .RB ( \%nrrmc )
106 are defined,
107 or
108 .bP
109 if
110 .I curses
111 knows that the terminal has been written to since the preceding
112 \fB\%scr_dump\fP call.
113 .PP
114 \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
116 done a \fBscr_dump\fP after \fB\%endwin\fP(3X).
117 .SS scr_set
118 The \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
120 what is currently on the screen, and also what the program wants on the screen.
121 This can be thought of as a screen inheritance function.
122 .SH RETURN VALUE
123 These functions return \fBOK\fP on success and \fBERR\fP on failure.
124 .PP
125 X/Open defines no failure conditions.
126 In this implementation,
127 each function fails if it cannot open
128 .IR filename .
129 .SH NOTES
130 \fB\%scr_init\fP,
131 \fB\%scr_set\fP,
132 and
133 \fB\%scr_restore\fP may be macros.
134 .SH PORTABILITY
135 X/Open Curses, Issue 4, describes these functions.
136 .PP
137 .\" SVID 4, p. 529
138 SVr4 omitted the
139 .I \%const
140 qualifiers.
141 .PP
142 SVr4 documentation describes \fB\%scr_init\fP such that the dump data is
143 also considered invalid \*(``if the time-stamp of the tty is old\*(''
144 but does not define \*(``old\*(''.
145 .SH SEE ALSO
146 \fB\%curses\fP(3X),
147 \fB\%curs_initscr\fP(3X),
148 \fB\%curs_refresh\fP(3X),
149 \fB\%curs_util\fP(3X),
150 \fB\%system\fP(3),
151 \fB\%scr_dump\fP(5)