Donate Travis Latest Version MIT docs Lines of Code Join us on Discord

Unified API for different TUI libraries.

This library offers a universal API over various terminal libraries such as termion, crossterm, ncurses, pancurses and console.

Why would I need this librarie? Three main reasons:

1) These libraries differ in the API.

A smart choice would be to create an adapter layer to one of these libraries so that you wont have an direct dependency 
and you won't need to update your code base when you want to switch or upgrade. Creating those adapters is boring (mapping types).
Fortunately, this library does that for you. Some examples of those mappings can be found in those libraries: ([cursive][cursive], [tui][tui], [termimad][termimad], ...).

2) These libraries can be complex for beginners.

This library offers a very thin and simple abstraction to make it somewhat easier for the user.
This is achieved by hiding the implementation details. 
Implementation details cover raw mode, write to buffer, batch operations.

3) Libraries differ in how they work.

Like cursor 0 or 1 based, cleaning resources, event handling, performing actions.

Table of Contents

Features

Implemented Backends

Use one of the below feature flags to choose an backend.

| Feature | Description | | :------ | :------ | | crossterm-backend | crossterm backend will be used.| | termion-backend | termion backend will be used.|

like toml [dependencies.terminal] version = "0.1" features = ["crossterm-backend"]

Yet to Implement

Getting Started

Click to show Cargo.toml.

toml [dependencies] terminal = "0.1" features = ["your_backend_choice"]

```rust use terminal::{ClearType, Action, Value, Retreived, error};

pub fn main() -> error::Result<()> { let terminal = terminal::stdout();

// perform an single action.
terminal.act(Action::ClearTerminal(ClearType::All))?;

// batch multiple actions.
for i in 0..100 {
    terminal.batch(Action::MoveCursorTo(0, i))?;
}

// execute batch.
terminal.flush_batch();

// get an terminal value.
if let Retreived::TerminalSize(x, y) = terminal.get(Value::TerminalSize)? {
    println!("x: {}, y: {}", x, y);
}

Ok(())

} ```

Other Resources

Contributing

I would appreciate any kind of contribution. Before you do, please, read the Contributing guidelines.

Authors

License

This project, terminal are licensed under the MIT License - see the LICENSE file for details.