Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gchp/rustbox
Rust implementation of the termbox library
https://github.com/gchp/rustbox
Last synced: 1 day ago
JSON representation
Rust implementation of the termbox library
- Host: GitHub
- URL: https://github.com/gchp/rustbox
- Owner: gchp
- License: mit
- Created: 2014-07-17T12:55:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-10T15:35:36.000Z (over 4 years ago)
- Last Synced: 2025-01-04T21:06:19.232Z (8 days ago)
- Language: Rust
- Size: 176 KB
- Stars: 468
- Watchers: 21
- Forks: 48
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-cn - gchp/rustbox - ci.org/gchp/rustbox.svg?branch=master">](https://travis-ci.org/gchp/rustbox) (Libraries / Command-line)
- awesome-rust - gchp/rustbox - ci.org/gchp/rustbox.svg?branch=master">](https://travis-ci.org/gchp/rustbox) (Libraries / Command-line)
- awesome-rust - gchp/rustbox
- awesome-rust - gchp/rustbox
- awesome-rust-cn - gchp/rustbox
- awesome-rust-zh - gchp/rustbox - [Termbox](https://github.com/nsf/termbox) 绑定 [<img src="https://api.travis-ci.org/gchp/rustbox.svg?branch=master">](https://travis-ci.org/gchp/rustbox) (库 / 命令行)
- awesome-rust - gchp/rustbox - bindings to [Termbox](https://github.com/nsf/termbox) (Libraries / Command-line)
- awesome-rust - gchp/rustbox - ci.org/gchp/rustbox.svg?branch=master">](https://travis-ci.org/gchp/rustbox) (库 Libraries / 命令行 Command-line)
- fucking-awesome-rust - gchp/rustbox - bindings to <b><code> 1972⭐</code></b> <b><code> 187🍴</code></b> [Termbox](https://github.com/nsf/termbox)) (Libraries / Command-line)
- fucking-awesome-rust - gchp/rustbox - bindings to <b><code> 1963⭐</code></b> <b><code> 186🍴</code></b> [Termbox](https://github.com/nsf/termbox)) (Libraries / Command-line)
README
# Rustbox
Rustbox is a Rust implementation of [termbox](http://github.com/nsf/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](http://github.com/apribadi/rust-termbox), 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**](https://docs.rs/rustbox/)
## Usage
In your `Cargo.toml` add the following:
```toml
[dependencies]
rustbox = "*"
```You can also use the current git version by instead adding:
```toml
[dependencies.rustbox]
git = "https://github.com/gchp/rustbox.git"
```Then, in your `src/example.rs`:
```rust
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:
* [hostblock](https://github.com/cgag/hostblock)
* [rust-2048](https://github.com/kdar/rust-2048)
* [marching-squares](https://github.com/crespyl/marching-squares)