Skip to content

Add curses.scr_dump(), scr_restore(), scr_init() and scr_set() #152260

Description

@serhiy-storchaka

The curses module can serialize a single window with window.putwin() / curses.getwin(), but it has no way to dump and restore the whole screen. The four X/Open functions that do this are still missing:

  • scr_dump(filename) — write the current virtual screen to a file.
  • scr_restore(filename) — set the virtual screen to a dumped file; the next doupdate()/refresh() paints it.
  • scr_init(filename) — use a dump as the assumed current terminal contents (e.g. after another program drew the screen).
  • scr_set(filename) — combine scr_restore() and scr_init().

These are the whole-screen counterpart of putwin()/getwin(). Unlike those (which take a Python file object, mirroring C putwin(WINDOW *, FILE *)), the C scr_* functions are filename-based (they fopen internally), so the Python wrappers take a filename — a str or a path-like object.

Proposed API:

curses.scr_dump(filename)
curses.scr_restore(filename)
curses.scr_init(filename)
curses.scr_set(filename)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions