Skip to content

Repository files navigation


uncurses

CI License: MIT Rust 1.88+ Website

uncurses is 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. It asks the terminal what it supports instead of looking it up in a terminfo database, so the same code runs on Linux, macOS, and Windows.

Full guides, concepts, and API reference: uncurses.org

Quickstart

Screen is the core: it owns raw mode, a diffed back buffer, and input. Draw into it, call render() to ship only the changed cells, and finish() to restore the terminal.

use uncurses::event::Event;
use uncurses::screen::Screen;
use uncurses::style::Style;
use uncurses::text::TextSurface;

fn main() -> std::io::Result<()> {
    let mut screen = Screen::stdio()?;
    screen.init()?;
    screen.enter_alt_screen()?; // take over the full screen
    screen.set_str((0, 0), "hello, uncurses!", Style::new());
    screen.render()?;
    while !matches!(screen.read_event()?, Event::KeyPress(_)) {} // wait for a key
    screen.finish() // restores the main screen
}

Per-crate guides and more examples:

Examples

A curated few, each cargo run -p examples --example <name>:

tour

An animated showcase that cycles through sprinkles, nested colored panels, a styled banner, a marquee, and bouncing balls. The quickest way to see what the renderer can do.

tour

gradient

A smooth truecolor field that packs two colors per cell with half-block sub-pixels, plus a mouse-driven inspector that reports the color under the pointer. Shows color handling and mouse input together.

gradient

file_explorer

A real two-pane file browser with a live preview that scrolls by column, so a side pane moves without disturbing the file list. A full end-to-end app.

file_explorer

task_picker

An inline picker (no alternate screen) that hands off to an animated progress bar, then exits cleanly. Shows how uncurses draws in the normal buffer.

task_picker

For more, browse the examples/ directory.

Crates

Install

Not on crates.io yet, so depend on it straight from git:

[dependencies]
uncurses = { 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).

Credits

uncurses stands on the shoulders of projects worth naming:

  • ncurses: the original. The name nods to it, even as uncurses leaves terminfo behind.
  • ultraviolet: Charm's low-level terminal library, and the inspiration for how uncurses models cells and screens.
  • colorprofile: Charm's color degradation library, the model behind uncurses color profiles.
  • ratatui: the Rust TUI framework uncurses ships a backend for.

License

MIT. See LICENSE.

About

A terminal toolkit library for building UIs

Topics

Resources

Stars

28 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages