Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ unknown tmux release or one before 3.5,
is false and `unexposed_fields` lists `grapheme_widths`. Pass
`tmux_version=` when decoding raw output to identify the server.

#### Restore viewport state when replaying VT snapshots (#180)

{meth}`~libvt.terminal.Snapshot.format` with
{attr}`~libvt.terminal.OutputFormat.VT` restores scroll margins, cell
protection, and the active SGR, OSC 8, and DECSCA pen. The formatter paints
stored glyphs in their recorded widths and preserves pending wrap where it
can reprint the captured margin glyph in place.

### Documentation

#### Assert effective colors alongside screen goldens (#190)
Expand Down
8 changes: 8 additions & 0 deletions MIGRATION
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ presentation selector from an unknown or pre-3.5 release now leaves
`exact_cells` false. Read an attached client's screen when the column of
the next character matters.

### VT snapshot output retains the terminal pen

{meth}`~libvt.terminal.Snapshot.format` with
{attr}`~libvt.terminal.OutputFormat.VT` ends with the captured pen and
cursor state. When appending unrelated text, set its cursor position
and rendition before writing. Close a captured OSC 8 hyperlink with
`OSC 8 ; ; ST` and reset SGR and DECSCA with `CSI 0 m` and `CSI 0 " q`.

## libvt 0.0.1a2 (2026-11-28)

### Curated PEP 562 `libvt` root exports (#43)
Expand Down
26 changes: 26 additions & 0 deletions docs/topics/snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,31 @@ True
('build', ['$ make', 'ok'], 1)
```

### Continue after replaying VT output

Replay `OutputFormat.VT` into a fresh {class}`~libvt.terminal.Terminal`
with the snapshot's dimensions and the source terminal's profile. The replay
restores the active viewport, its cursor, scroll margins, cell protection,
and the active SGR, OSC 8, and DECSCA pen. A pending wrap resumes when the
export can reprint the margin glyph. An erased margin cell stays erased.
The formatter can switch grapheme modes while painting stored glyphs and
restores the active mode for subsequent input.

```python
>>> from libvt import Terminal
>>> from libvt.terminal import OutputFormat
>>> live = Terminal(rows=2, cols=3)
>>> live.feed(b"\x1b[31mABC")
>>> replay = Terminal(rows=2, cols=3)
>>> replay.feed_str(live.committed.format(OutputFormat.VT))
>>> replay.feed(b"D")
>>> replay.committed.lines, replay[1, 0].style.fg == live[0, 2].style.fg
(('ABC', 'D'), True)
```

Retain the original input for replays that depend on unfinished control
sequences, saved cursor slots, tab stops, scrollback, inactive buffers, or
glyphs assembled using different modes within a single cell.

For asserting, scrubbing, and diffing `Terminal` and `Snapshot` grids in test
suites, see {doc}`testing`.
1 change: 1 addition & 0 deletions src/libvt/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,7 @@ def snapshot(
),
cols=self._cols,
cursor=eff_cursor,
scroll_region=self.scroll_region,
title=title,
cwd=cwd,
cwd_uri=cwd_uri,
Expand Down
Loading
Loading