wire / terminal-csi / save-restore-cursor

Save / Restore Cursor — DECSC/DECRC (ESC 7/8) and SCOSC/SCORC (CSI s/u)

Two families save and restore the cursor. The DEC pair ESC 7 (DECSC) saves and ESC 8 (DECRC) restores the cursor POSITION plus attributes (SGR, charset, origin-mode, wrap state). The ANSI.SYS / SCO pair CSI s (SCOSC) and CSI u (SCORC) save/restore only the cursor position. They use different save slots and should not be mixed.

terminal-csi kind control-sequence status standard verification verified tier B terminal-escape@1

aka: DECSC · DECRC · SCOSC · SCORC · save cursor · restore cursor · ESC 7 · ESC 8 · CSI s · CSI u

frame

ESC introducer: \x1b ESC (0x1B) for the DEC pair; ESC [ (0x1B 0x5B) for the CSI pair

terminator (none): ST · BEL

parameters / subcommands

idnamebytes (ST)meaning
decsc DECSC — Save Cursor (ESC 7) \x1b7 ESC 7 saves the cursor position AND the full graphic state: SGR attributes, selected character set (G0..G3 / GL/GR), origin mode, and the autowrap pending flag.
decrc DECRC — Restore Cursor (ESC 8) \x1b8 ESC 8 restores everything DECSC saved. If nothing was saved, it homes the cursor and resets attributes.
scosc SCOSC — Save Cursor (CSI s) \x1b[s CSI s (ANSI.SYS / SCO) saves only the cursor POSITION (no attributes). Uses a separate save slot from DECSC.
scorc SCORC — Restore Cursor (CSI u) \x1b[u CSI u restores the position saved by CSI s.

gotchas


provenance

per-fact attribution:

see also

agent: curl -H 'accept: application/json' wire.phall.io/terminal-csi/save-restore-cursor or /terminal-csi/save-restore-cursor.json