README.md 1.92 KB
Newer Older
ticki's avatar
ticki committed
1
# Termion
Ticki's avatar
Ticki committed
2

ticki's avatar
ticki committed
3 4 5
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.
6

ticki's avatar
ticki committed
7 8 9 10 11
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).
Ticki's avatar
Ticki committed
12

Ticki's avatar
Ticki committed
13 14
[Documentation.](http://ticki.github.io/termion/termion/) | [Examples.](https://github.com/Ticki/termion/tree/master/examples)

ticki's avatar
ticki committed
15
## A note on stability
Ticki's avatar
Ticki committed
16

ticki's avatar
ticki committed
17 18
Although small breaking changes might happen, I will try my best to avoid them,
and this crate can generally be considered stable.
Ticki's avatar
Ticki committed
19

ticki's avatar
ticki committed
20
## Features
21 22

- Raw mode.
ticki's avatar
ticki committed
23
- 256-color mode.
24 25
- Cursor movement.
- Color output.
ticki's avatar
ticki committed
26
- Calculating ANSI escapes.
27 28 29 30 31
- Text formatting.
- Console size.
- Control sequences.
- Termios control.
- Password input.
Ticki's avatar
Ticki committed
32 33
- Redox support.
- Panic-free error handling.
Ticki's avatar
Ticki committed
34
- Special keys events (modifiers, special keys, etc.).
ticki's avatar
ticki committed
35
- Allocation-free.
Ticki's avatar
Ticki committed
36
- Asynchronous key events.
ticki's avatar
ticki committed
37
- Carefully tested.
Ticki's avatar
Ticki committed
38 39

and much more.
40

ticki's avatar
ticki committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
## 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
Ticki's avatar
Ticki committed
70 71 72

See `examples/`, and the documentation, which can be rendered using `cargo doc`.

Antonin Carette's avatar
Antonin Carette committed
73
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.
Ticki's avatar
Ticki committed
74

ticki's avatar
ticki committed
75
<img src="image.png" width="200">
Ticki's avatar
Resize  
Ticki committed
76

Ticki's avatar
Ticki committed
77

ticki's avatar
ticki committed
78
## TODO
79 80

- Mouse input
Ticki's avatar
Ticki committed
81

ticki's avatar
ticki committed
82
## License
Ticki's avatar
Ticki committed
83

ticki's avatar
ticki committed
84
MIT/X11.