Pretty 🌸 Tty
[ Docs.rs | GitHub Pages | Rust Crate | Repository ]
Prettytty is a lightweight and flexible terminal library for Rust that has
only one low-level dependency, i.e., libc on
Unix and windows-sys on Windows. Its
API is clean and simple: Open a Connection to the terminal and share it
across threads as needed. Write Commands to Output. Read Query
responses from Input. Scan::read_token takes care of low-level UTF-8 and
ANSI escape sequence decoding and Query::parse turns token payloads into
objects. A cmd library with 80+ built-in commands covers basic needs and
then some. Commands generally are zero-sized. That is, unless they require
string arguments or are designed for dynamic state (and hence prefixed with
Dyn for dynamic).
Example
Here's how the above mentioned abstractions are used in practice:
use ;
use ;
use Options;
// Open a terminal connection with 1s timeout.
let tty = with_options?;
let pos = ;
assert_eq!;
Release History
v0.2 (2025-01-31)
Add zero-sized generic versions for commands that set colors or move cursor.
Keep previous, argument-based versions with Dyn prefix. Rename other commands
with runtime arguments to also use Dyn prefix.
Rename sgr! macro for combining several Sgr commands into one command to
fuse_sgr! and introduce the more general fuse! macro for combining
arbitrary commands into one command.
Add Rust version of progress bar to illustrate API differences from Python version.
v0.1 (2024-12-23)
Initial release.
Copyright 2024-2025 Robert Grimm. The code in this repository has been released as open source under the Apache 2.0 license.