uncurses-ratatui 0.0.6

Integration adapter for the uncurses terminal rendering library
Documentation

uncurses-ratatui

CI License: MIT Rust 1.88+ Website

A ratatui Backend that renders through uncurses. Write your UI with ratatui widgets and let uncurses diff frames and ship the minimal bytes. A single UncursesBackend wraps a Program, which owns input, terminal modes, and the renderer reached through program().screen().

Usage

try_init() gives you a ratatui terminal wired to uncurses; restore() puts the terminal back. In between, draw() renders widgets and backend_mut().read_event() pulls input.

use ratatui::widgets::Paragraph;
use uncurses::event::{Event, Key};

fn main() -> std::io::Result<()> {
    let mut terminal = uncurses_ratatui::try_init()?;

    let q: Key = "q".parse().unwrap();
    loop {
        terminal.draw(|frame| {
            frame.render_widget(
                Paragraph::new("from ratatui, via uncurses, press q to quit"),
                frame.area(),
            );
        })?;

        let ev = terminal.backend_mut().read_event()?;
        if matches!(ev, Event::KeyPress(k) if k == q) {
            break;
        }
    }

    uncurses_ratatui::restore(&mut terminal);
    Ok(())
}

The backend exposes the wrapped program as program() and program_mut(). Synchronous reads go through Program, so capability replies are observed for you. try_read_event() returns io::Result<Option<Event>>; use observe_event only for async streams or events read outside the program. Setup does not probe the terminal; call backend.program_mut().query_capabilities(&[])? when you want discovery.

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:

[dependencies]
uncurses-ratatui = { git = "https://github.com/aymanbagabas/uncurses" }
ratatui = "0.30"

Features mirror the core crate: unicode-rs (default), icu, and runtime-agnostic async for event_stream() with no tokio dependency.

Credits

Built on ratatui and uncurses, which in turn tips its hat to ncurses, ultraviolet, and colorprofile.

License

MIT. See LICENSE.