Skip to main content

vterm/
lib.rs

1//! vterm: a minimal terminal-emulator core, on the Rust standard library
2//! plus the nativelite `ansi` crate alone. Zero third-party dependencies.
3//!
4//! One concern: turn a child process's VT output byte stream into a live
5//! [`ansi::Screen`] you can composite and diff. [`Term::feed`] drives an
6//! internal [`ansi::Parser`] and applies the resulting tokens (cursor
7//! motion, erase, scroll region, SGR style, autowrap, alt-screen) to a cell
8//! grid. [`Term::screen`] hands back the active buffer with its cursor set,
9//! ready for `Screen::diff` compositing.
10//!
11//! ```
12//! let mut t = vterm::Term::new(24, 80);
13//! t.feed(b"\x1b[2J\x1b[3;5HX");   // clear, cursor to row 3 col 5, print 'X'
14//! let s = t.screen();
15//! assert_eq!(s.cell(2, 4).ch, 'X');
16//! assert_eq!(s.cursor, (2, 5)); // cursor advanced past the 'X'
17//! ```
18//!
19//! This is a *correct common core*, not a pixel-perfect xterm. Wide/CJK
20//! characters, sixel/images, mouse reporting, and exotic private modes are
21//! deliberately out of scope (see the README's fidelity boundaries); the host
22//! app's answer for those is raw passthrough (atrium's "zoom").
23//!
24//! There is no I/O here: no PTY, no raw mode. `vterm` turns bytes into a
25//! screen; feeding it child output and painting its screen are the caller's
26//! job (see `pty` and `atrium`).
27
28mod term;
29
30pub use term::Term;