Skip to content

Support XTSAVE (CSI ? Pm s) and XTRESTORE (CSI ? Pm r) private mode save/restore #29

Done

Description

@tony

Summary

Terminal._handle_csi() in src/libvt/terminal.py (#2) handles DECSET (CSI ? Pm h), DECRST (CSI ? Pm l), and DECRQM (CSI ? Ps $ p), while xterm private mode save/restore (XTSAVE CSI ? Pm s and XTRESTORE CSI ? Pm r) is deferred to 0.2.0.

Motivation

Legacy and hybrid TUI programs save specific DEC private modes (?1, ?7, ?25, ?47/?1049, ?1000–?1006, ?2004) via CSI ? Pm s on startup and restore them via CSI ? Pm r on suspend (SIGTSTP) or exit instead of hard-coding DECRST values.

Proposal

Invariants

The invariants below are load-bearing; everything under Intent is open.

  • CSI ? Pm s (prefix == ord("?")) dispatches strictly to XTSAVE and never collides with unprefixed CSI s (SCOSC / DECSLRM), and CSI ? Pm r dispatches strictly to XTRESTORE and never collides with unprefixed CSI Pt ; Pb r (DECSTBM).
  • Saved mode state is bounded (one saved bool per recognized Mode, O(1) memory) and cleared on RIS (ESC c).
  • Restoring ?47 / ?1047 / ?1049 or ?2026 routes through _apply_mode() so alternate-screen epochs and synchronized-output invariants hold.

Intent (non-binding)

  • Target 0.2.0: add a saved-mode map on ModeState / Terminal supporting empty-param ("save/restore all recognized private modes") and multi-param CSI ? p1 ; p2 s / r, gated on Profile (tmux ignores XTSAVE/XTRESTORE in input.c).

Not doing

  • Unbounded push/pop stacks per mode (xterm XTSAVE overwrites a single save slot per DEC private mode).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions