{
    "content": [
        {
            "type": "text",
            "text": "# scr_dump (man)\n\n## NAME\n\nscrdump - format of curses screen-dumps.\n\n## SYNOPSIS\n\nscrdump\n\n## DESCRIPTION\n\nThe  curses  library provides applications with the ability to write the contents of a window\nto an external file using scrdump or putwin, and read it back using scrrestore or getwin.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (2 subsections)\n- **PORTABILITY** (5 subsections)\n- **EXAMPLE**\n- **SEE ALSO**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "scr_dump",
        "section": "",
        "mode": "man",
        "summary": "scrdump - format of curses screen-dumps.",
        "synopsis": "scrdump",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Given a simple program which writes text to the screen (and for the sake of example, limiting",
            "the screen-size to 10x20):",
            "#include <curses.h>",
            "int",
            "main(void)",
            "putenv(\"LINES=10\");",
            "putenv(\"COLUMNS=20\");",
            "initscr();",
            "startcolor();",
            "initpair(1, COLORWHITE, COLORBLUE);",
            "initpair(2, COLORRED, COLORBLACK);",
            "bkgd(COLORPAIR(1));",
            "move(4, 5);",
            "attron(ABOLD);",
            "addstr(\"Hello\");",
            "move(5, 5);",
            "attroff(ABOLD);",
            "attrset(AREVERSE | COLORPAIR(2));",
            "addstr(\"World!\");",
            "refresh();",
            "scrdump(\"foo.out\");",
            "endwin();",
            "return 0;",
            "When run using ncurses6, the output looks like this:",
            "\\210\\210\\210\\210ncurses 6.0.20170415",
            "cury=5",
            "curx=11",
            "maxy=9",
            "maxx=19",
            "flags=14",
            "attrs=\\{REVERSE|C2}",
            "flag=idcok",
            "delay=-1",
            "regbottom=9",
            "bkgrnd=\\{NORMAL|C1}\\s",
            "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",
            "The first four octal escapes are actually nonprinting characters, while the remainder of  the",
            "file is printable text.  You may notice:",
            "•   The actual color pair values are not written to the file.",
            "•   All  characters are shown in printable form; spaces are “\\s” to ensure they are not over‐",
            "looked.",
            "•   Attributes are written in escaped curly braces, e.g., “\\{BOLD}”, and may include a color-",
            "pair (C1 or C2 in this example).",
            "•   The  parameters  in  the  header  are written out only if they are nonzero.  When reading",
            "back, order does not matter.",
            "Running the same program with Solaris xpg4 curses gives this dump:",
            "MAX=10,20",
            "BEG=0,0",
            "SCROLL=0,10",
            "VMIN=1",
            "VTIME=0",
            "FLAGS=0x1000",
            "FG=0,0",
            "BG=0,0,",
            "0,0,0,1,",
            "0,19,0,0,",
            "1,0,0,1,",
            "1,19,0,0,",
            "2,0,0,1,",
            "2,19,0,0,",
            "3,0,0,1,",
            "3,19,0,0,",
            "4,0,0,1,",
            "4,5,0x20,0,Hello",
            "4,10,0,1,",
            "4,19,0,0,",
            "5,0,0,1,",
            "5,5,0x4,2,World!",
            "5,11,0,1,",
            "5,19,0,0,",
            "6,0,0,1,",
            "6,19,0,0,",
            "7,0,0,1,",
            "7,19,0,0,",
            "8,0,0,1,",
            "8,19,0,0,",
            "9,0,0,1,",
            "9,19,0,0,",
            "CUR=11,5",
            "Solaris getwin requires that all parameters are present, and in the  same  order.   The  xpg4",
            "curses  library does not know about the bce (back color erase) capability, and does not color",
            "the window background.",
            "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”):",
            "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",
            "0000060 00 00 00 80 00 00 20 00 00 00 ff ff ff ff 00 00",
            "0000100 ff ff ff ff 00 00 00 00 20 80 00 00 20 80 00 00",
            "0000120 20 80 00 00 20 80 00 00 20 80 00 00 20 80 00 00",
            "0000620 20 80 00 00 20 80 00 00 20 80 00 00 48 80 00 04",
            "0000640 65 80 00 04 6c 80 00 04 6c 80 00 04 6f 80 00 04",
            "0000660 20 80 00 00 20 80 00 00 20 80 00 00 20 80 00 00",
            "0000740 20 80 00 00 20 80 00 00 20 80 00 00 57 00 81 00",
            "0000760 6f 00 81 00 72 00 81 00 6c 00 81 00 64 00 81 00",
            "0001000 21 00 81 00 20 80 00 00 20 80 00 00 20 80 00 00",
            "0001020 20 80 00 00 20 80 00 00 20 80 00 00 20 80 00 00",
            "0001540 20 80 00 00 20 80 00 00 00 00 f6 d1 01 00 f6 d1",
            "0001560 08 00 00 00 40 00 00 00 00 00 00 00 00 00 00 07",
            "0001600 00 04 00 01 00 01 00 00 00 01 00 00 00 00 00 00",
            "0001620 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
            "0002371"
        ],
        "see_also": [
            {
                "name": "scrdump",
                "section": "3NCURSES",
                "url": "https://www.chedong.com/phpMan.php/man/scrdump/3NCURSES/json"
            },
            {
                "name": "util",
                "section": "3NCURSES",
                "url": "https://www.chedong.com/phpMan.php/man/util/3NCURSES/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 6,
                "subsections": [
                    {
                        "name": "ncurses6",
                        "lines": 38
                    },
                    {
                        "name": "ncurses5 (legacy)",
                        "lines": 14
                    }
                ]
            },
            {
                "name": "PORTABILITY",
                "lines": 3,
                "subsections": [
                    {
                        "name": "X/Open Curses",
                        "lines": 26
                    },
                    {
                        "name": "Unix SystemV",
                        "lines": 40
                    },
                    {
                        "name": "Solaris",
                        "lines": 16
                    },
                    {
                        "name": "PDCurses",
                        "lines": 6
                    },
                    {
                        "name": "NetBSD",
                        "lines": 15
                    }
                ]
            },
            {
                "name": "EXAMPLE",
                "lines": 133,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 9,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "scrdump - format of curses screen-dumps.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "scrdump\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The  curses  library provides applications with the ability to write the contents of a window\nto an external file using scrdump or putwin, and read it back using scrrestore or getwin.\n\nThe putwin and getwin functions do the work; while scrdump and scrrestore conveniently save\nand restore the whole screen, i.e., stdscr.\n",
                "subsections": [
                    {
                        "name": "ncurses6",
                        "content": "A  longstanding  implementation  of  screen-dump was revised with ncurses6 to remedy problems\nwith the earlier approach:\n\n•   A “magic number” is written to the beginning of  the  dump  file,  allowing  applications\n(such as file(1)) to recognize curses dump files.\n\nBecause  ncurses6 uses a new format, that requires a new magic number was unused by other\napplications.  This 16-bit number was unused:\n\n0x8888 (octal “\\210\\210”)\n\nbut to be more certain, this 32-bit number was chosen:\n\n0x88888888 (octal “\\210\\210\\210\\210”)\n\nThis is the pattern submitted to the maintainers of the file program:\n\n#\n# ncurses5 (and before) did not use a magic number,\n# making screen dumps \"data\".\n#\n# ncurses6 (2015) uses this format, ignoring byte-order\n0    string    \\210\\210\\210\\210ncurses    ncurses6 screen image\n#\n\n•   The screen dumps are written in textual form, so that internal data  sizes  are  not  di‐\nrectly  related  to  the  dump-format, and enabling the library to read dumps from either\nnarrow- or wide-character- configurations.\n\nThe narrow library configuration holds  characters  and  video  attributes  in  a  32-bit\nchtype,  while  the  wide-character library stores this information in the cchart struc‐\nture, which is much larger than 32-bits.\n\n•   It is possible to read a screen dump into a terminal with a  different  screen-size,  be‐\ncause the library truncates or fills the screen as necessary.\n\n•   The ncurses6 getwin reads the legacy screen dumps from ncurses5.\n"
                    },
                    {
                        "name": "ncurses5 (legacy)",
                        "content": "The  screen-dump  feature  was added to ncurses in June 1995.  While there were fixes and im‐\nprovements in succeeding years, the basic scheme was unchanged:\n\n•   The WINDOW structure was written in binary form.\n\n•   The WINDOW structure refers to lines of data, which were written as an  array  of  binary\ndata following the WINDOW.\n\n•   When  getwin  restored the window, it would keep track of offsets into the array of line-\ndata and adjust the WINDOW structure which was read back into memory.\n\nThis is similar to Unix SystemV, but does not write a “magic number”  to  identify  the  file\nformat.\n"
                    }
                ]
            },
            "PORTABILITY": {
                "content": "There is no standard format for putwin.  This section gives a brief description of the exist‐\ning formats.\n",
                "subsections": [
                    {
                        "name": "X/Open Curses",
                        "content": "Refer to X/Open Curses, Issue 7 (2009).\n\nX/Open's documentation for enhanced curses says only:\n\nThe getwin( ) function reads window-related data stored in the  file  by  putwin( ).   The\nfunction then creates and initializes a new window using that data.\n\nThe  putwin( ) function writes all data associated with win into the stdio stream to which\nfilep points, using an unspecified format.  This information can be retrieved later  using\ngetwin( ).\n\nIn  the mid-1990s when the X/Open Curses document was written, there were still systems using\nolder, less capable curses libraries (aside from the BSD curses library which was  not  rele‐\nvant to X/Open because it did not meet the criteria for base curses).  The document explained\nthe term “enhanced” as follows:\n\n•   Shading is used to identify X/Open Enhanced Curses material,  relating  to  interfaces\nincluded  to  provide  enhanced capabilities for applications originally written to be\ncompiled on systems based on the UNIX operating system.  Therefore, the  features  de‐\nscribed may not be present on systems that conform to XPG4 or to earlier XPG releases.\nThe relevant reference pages may provide additional or more specific portability warn‐\nings about use of the material.\n\nIn  the foregoing, emphasis was added to unspecified format and to XPG4 or to earlier XPG re‐‐\nleases, for clarity.\n"
                    },
                    {
                        "name": "Unix SystemV",
                        "content": "Unix SystemV curses identified the file format by writing a “magic number” at  the  beginning\nof the dump.  The WINDOW data and the lines of text follow, all in binary form.\n\nThe Solaris curses source has these definitions:\n\n/* terminfo magic number */\n#define MAGNUM  0432\n\n/* curses screen dump magic number */\n#define SVR2DUMPMAGICNUMBER  0433\n#define SVR3DUMPMAGICNUMBER  0434\n\nThat  is, the feature was likely introduced in SVr2 (1984), and improved in SVr3 (1987).  The\nSolaris curses source has no magic number for SVr4 (1989).  Other operating systems (AIX  and\nHPUX) use a magic number which would correspond to this definition:\n\n/* curses screen dump magic number */\n#define SVR4DUMPMAGICNUMBER  0435\n\nThat  octal  number in bytes is 001, 035.  Because most Unix vendors use big-endian hardware,\nthe magic number is written with the high-order byte first, e.g.,\n\n01 35\n\nAfter the magic number, the WINDOW structure and line-data  are  written  in  binary  format.\nWhile  the  magic  number  used by the Unix systems can be seen using od(1), none of the Unix\nsystems documents the format used for screen-dumps.\n\nThe Unix systems do not use identical formats.  While collecting  information  for  for  this\nmanual  page,  the  savescreen  test-program  produced dumps of different size (all on 64-bit\nhardware, on 40x80 screens):\n\n•   AIX (51817 bytes)\n\n•   HPUX (90093 bytes)\n\n•   Solaris 10 (13273 bytes)\n\n•   ncurses5 (12888 bytes)\n"
                    },
                    {
                        "name": "Solaris",
                        "content": "As noted above, Solaris curses has no magic number corresponding to SVr4 curses.  This is odd\nsince  Solaris  was  the first operating system to pass the SVr4 guidelines.  Solaris has two\nversions of curses:\n\n•   The default curses library uses the SVr3 magic number.\n\n•   There is an alternate curses library in /usr/xpg4.  This uses a textual  format  with  no\nmagic number.\n\nAccording  to  the copyright notice, the xpg4 Solaris curses library was developed by MKS\n(Mortice Kern Systems) from 1990 to 1995.\n\nLike ncurses6, there is a file-header with parameters.  Unlike ncurses6, the contents  of\nthe  window are written piecemeal, with coordinates and attributes for each chunk of text\nrather than writing the whole window from top to bottom.\n"
                    },
                    {
                        "name": "PDCurses",
                        "content": "PDCurses added support for screen dumps  in  version  2.7  (2005).   Like  Unix  SystemV  and\nncurses5,  it  writes the WINDOW structure in binary, but begins the file with its three-byte\nidentifier “PDC”, followed by a one-byte version, e.g.,\n\n“PDC\\001”\n"
                    },
                    {
                        "name": "NetBSD",
                        "content": "As of April 2017, NetBSD curses does not  support  scrdump  and  scrrestore  (or  scrinit,\nscrset), although it has putwin and getwin.\n\nLike  ncurses5,  NetBSD  putwin  does  not identify its dumps with a useful magic number.  It\nwrites\n\n•   the curses shared library major and minor versions as the first two bytes  (e.g.,  7  and\n1),\n\n•   followed by a binary dump of the WINDOW,\n\n•   some data for wide-characters referenced by the WINDOW structure, and\n\n•   finally, lines as done by other implementations.\n"
                    }
                ]
            },
            "EXAMPLE": {
                "content": "Given a simple program which writes text to the screen (and for the sake of example, limiting\nthe screen-size to 10x20):\n\n#include <curses.h>\n\nint\nmain(void)\n{\nputenv(\"LINES=10\");\nputenv(\"COLUMNS=20\");\ninitscr();\nstartcolor();\ninitpair(1, COLORWHITE, COLORBLUE);\ninitpair(2, COLORRED, COLORBLACK);\nbkgd(COLORPAIR(1));\nmove(4, 5);\nattron(ABOLD);\naddstr(\"Hello\");\nmove(5, 5);\nattroff(ABOLD);\nattrset(AREVERSE | COLORPAIR(2));\naddstr(\"World!\");\nrefresh();\nscrdump(\"foo.out\");\nendwin();\nreturn 0;\n}\n\nWhen run using ncurses6, the output looks like this:\n\n\\210\\210\\210\\210ncurses 6.0.20170415\ncury=5\ncurx=11\nmaxy=9\nmaxx=19\nflags=14\nattrs=\\{REVERSE|C2}\nflag=idcok\ndelay=-1\nregbottom=9\nbkgrnd=\\{NORMAL|C1}\\s\nrows:\n1:\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n2:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n3:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n4:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n5:\\s\\s\\s\\s\\s\\{BOLD}Hello\\{NORMAL}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n6:\\s\\s\\s\\s\\s\\{REVERSE|C2}World!\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s\n7:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n8:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n9:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n10:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\n\nThe first four octal escapes are actually nonprinting characters, while the remainder of  the\nfile is printable text.  You may notice:\n\n•   The actual color pair values are not written to the file.\n\n•   All  characters are shown in printable form; spaces are “\\s” to ensure they are not over‐\nlooked.\n\n•   Attributes are written in escaped curly braces, e.g., “\\{BOLD}”, and may include a color-\npair (C1 or C2 in this example).\n\n•   The  parameters  in  the  header  are written out only if they are nonzero.  When reading\nback, order does not matter.\n\nRunning the same program with Solaris xpg4 curses gives this dump:\n\nMAX=10,20\nBEG=0,0\nSCROLL=0,10\nVMIN=1\nVTIME=0\nFLAGS=0x1000\nFG=0,0\nBG=0,0,\n0,0,0,1,\n0,19,0,0,\n1,0,0,1,\n1,19,0,0,\n2,0,0,1,\n2,19,0,0,\n3,0,0,1,\n3,19,0,0,\n4,0,0,1,\n4,5,0x20,0,Hello\n4,10,0,1,\n4,19,0,0,\n5,0,0,1,\n5,5,0x4,2,World!\n5,11,0,1,\n5,19,0,0,\n6,0,0,1,\n6,19,0,0,\n7,0,0,1,\n7,19,0,0,\n8,0,0,1,\n8,19,0,0,\n9,0,0,1,\n9,19,0,0,\nCUR=11,5\n\nSolaris getwin requires that all parameters are present, and in the  same  order.   The  xpg4\ncurses  library does not know about the bce (back color erase) capability, and does not color\nthe window background.\n\nOn the other hand, the SVr4 curses library does know about the  background  color.   However,\nits screen dumps are in binary.  Here is the corresponding dump (using “od -t x1”):\n\n0000000 1c 01 c3 d6 f3 58 05 00 0b 00 0a 00 14 00 00 00\n0000020 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00\n0000040 00 00 b8 1a 06 08 cc 1a 06 08 00 00 09 00 10 00\n0000060 00 00 00 80 00 00 20 00 00 00 ff ff ff ff 00 00\n0000100 ff ff ff ff 00 00 00 00 20 80 00 00 20 80 00 00\n0000120 20 80 00 00 20 80 00 00 20 80 00 00 20 80 00 00\n*\n0000620 20 80 00 00 20 80 00 00 20 80 00 00 48 80 00 04\n0000640 65 80 00 04 6c 80 00 04 6c 80 00 04 6f 80 00 04\n0000660 20 80 00 00 20 80 00 00 20 80 00 00 20 80 00 00\n*\n0000740 20 80 00 00 20 80 00 00 20 80 00 00 57 00 81 00\n0000760 6f 00 81 00 72 00 81 00 6c 00 81 00 64 00 81 00\n0001000 21 00 81 00 20 80 00 00 20 80 00 00 20 80 00 00\n0001020 20 80 00 00 20 80 00 00 20 80 00 00 20 80 00 00\n*\n0001540 20 80 00 00 20 80 00 00 00 00 f6 d1 01 00 f6 d1\n0001560 08 00 00 00 40 00 00 00 00 00 00 00 00 00 00 07\n0001600 00 04 00 01 00 01 00 00 00 01 00 00 00 00 00 00\n0001620 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n*\n0002371\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "scrdump(3NCURSES), util(3NCURSES).\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Thomas E. Dickey\nextended screen-dump format for ncurses 6.0 (2015)\n\nEric S. Raymond\nscreen dump feature in ncurses 1.9.2d (1995)\n\n\n\nscrdump(5)",
                "subsections": []
            }
        }
    }
}