thuja

Crates.iothuja
lib.rsthuja
version0.2.1
sourcesrc
created_at2021-11-17 00:53:07.924808
updated_at2022-07-21 12:47:32.983463
descriptionElm-inspired library for building text user interfaces
homepage
repositoryhttps://gitlab.com/bemyak/thuja
max_upload_size
id483059
size44,042
(bemyak)

documentation

README

Thuja

Elm-inspired library for building Text User Interfaces.

Thuja heavily relies on the tui crate and essentially is just an (opinionated) wrapper around it. Thuja uses crossterm as a terminal backend.

Thuja is an experimental library and its API is likely a subject to change

Quick start

The simplest app looks like this:

use thuja::{components::list::List, Component, Thuja};

fn main() {
    let list = List::new(vec!["one", "two", "three"]);
    Thuja::new(list).run();
}

This code will display a list of three elements, with the first one selected. You can switch between elements using arrow keys.
Pretty simple, right?

The goal of the project is to make components easily reusable and composable.

The next example will display the same list, but with a legend status bar and Ctrl+C handling:

use thuja::{components::{ctrlc::{CtrlCHandler,CtrlCMsg},legend::Legend,list::List},Thuja};

fn main() {
    let list = List::new(vec!["one", "two", "three"]);
    let ctrlc = CtrlCHandler::new(list, "Quit");
    let legend = Legend::new(ctrlc);
    Thuja::new(legend).with_exit_msg(Some(CtrlCMsg::Exit)).run();
}

See the docs for further information.

Why "thuja"?

As said, it is Elm-inspired and the name is consonant with "TUI" (text user interface). Got it?

Commit count: 10

cargo fmt