Skip to main content

Crate retroglyph_recorder

Crate retroglyph_recorder 

Source
Expand description

Input recording & replay for retroglyph.

Two things live here, both built on retroglyph-core’s testing feature (retroglyph_core::testing::InputRecording/TestHarness):

  • InputRecorder: wraps any Backend and taps its input stream, so a real session (a bug report, a demo run) can be captured to a .rgrec file via InputRecorder::save.
  • replay_live: drives a saved recording forward into a live Terminal/App, once, at recorded pace – “watch it happen” on screen. For driving a recording back through a headless App in a test instead (no real backend, no wall-clock sleeping), use TestHarness::replay directly.

install_panic_recorder wires a RecorderHandle into std::panic’s hook, so an in-progress recording is saved automatically if the process panics instead of being lost.

A different pair records “what was shown” instead of “what happened”:

  • FrameRecorder: wraps any Output backend and taps its DrawCell diff stream, buffering owned CapturedFrames.
  • write_cast: exports those frames as asciicast v3 newline-delimited JSON, so the existing external ecosystem (agg, asciinema-player, svg-term) renders it – retroglyph never builds a GIF encoder or an interactive player of its own.

With the pty feature, pty::capture_pty is a second capture source for the same write_cast path: it drives a real backend under a real pseudo-terminal (rather than a TestHarness-style synthetic Headless), aiming for the fidelity a real-terminal tool like vhs gets from a real terminal emulator, without one in this crate’s own dependency tree.

Not here: a first-class cross-backend replay helper for frame recordings (standard asciicast output already covers the common case), or embedding asciinema-player in the docs site (straightforward once there’s a concrete need) – both deliberately deferred, see retroglyph#1268.

§Features

This crate has no default features; every feature below is optional and off unless enabled.

§pty

⚪ Optional.

A real-pseudo-terminal capture source (pty::capture_pty) feeding the same write_cast path FrameRecorder does, for vhs-like real-terminal fidelity. Adds portable-pty/vt100.

Modules§

pty
capture_pty: a real-pseudo-terminal capture source, behind the pty feature.

Structs§

CapturedFrame
One changed frame: every cell Output::draw_layers reported changed on that call, with the wall-clock time since FrameRecorder::new.
FrameRecorder
Wraps a backend and records every frame it draws.
FrameRecorderHandle
A cheap, cloneable handle onto a FrameRecorder’s captured frames.
InputRecorder
Wraps a backend and records every event it sees.
OwnedCell
An owned copy of a single DrawCell, the shape FrameRecorder buffers instead of the borrowed original.
RecorderHandle
A cheap, cloneable handle onto an InputRecorder’s captured state.

Functions§

install_panic_recorder
Installs a panic hook that saves whatever handle’s recorder has captured so far to path when the process panics, then chains to whatever hook was already installed.
read
Reads a .rgrec file written by write() back into an InputRecording.
replay_live
Drives recording into app through a live term, once, at recorded pace.
write
Writes recording to path as .rgrec, overwriting any existing file.
write_cast
Exports frames as asciicast v3 newline-delimited JSON, written to writer.