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,2017 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_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 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\%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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 53 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 62 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 95 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 113 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 122 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | These functions return \fBOK\fP on success and \fBERR\fP on failure. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 124 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 125 | X/Open defines no failure conditions. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 126 | In this implementation, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 127 | each function fails if it cannot open |
| 128 | .IR filename . |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 129 | .SH NOTES |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 130 | \fB\%scr_init\fP, |
| 131 | \fB\%scr_set\fP, |
| 132 | and |
| 133 | \fB\%scr_restore\fP may be macros. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 134 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 135 | X/Open Curses, |
| 136 | Issue 4 describes these functions. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 137 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 138 | .\" SVID 4, p. 529 |
| 139 | SVr4 omitted the |
| 140 | .I \%const |
| 141 | qualifiers. |
| 142 | .PP |
| 143 | SVr4 documentation describes \fB\%scr_init\fP such that the dump data is |
| 144 | also considered invalid \*(``if the time-stamp of the tty is old\*('' |
| 145 | but does not define \*(``old\*(''. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 146 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 147 | \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) |