#termbox #terminal

rustbox

A rust implementation of the termbox library

41 releases

Uses old Rust 2015

0.11.0 Mar 30, 2018
0.9.0 Sep 8, 2016
0.8.1 Jan 22, 2016
0.7.2 Sep 28, 2015
0.2.2 Dec 27, 2014

#695 in GUI

Download history 325/week @ 2024-03-11 246/week @ 2024-03-18 208/week @ 2024-03-25 346/week @ 2024-04-01 158/week @ 2024-04-08 244/week @ 2024-04-15 249/week @ 2024-04-22 225/week @ 2024-04-29 215/week @ 2024-05-06 231/week @ 2024-05-13 236/week @ 2024-05-20 284/week @ 2024-05-27 209/week @ 2024-06-03 171/week @ 2024-06-10 224/week @ 2024-06-17 210/week @ 2024-06-24

871 downloads per month
Used in fewer than 14 crates

MIT license

24KB
510 lines

Rustbox

Rustbox is a Rust implementation of termbox.

Currently, this is just a wrapper of the C library by nsf, though my plan is to convert it to be a pure Rust implementation and remove the requirement on the C library.

The original implementation of this was inspired by Aaron Pribadi, so big props to him for the original work.

NOTE This is under development, and the APIs may change as I figure out more how Rust works and as the language itself changes

Documentation

Usage

In your Cargo.toml add the following:

[dependencies]
rustbox = "*"

You can also use the current git version by instead adding:

[dependencies.rustbox]
git = "https://github.com/gchp/rustbox.git"

Then, in your src/example.rs:

extern crate rustbox;

use std::error::Error;
use std::default::Default;

use rustbox::{Color, RustBox};
use rustbox::Key;

fn main() {
    let rustbox = match RustBox::init(Default::default()) {
        Result::Ok(v) => v,
        Result::Err(e) => panic!("{}", e),
    };

    rustbox.print(1, 1, rustbox::RB_BOLD, Color::White, Color::Black, "Hello, world!");
    rustbox.print(1, 3, rustbox::RB_BOLD, Color::White, Color::Black,
                  "Press 'q' to quit.");
    rustbox.present();
    loop {
        match rustbox.poll_event(false) {
            Ok(rustbox::Event::KeyEvent(key)) => {
                match key {
                    Key::Char('q') => { break; }
                    _ => { }
                }
            },
            Err(e) => panic!("{}", e.description()),
            _ => { }
        }
    }
}

NOTE: this example can also be run with cargo run --example hello-world.

Projects that use this crate:

Dependencies

~2–11MB
~113K SLoC