{
    "mode": "man",
    "parameter": "scr_dump",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/scr_dump/5/json",
    "generated": "2026-10-09T10:19:36Z",
    "sections": {
        "NAME": {
            "content": "scrdump - curses screen dump\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 System V, but does not write a “magic number” to identify the file\nformat.\n"
                }
            ]
        },
        "PORTABILITY": {
            "content": "There is no standard format for curses screen dumps.  A brief survey of the  existing  imple‐\nmentations follows.\n",
            "subsections": [
                {
                    "name": "X/Open Curses",
                    "content": "X/Open Curses, Issue 7 specifies little.  It says (boldface emphasis added)\n\n“[t]he  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 System V  sys‐\ntems  using  older, less capable curses libraries.  BSD curses was not relevant to X/Open be‐\ncause it did not meet the criteria for base-level conformance; see ncurses(3NCURSES).\n"
                },
                {
                    "name": "System V",
                    "content": "System V curses identified the file format by writing a “magic number” at  the  beginning  of\nthe dump.  The WINDOW data and the lines of text follow, all in binary form.\n\nSolaris curses has the following 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).  So‐\nlaris curses has no magic number for SVr4 (1989).  Other System V operating systems (AIX  and\nHP-UX) use a magic number that would correspond to the following.\n\n/* curses screen dump magic number */\n#define SVR4DUMPMAGICNUMBER  0435\n\nThat  octal  number in bytes is 001, 035.  Because most Unix vendors at the time used big-en‐\ndian hardware, the magic number is written with the high-order byte first.\n\n\\001\\035\n\nAfter the magic number, the WINDOW structure and line data  are  written  in  binary  format.\nWhile  the  magic number used by these systems can be observed with od(1), none of them docu‐\nments the format used for screen dumps.\n\nNor do they use an identical format, even with the System V family.  The  ncurses  savescreen\ntest program was used to collect information for this manual page.  It produced dumps of dif‐\nferent size (all on 64-bit hardware, on 40x80 screens):\n\n•   AIX (51817 bytes)\n\n•   HP-UX (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\nodd, since Solaris was the first operating system to meet the SVr4 guidelines.  Solaris  fur‐\nthermore supplies two versions of curses.\n\n•   The default curses library uses the SVr3 magic number.\n\n•   An  alternate curses library (which we term xcurses), available in /usr/xpg4, uses a tex‐\ntual format with no magic number.\n\nAccording to its copyright notice, this xcurses library was  developed  by  MKS  (Mortice\nKern Systems) from 1990 to 1995.\n\nLike  ncurses6,  it  includes a 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 System V and ncurses5,\nit writes the WINDOW structure in binary, but begins the file with its three-byte  identifier\n“PDC”, followed by a single-byte version number.\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 (for example, 7\nand 1),\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"
                }
            ]
        },
        "EXAMPLES": {
            "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": []
        },
        "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",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "scrdump(3NCURSES), util(3NCURSES)\n\nncurses 6.4                                  2023-12-30                                  scrdump(5)",
            "subsections": []
        }
    },
    "summary": "scrdump - curses screen dump",
    "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"
        }
    ]
}