#prettytty

Robert Grimmapparebit
2025-01-31

As with other crates, you write zero-sized structs to execute commands. But it goes further: To perform a query, the same struct also knows how to parse a response from an ANSI escape sequence. And the runtime knows how to recognize those. 💥 80+ builtin commands! 🎉 (3/3)

// Open connection to terminal device
let options = Options::default();
let tty = Connection::with_options(options)?;
let (mut input, mut output) = tty.io();
// Execute commands, i.e., write display & flush
output.exec(MoveToColumn::<17>)?;
output.exec(RequestCursorPosition)?;
// Scan response as control, payload token
let payload = input.read_sequence(
    RequestCursorPosition.control())?;
// Parse payload into position
let position = RequestCursorPosition.parse(payload)?;
assert_eq!(position.1, 17);
Robert Grimmapparebit
2025-01-31

Prettypretty's version optionally uses the new crate for interacting with the . Prettytty distinguishes itself from other terminal crates by being cross-platform while also lightweight, with no dependency other than libc/windows-sys. (2/3)
crates.io/crates/prettytty

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst