2 unstable releases

0.2.0 Jun 5, 2023
0.1.0 Mar 22, 2022

#514 in Command-line interface

Download history 4250/week @ 2024-07-20 3945/week @ 2024-07-27 3861/week @ 2024-08-03 2148/week @ 2024-08-10 2324/week @ 2024-08-17 2310/week @ 2024-08-24 2216/week @ 2024-08-31 2756/week @ 2024-09-07 2532/week @ 2024-09-14 2499/week @ 2024-09-21 2535/week @ 2024-09-28 2732/week @ 2024-10-05 2648/week @ 2024-10-12 2108/week @ 2024-10-19 4824/week @ 2024-10-26 2939/week @ 2024-11-02

12,877 downloads per month
Used in 8 crates (2 directly)

MIT/Apache

3MB
3.5K SLoC

A component-based framework for building Rust Text-based User Interfaces (TUIs)

There are several copies of this repo on GitHub, facebookincubator/superconsole is the canonical one.

The superconsole framework provides a powerful line based abstraction over text based rendering to the terminal. It also provides basic building blocks like line manipulation, and a higher level of composable components. A base set of "batteries" components are included to help developers create Text-based User Interfaces (TUIs) as quickly as possible.

The design choices that underly superconsole are selected to prioritize testability, ease of composition, and flexibility.

Superconsole also offers stylization, including italics, underlining, bolding, and coloring text. Furthermore, relying on crossterm ensures that it is compatible with Windows, Unix, and MacOS.

Finally, superconsole delineates between rendering logic and program state - each render call accepts an immutable reference to state, which components may use to inject state into their otherwise immutable rendering logic.

Demo

Superconsole running some buck2 tests

Examples

use std::convert::TryInto;
use superconsole::components::bordering::{Bordered, BorderedSpec};
use superconsole::{Component, Dimensions, DrawMode, Lines, SuperConsole};

#[derive(Debug)]
struct HelloWorld;

impl Component for HelloWorld {
    fn draw_unchecked(&self, _dimensions: Dimensions, _mode: DrawMode) -> anyhow::Result<Lines> {
        Ok(Lines(vec![
            vec!["Hello world!".to_owned()].try_into().unwrap(),
        ]))
    }
}

pub fn main() -> anyhow::Result<()> {
    let bordering = BorderedSpec::default();
    let mut superconsole = SuperConsole::new().ok_or_else(|| anyhow::anyhow!("Not a TTY"))?;
    let component = Bordered::new(HelloWorld, bordering);
    superconsole.render(&component)?;
    superconsole.finalize(&component)?;
    Ok(())
}

See the CONTRIBUTING file for how to help out.

License

Superconsole is both MIT and Apache License, Version 2.0 licensed, as found in the LICENSE-MIT and LICENSE-APACHE files.

Dependencies

~18–30MB
~479K SLoC