uncurses
A Rust library for building terminal user interfaces. It provides a direct, framework-free way to draw to the terminal and read input, giving you control over every cell and your own event loop, whether you run inline, take over the full screen, mix the two, or leave the console unmanaged and just shape your output. It includes a diffing renderer that redraws only what changed, Unicode-aware width, truecolor styling with automatic downsampling, hyperlinks, and typed keyboard, mouse, and paste input. Rather than a terminfo database, it can ask the terminal what it supports and runs across Linux, macOS, and Windows.
Usage
Program owns the session: raw mode, terminal modes, input, and teardown.
Screen is the renderer it draws with: a cell grid that ships only the cells
that changed. Reach for the screen through screen_mut().
use Event;
use Program;
use Style;
use TextSurface;
Program owns the terminal and the input source; the Screen inside it owns
the drawing. Add an event loop to react to input. A session starts inline
(drawing in the normal buffer) with the cursor visible; the alternate screen, a
hidden cursor, and capability queries are opt-in.
use Bounded;
use ;
use Program;
use Style;
use TextSurface;
init() sets up the session and sends no capability query, so discovery is
yours to start: call program.query_capabilities(&[])? and keep reading events
until the Primary DA reply arrives; ordinary read_event and try_read_event
calls observe those replies automatically. observe_event is only needed when
events come from outside the program, such as event_stream().
Only need output? A Screen stands alone over any Write, independent of any
terminal session:
use Screen;
use Style;
use TextSurface;
let mut screen = new;
screen.set_str;
screen.render.unwrap;
assert!;
That's the shape of it; the full API and guides live at uncurses.org.
Install
Not on crates.io yet, so depend on it straight from git:
[]
= { = "https://github.com/aymanbagabas/uncurses" }
Runs on Linux, macOS, Windows, and the BSDs. Uses the 2024 edition and tracks the latest stable Rust (currently 1.88 or newer).
Features: unicode-rs (default) for width and segmentation, icu for
ICU4X-backed correctness, and async for runtime-agnostic event_stream(),
an owned futures_core::Stream over the program's input decoder with no
executor dependency.
Credits
- ncurses: the original the name nods to, minus the terminfo baggage.
- ultraviolet: Charm's terminal library, the inspiration for the cell and screen model.
- colorprofile: Charm's color degradation library, the model behind uncurses color profiles.
- ratatui: the Rust TUI framework, wired up through
uncurses-ratatui.
License
MIT. See LICENSE.