Crates.io | terminal |
lib.rs | terminal |
version | 0.2.1 |
source | src |
created_at | 2015-04-06 17:37:17.497233 |
updated_at | 2020-01-31 18:54:19.795657 |
description | Unified API over different TUI libraries. |
homepage | |
repository | https://github.com/crossterm-rs/terminal |
max_upload_size | |
id | 1787 |
size | 147,196 |
This library offers a universal API over various terminal libraries such as termion, crossterm, ncurses, pancurses, and console.
Why would I need this library? Three main reasons:
This library is still quite young. If you experience problems, feel free to make an issue. I'd fix it as soon as possible.
Batching multiple terminal commands before executing (flush).
Complete control over the underlying buffer.
Locking the terminal for a certain duration.
Backend of your choice.
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. |
crosscurses-backend |
crosscurses backend will be used. |
like
[dependencies.terminal]
version = "0.2"
features = ["crossterm-backend"]
In the backend-specification document you will find each backend and it's benefits described.
[dependencies]
terminal = "0.2"
features = ["your_backend_choice"]
use terminal::{Action, Clear, error, Retrieved, Value};
use std::io::Write;
pub fn main() -> error::Result<()> {
let mut terminal = terminal::stdout();
// perform an single action.
terminal.act(Action::ClearTerminal(Clear::All))?;
// batch multiple actions.
for i in 0..20 {
terminal.batch(Action::MoveCursorTo(0, i))?;
terminal.write(format!("{}", i).as_bytes());
}
// execute batch.
terminal.flush_batch();
// get an terminal value.
if let Retrieved::TerminalSize(x, y) = terminal.get(Value::TerminalSize)? {
println!("\nx: {}, y: {}", x, y);
}
Ok(())
}
I would appreciate any kind of contribution. Before you do, please, read the Contributing guidelines.
This project, terminal
are licensed under the MIT
License - see the LICENSE file for details.