Advertisement · 728 × 90
#
Hashtag

#prettytty

Advertisement · 728 × 90
// Open connection to terminal device
let options = Options::default();
let tty = Connection::with_options(options)?;
let (mut input, mut output) = tty.io();
// Execute commands, ie, 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);

// Open connection to terminal device let options = Options::default(); let tty = Connection::with_options(options)?; let (mut input, mut output) = tty.io(); // Execute commands, ie, 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);

As with other #Rust #terminal crates, you write zero-sized structs to execute #prettytty 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)

0 0 0 0
The "pretty 🌸 tty" logo with a cherry blossom emoji between the two words.

The "pretty 🌸 tty" logo with a cherry blossom emoji between the two words.

Prettypretty's #Rust version optionally uses the new #prettytty crate for interacting with the #terminal. 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/prett...

0 0 1 0