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

3 4
A pure Rust library for handling, manipulating and reading information about terminals. This provides a full-featured alternative to Termbox.

Ticki's avatar
Ticki committed
5 6
Supports Redox and POSIX. Untested on Windows.

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

ticki's avatar
ticki committed
9
## A note on stability
Ticki's avatar
Ticki committed
10

ticki's avatar
ticki committed
11 12
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
13

ticki's avatar
ticki committed
14
## Features
15 16

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

and much more.
34

ticki's avatar
ticki committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
## 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
64 65 66

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

Antonin Carette's avatar
Antonin Carette committed
67
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
68

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

Ticki's avatar
Ticki committed
71

ticki's avatar
ticki committed
72
## TODO
73 74

- Mouse input
Ticki's avatar
Ticki committed
75

ticki's avatar
ticki committed
76
## License
Ticki's avatar
Ticki committed
77

ticki's avatar
ticki committed
78
MIT/X11.