termion/README.md

102 lines
2.1 KiB
Markdown
Raw Normal View History

2016-07-02 14:06:47 +01:00
# Termion
2016-03-06 13:55:01 +00:00
2016-07-02 14:42:18 +01:00
Termion is a pure Rust, bindless library for low-level handling, manipulating
and reading information about terminals. This provides a full-featured
alternative to Termbox.
2016-07-02 14:42:18 +01:00
Termion aims to be simple and yet expressive. It is bindless, meaning that it
is not a front-end to some other library (e.g., ncurses or termbox), but a
standalone library directly talking to the TTY.
Supports Redox, Mac OS X, and Linux (or, in general, ANSI terminals).
2016-03-07 21:19:35 +00:00
2016-07-03 12:43:22 +01:00
[Documentation.](http://ticki.github.io/termion/) | [Examples.](https://github.com/Ticki/termion/tree/master/examples)
2016-03-16 07:36:50 +00:00
2016-07-02 14:06:47 +01:00
## A note on stability
2016-03-08 18:44:31 +00:00
2016-07-02 14:06:47 +01:00
Although small breaking changes might happen, I will try my best to avoid them,
and this crate can generally be considered stable.
2016-03-08 18:44:31 +00:00
2016-07-03 12:27:07 +01:00
## Cargo.toml
For nightly, add
```toml
[dependencies.termion]
2016-07-03 12:46:18 +01:00
git = "https://github.com/ticki/termion.git"
2016-07-03 12:27:07 +01:00
```
For stable,
```toml
[dependencies.termion]
2016-07-03 12:46:18 +01:00
git = "https://github.com/ticki/termion.git"
2016-07-03 12:27:07 +01:00
default-features = false
```
2016-07-02 14:06:47 +01:00
## Features
- Raw mode.
2016-06-14 13:29:31 +01:00
- 256-color mode.
- Cursor movement.
- Color output.
2016-07-02 14:06:47 +01:00
- Calculating ANSI escapes.
- Text formatting.
- Console size.
- Control sequences.
- Termios control.
- Password input.
2016-03-08 18:44:31 +00:00
- Redox support.
- Panic-free error handling.
2016-03-15 19:32:25 +00:00
- Special keys events (modifiers, special keys, etc.).
2016-06-14 13:29:31 +01:00
- Allocation-free.
2016-03-15 19:32:25 +00:00
- Asynchronous key events.
2016-07-02 14:06:47 +01:00
- Carefully tested.
2016-03-08 18:44:31 +00:00
and much more.
2016-07-02 14:06:47 +01:00
## Example
```rust
extern crate termion;
use termion::{TermWrite, color, Style};
use std::io;
fn main() {
let stdout = io::stdout();
let mut stdout = stdout.lock();
stdout.color(color::Red).unwrap();
println!("Red");
stdout.color(color::Blue).unwrap();
println!("Blue");
stdout.style(Style::Bold).unwrap();
println!("Blue'n'Bold");
stdout.reset().unwrap();
stdout.style(Style::Italic).unwrap();
println!("Just plain italic")
}
```
## Usage
2016-03-15 19:39:08 +00:00
See `examples/`, and the documentation, which can be rendered using `cargo doc`.
2016-04-02 21:48:12 +01:00
For a more complete example, see [a minesweeper implementation](https://github.com/redox-os/games-for-redox/blob/master/src/minesweeper/main.rs), that I made for Redox using termion.
2016-03-15 19:39:08 +00:00
2016-07-02 14:06:47 +01:00
<img src="image.png" width="200">
2016-03-16 07:14:58 +00:00
2016-03-16 07:11:35 +00:00
2016-07-02 14:06:47 +01:00
## TODO
- Mouse input
2016-03-06 13:55:01 +00:00
2016-07-02 14:06:47 +01:00
## License
2016-03-06 13:55:01 +00:00
2016-07-02 14:06:47 +01:00
MIT/X11.