Go to file
ticki e36ff1c71b Termion 1.0.0: Complete overhaul of how escape codes are handled, add truecolor support.
This commit is a major semver bump. Every progra utilizing escape codes generated by Termion is likely broken. The main change is to make each escape has their own type implementing the Display trait.

- Use formatters, mainly Display for escapes.

- Add Truecolor support (`color::Rgb`).

- Put each primitive into distinct modules.

- Add is_tty for checking if some stream is a TTY.

- Add multiple new examples.
2016-07-23 16:40:27 +02:00
examples Termion 1.0.0: Complete overhaul of how escape codes are handled, add truecolor support. 2016-07-23 16:40:27 +02:00
src Termion 1.0.0: Complete overhaul of how escape codes are handled, add truecolor support. 2016-07-23 16:40:27 +02:00
.gitignore Add README 2016-03-06 14:55:01 +01:00
Cargo.toml Termion 1.0.0: Complete overhaul of how escape codes are handled, add truecolor support. 2016-07-23 16:40:27 +02:00
LICENSE Add license 2016-03-08 09:30:24 +01:00
README.md Termion 1.0.0: Complete overhaul of how escape codes are handled, add truecolor support. 2016-07-23 16:40:27 +02:00
image.png Example image 2016-03-16 08:11:35 +01:00

README.md

Termion

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.

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).

Documentation. | Examples.

A note on stability

Although small breaking changes might happen, I will try my best to avoid them, and this crate can generally be considered stable.

Cargo.toml

For nightly, add

[dependencies.termion]
git = "https://github.com/ticki/termion.git"

For stable,

[dependencies.termion]
git = "https://github.com/ticki/termion.git"
default-features = false

Features

  • Raw mode.
  • Truecolor.
  • 256-color mode.
  • Cursor movement.
  • Color output.
  • Calculating ANSI escapes.
  • Text formatting.
  • Console size.
  • Control sequences.
  • Termios control.
  • Password input.
  • Redox support.
  • Panic-free error handling.
  • Special keys events (modifiers, special keys, etc.).
  • Allocation-free.
  • Asynchronous key events.
  • Carefully tested.

and much more.

Example

extern crate termion;

use termion::{color, style};

use std::io;

fn main() {
    println!("{}Red", color::Fg(color::Red));

    println!("{}Blue", color::Fg(color::Blue));

    println!("{}Blue'n'Bold{}", style::Bold, style::Reset);

    println!("{}Just plain italic", style::Italic);
}

Usage

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

For a more complete example, see a minesweeper implementation, that I made for Redox using termion.

TODO

  • Mouse input

License

MIT/X11.