uncurses-ratatui 0.0.9

Integration adapter for the uncurses terminal rendering library
Documentation
# uncurses-ratatui

[![CI](https://github.com/aymanbagabas/uncurses/actions/workflows/ci.yml/badge.svg)](https://github.com/aymanbagabas/uncurses/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](../LICENSE)
[![Rust 1.88+](https://img.shields.io/badge/rust-1.88%2B-orange.svg)](https://www.rust-lang.org)
[![Website](https://img.shields.io/badge/website-uncurses.org-blue.svg)](https://uncurses.org)

A [ratatui](https://ratatui.rs) `Backend` that renders through
[uncurses](../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()`.

<p align="center">
  <img src="https://media.githubusercontent.com/media/aymanbagabas/uncurses/main/assets/ratatui_popup.gif" width="440" alt="Ratatui popup rendered through uncurses">
</p>

## Usage

Construct the backend and ratatui terminal before session setup. This keeps
restoration available if setup fails. `draw()` renders widgets, and
`backend_mut().read_event()` reads input.

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

fn main() -> std::io::Result<()> {
    let backend = uncurses_ratatui::UncursesBackend::stdio()?;
    let mut terminal = ratatui::Terminal::new(backend)?;

    let result = (|| {
        let program = terminal.backend_mut().program_mut();
        program.init()?;
        program.enter_alt_screen()?;
        program.hide_cursor()?;

        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;
            }
        }
        Ok(())
    })();
    let restore = uncurses_ratatui::try_restore(&mut terminal);
    result.and(restore)
}
```

Restoration runs after setup, drawing, or input errors. `try_restore()` reports
restoration errors when the session succeeds.

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](https://uncurses.org).

## Install

Install v0.0.9 from
[crates.io](https://crates.io/crates/uncurses-ratatui):

```toml
[dependencies]
uncurses = "0.0.9"
uncurses-ratatui = "0.0.9"
ratatui = "0.30"
```

Use the [v0.0.9 API reference](https://docs.rs/uncurses-ratatui/0.0.9).
Checkout examples follow their source revision. Use matching git dependencies
for unreleased APIs.

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

## Credits

Built on [ratatui](https://ratatui.rs) and [uncurses](../uncurses/), which in
turn tips its hat to [ncurses](https://invisible-island.net/ncurses/),
[ultraviolet](https://github.com/charmbracelet/ultraviolet), and
[colorprofile](https://github.com/charmbracelet/colorprofile).

## License

MIT. See [LICENSE](../LICENSE).