Skip to main content

Module pty

Module pty 

Source
Expand description

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

Promotes the technique examples/tests/support::capture_pty_until already used (test-only, synchronizing on a ready marker) into a public, reusable capture source that feeds the same write_cast path FrameRecorder does. This is the mechanism retroglyph#461’s “supersede the vhs tape plan” bet rests on: a real portable-pty pseudo-terminal plus a real vt100 VT-parser aims for the fidelity vhs gets from a real terminal emulator, without one in this crate’s own dependency tree.

PtySession is the spawn/write/read/lifecycle plumbing this shares with examples/tests/support’s marker/settle-driven test harness (retroglyph#1320): opening the PTY, spawning the child, and draining its output on a background thread are identical in both places, but what each side does with that output differs – capture_pty below polls on a fixed interval and diffs settled frames, while the test harness waits for a ready-marker substring, writes input, then waits for a caller’s settle callback before quitting, with much richer panic diagnostics. PtySession only owns the part that’s genuinely identical; neither loop shape is imposed on the other.

§Fidelity vs. the TestHarness-driven source

Frames here come from diffing successive [vt100::Screen] polls of a real child process’s PTY output, not from Output::draw_layers’s own diff stream – so timing reflects real scheduling (the child’s own draw cadence, kernel PTY buffering, this capture’s poll interval) rather than FrameRecorder’s frame-exact clock, and a poll interval coarser than the source’s redraw rate can miss or coalesce short-lived intermediate frames a TestHarness-driven capture would record individually. Both still converge on identical write_cast output for a settled scripted session (see this crate’s pty_matches_frame_recorder test): the difference is in what “a frame” means for a live, real-terminal source, not in the exported format.

Structs§

PtySession
A live, real-pseudo-terminal-backed child process.

Functions§

capture_pty
Runs bin (with args) under a real pseudo-terminal sized colsxrows, and captures its settled frames until it exits or timeout elapses.