rustbox

Rust implementation of the termbox library

  • Owner: gchp/rustbox
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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:

Main metrics

Overview
Name With Ownergchp/rustbox
Primary LanguageRust
Program languageRust (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2014-07-17 12:55:21
Pushed At2020-10-10 15:35:36
Last Commit At2018-03-30 14:28:32
Release Count36
Last Release Name0.11.0 (Posted on 2018-03-30 14:28:40)
First Release Name0.2.5 (Posted on )
用户参与
Stargazers Count468
Watchers Count20
Fork Count47
Commits Count204
Has Issues Enabled
Issues Count39
Issue Open Count17
Pull Requests Count37
Pull Requests Open Count6
Pull Requests Close Count9
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private