Expand description
Record scripted terminal sessions: tapes (#599).
A tape scripts a session: type, press keys, wait for text on the screen,
take screenshots. record::record runs it in bash on a real PTY with a
pinned environment, follows the screen with a VT emulator, and returns the
screenshots and a timeline. record::write turns them into files:
- per screenshot, a PNG in a window frame, an SVG with selectable text
(drawn by rich-ext’s frame exporter,
rich_ext::frame::Frame::to_svg), and a text grid (throughrich_ext::frame::Frame); - an asciinema v2 cast with input events and the theme in its header;
- a GIF with a key overlay, and an MP4 when FFmpeg is installed;
- a self-contained HTML page with a small player and the screenshots.
The window frame, a caption and the key overlay can each be switched on
or off (record::Presentation), and a tape’s Output chooses what is
written.
record::check compares a new run’s text grids with committed ones, so
documentation media cannot drift from the program it shows.
use rich_record::{record, tape};
let source = std::fs::read_to_string("demo.tape")?;
let tape = tape::parse(&source)?;
let recording = record::record(&tape, "demo", &record::Options::default())?;
let fonts = rich_record::render::raster::Fonts::embedded();
record::write(&recording, "media/demo".as_ref(), "demo", record::Formats::ALL,
&fonts, &Default::default(), None)?;Linux and macOS are supported. Windows builds through ConPTY but needs
bash on PATH and is experimental.
Re-exports§
pub use record::Formats;pub use record::Options;pub use record::Presentation;pub use record::Problem;pub use record::Recording;pub use screen::Snapshot;pub use screen::Theme;pub use tape::Format;pub use tape::Output;pub use tape::Tape;pub use tape::TapeError;
Modules§
- record
- Running a tape, and writing or checking what it produced.
- render
- Turning snapshots and timelines into files.
- screen
- What the terminal shows at one moment, resolved to colours.
- session
- A shell on a PTY, followed by a VT emulator, with a recording.
- tape
- The tape format: one step per line.
- terminal
- The VT emulator, with every grapheme cluster as wide as rich measures it.