]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - man/scr_dump.5
ncurses 6.4 - patch 20231028
[ncurses.git] / man / scr_dump.5
index fd2e1a07e52fb7ddd9bff6ab9c7fce02283d8a43..7bc736dda2e3e8a7d8a1720abbd1ed24f948192a 100644 (file)
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
+.\" Copyright 2018-2021,2023 Thomas E. Dickey                                *
 .\" Copyright 2017 Free Software Foundation, Inc.                            *
 .\"                                                                          *
 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: scr_dump.5,v 1.20 2021/12/25 21:13:38 tom Exp $
-.TH scr_dump 5
-.ie \n(.g .ds `` \(lq
-.el       .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el       .ds '' ''
-.de NS
-.ie n  .sp
-.el    .sp .5
-.ie n  .in +4
-.el    .in +2
-.nf
-.ft C                  \" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n  .in -4
-.el    .in -2
-..
+.\" $Id: scr_dump.5,v 1.37 2023/10/07 21:19:07 tom Exp $
+.TH scr_dump 5 2023-10-07 "ncurses 6.4" "File formats"
+.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
-scr_dump \- format of curses screen-dumps.
+scr_dump \-
+\fIcurses\fR screen dump
 .SH SYNOPSIS
 .B scr_dump
 .SH DESCRIPTION
-.PP
 The curses library provides applications with the ability to write the
 contents of a window to an external file using \fBscr_dump\fP or \fBputwin\fP,
 and read it back using \fBscr_restore\fP or \fBgetwin\fP.
@@ -65,10 +58,9 @@ The \fBputwin\fP and \fBgetwin\fP functions do the work;
 while \fBscr_dump\fP and \fBscr_restore\fP conveniently save and restore
 the whole screen, i.e., \fBstdscr\fP.
 .SS ncurses6
-.PP
 A longstanding implementation of screen-dump was
 revised with ncurses6 to remedy problems with the earlier approach:
-.bP
+.IP \(bu 4
 A \*(``magic number\*('' is written to the beginning of the dump file,
 allowing applications (such as \fBfile\fP(1)) to recognize curses dump files.
 .IP
@@ -76,25 +68,36 @@ Because ncurses6 uses a new format,
 that requires a new magic number
 was unused by other applications.
 This 16-bit number was unused:
-.NS
-0x8888 (octal \*(``\\210\\210\*('')
-.NE
-.IP
+.RS 4
+.PP
+.RS 4
+.EX
+0x8888 (octal \*(``\e210\e210\*('')
+.EE
+.RE
+.PP
 but to be more certain, this 32-bit number was chosen:
-.NS
-0x88888888 (octal \*(``\\210\\210\\210\\210\*('')
-.NE
-.IP
+.PP
+.RS 4
+.EX
+0x88888888 (octal \*(``\e210\e210\e210\e210\*('')
+.EE
+.RE
+.PP
 This is the pattern submitted to the maintainers of the \fBfile\fP program:
-.NS
+.PP
+.RS 4
+.EX
 #
 # ncurses5 (and before) did not use a magic number,
 # making screen dumps "data".
 #
 # ncurses6 (2015) uses this format, ignoring byte-order
-0    string    \\210\\210\\210\\210ncurses    ncurses6 screen image
+0    string    \e210\e210\e210\e210ncurses    ncurses6 screen image
 #
-.NE
+.EE
+.RE
+.RE
 .bP
 The screen dumps are written in textual form,
 so that internal data sizes are not directly related to the dump-format, and
@@ -112,7 +115,6 @@ because the library truncates or fills the screen as necessary.
 .bP
 The ncurses6 \fBgetwin\fP reads the legacy screen dumps from ncurses5.
 .SS ncurses5 (legacy)
-.PP
 The screen-dump feature was added to ncurses in June 1995.
 While there were fixes and improvements in succeeding years,
 the basic scheme was unchanged:
@@ -126,14 +128,12 @@ When \fBgetwin\fP restored the window,
 it would keep track of offsets into the array of line-data
 and adjust the \fBWINDOW\fP structure which was read back into memory.
 .PP
-This is similar to Unix SystemV,
+This is similar to Unix SystemV,
 but does not write a \*(``magic number\*('' to identify the file format.
 .SH PORTABILITY
-.PP
 There is no standard format for \fBputwin\fP.
 This section gives a brief description of the existing formats.
 .SS X/Open Curses
-.PP
 Refer to \fIX/Open Curses, Issue 7\fP (2009).
 .PP
 X/Open's documentation for \fIenhanced curses\fP says only:
@@ -170,38 +170,46 @@ or more specific portability warnings about use of the material.
 In the foregoing, emphasis was added to \fBunspecified format\fP
 and to \fBXPG4 or to earlier XPG releases\fP,
 for clarity.
-.SS Unix SystemV
-.PP
-Unix SystemV curses identified the file format by writing a
+.SS Unix System V
+Unix System\ V curses identified the file format by writing a
 \*(``magic number\*('' at the beginning of the dump.
 The \fBWINDOW\fP data and the lines of text follow, all in binary form.
 .PP
 The Solaris curses source has these definitions:
-.NS
+.PP
+.RS 4
+.EX
 /* terminfo magic number */
 #define MAGNUM  0432
 
 /* curses screen dump magic number */
 #define SVR2_DUMP_MAGIC_NUMBER  0433
 #define SVR3_DUMP_MAGIC_NUMBER  0434
-.NE
+.EE
+.RE
 .PP
 That is, the feature was likely introduced in SVr2 (1984),
 and improved in SVr3 (1987).
 The Solaris curses source has no magic number for SVr4 (1989).
 Other operating systems (AIX and HPUX) use a magic number which would
 correspond to this definition:
-.NS
+.PP
+.RS 4
+.EX
 /* curses screen dump magic number */
 #define SVR4_DUMP_MAGIC_NUMBER  0435
-.NE
+.EE
+.RE
 .PP
 That octal number in bytes is 001, 035.
 Because most Unix vendors use big-endian hardware,
 the magic number is written with the high-order byte first, e.g.,
-.NS
-\001\035
-.NE
+.PP
+.RS 4
+.EX
+\e001\e035
+.EE
+.RE
 .PP
 After the magic number, the \fBWINDOW\fP structure and line-data are
 written in binary format.
@@ -222,7 +230,6 @@ Solaris 10 (13273 bytes)
 .bP
 ncurses5 (12888 bytes)
 .SS Solaris
-.PP
 As noted above, Solaris curses has no magic number corresponding
 to SVr4 curses.
 This is odd since Solaris was the first operating system
@@ -242,18 +249,19 @@ Unlike ncurses6, the contents of the window are written piecemeal,
 with coordinates and attributes for each chunk of text rather
 than writing the whole window from top to bottom.
 .SS PDCurses
-.PP
 PDCurses added support for screen dumps in version 2.7 (2005).
-Like Unix SystemV and ncurses5,
+Like Unix SystemV and ncurses5,
 it writes the \fBWINDOW\fP structure in binary,
 but begins the file with its three-byte identifier \*(``PDC\*('',
 followed by a one-byte version,
 e.g.,
-.NS
-       \*(``PDC\\001\*(''
-.NE
-.SS NetBSD
 .PP
+.RS 4
+.EX
+       \*(``PDC\e001\*(''
+.EE
+.RE
+.SS NetBSD
 As of April 2017, NetBSD curses does
 not support \fBscr_dump\fP and \fBscr_restore\fP
 (or \fBscr_init\fP, \fBscr_set\fP),
@@ -272,10 +280,11 @@ some data for wide-characters referenced by the \fBWINDOW\fP structure, and
 .bP
 finally, lines as done by other implementations.
 .SH EXAMPLE
-.PP
 Given a simple program which writes text to the screen
 (and for the sake of example, limiting the screen-size to 10x20):
-.NS
+.PP
+.RS 4
+.EX
 #include <curses.h>
 
 int
@@ -300,33 +309,37 @@ main(void)
     endwin();
     return 0;
 }
-.NE
+.EE
+.RE
 .PP
 When run using ncurses6, the output looks like this:
-.NS
-\\210\\210\\210\\210ncurses 6.0.20170415
+.PP
+.RS 4
+.EX
+\e210\e210\e210\e210ncurses 6.0.20170415
 _cury=5
 _curx=11
 _maxy=9
 _maxx=19
 _flags=14
-_attrs=\\{REVERSE|C2}
+_attrs=\e{REVERSE|C2}
 flag=_idcok
 _delay=-1
 _regbottom=9
-_bkgrnd=\\{NORMAL|C1}\\s
+_bkgrnd=\e{NORMAL|C1}\es
 rows:
-1:\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-2:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-3:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-4:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-5:\\s\\s\\s\\s\\s\\{BOLD}Hello\\{NORMAL}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-6:\\s\\s\\s\\s\\s\\{REVERSE|C2}World!\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s
-7:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-8:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-9:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-10:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-.NE
+1:\e{NORMAL|C1}\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+2:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+3:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+4:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+5:\es\es\es\es\es\e{BOLD}Hello\e{NORMAL}\es\es\es\es\es\es\es\es\es\es
+6:\es\es\es\es\es\e{REVERSE|C2}World!\e{NORMAL|C1}\es\es\es\es\es\es\es\es\es
+7:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+8:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+9:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+10:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+.EE
+.RE
 .PP
 The first four octal escapes are actually nonprinting characters,
 while the remainder of the file is printable text.
@@ -334,10 +347,10 @@ You may notice:
 .bP
 The actual color pair values are not written to the file.
 .bP
-All characters are shown in printable form; spaces are \*(``\\s\*('' to
+All characters are shown in printable form; spaces are \*(``\es\*('' to
 ensure they are not overlooked.
 .bP
-Attributes are written in escaped curly braces, e.g., \*(``\\{BOLD}\*('',
+Attributes are written in escaped curly braces, e.g., \*(``\e{BOLD}\*('',
 and may include a color-pair (C1 or C2 in this example).
 .bP
 The parameters in the header are written out only if they are nonzero.
@@ -345,7 +358,9 @@ When reading back, order does not matter.
 .ne 10
 .PP
 Running the same program with Solaris \fIxpg4\fP curses gives this dump:
-.NS
+.PP
+.RS 4
+.EX
 MAX=10,20
 BEG=0,0
 SCROLL=0,10
@@ -379,7 +394,8 @@ BG=0,0,
 9,0,0,1,
 9,19,0,0,
 CUR=11,5
-.NE
+.EE
+.RE
 .PP
 Solaris \fBgetwin\fP requires that all parameters are present, and
 in the same order.
@@ -389,8 +405,10 @@ The \fIxpg4\fP curses library does not know about the \fBbce\fP
 .PP
 On the other hand, the SVr4 curses library does know about the background color.
 However, its screen dumps are in binary.
-Here is the corresponding dump (using \*(``od -t x1\*(''):
-.NS
+Here is the corresponding dump (using \*(``od \-t x1\*(''):
+.PP
+.RS 4
+.EX
 0000000 1c 01 c3 d6 f3 58 05 00 0b 00 0a 00 14 00 00 00
 0000020 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00
 0000040 00 00 b8 1a 06 08 cc 1a 06 08 00 00 09 00 10 00
@@ -413,13 +431,9 @@ Here is the corresponding dump (using \*(``od -t x1\*(''):
 0001620 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 *
 0002371
-.NE
-.SH SEE ALSO
-.PP
-\fBcurs_scr_dump\fP(3X),
-\fBcurs_util\fP(3X).
+.EE
+.RE
 .SH AUTHORS
-.PP
 Thomas E. Dickey
 .br
 extended screen-dump format for ncurses 6.0 (2015)
@@ -427,3 +441,6 @@ extended screen-dump format for ncurses 6.0 (2015)
 Eric S. Raymond
 .br
 screen dump feature in ncurses 1.9.2d (1995)
+.SH SEE ALSO
+\fB\%curs_scr_dump\fP(3X),
+\fB\%curs_util\fP(3X)