anes 0.1.3

An ANSI escape sequences.
Documentation

Stable Status Beta Status Nightly Status crates.io docs.rs MIT Apache 2.0 LOC

ANSI Escape Sequence

A Rust library which provides an ANSI escape sequences (or codes, whatever you like more).

Current status is experimental.

Goals

  • Provide ANSI escape sequences.
  • Provide input events parser (2nd phase).

Examples

[dependencies]
anes = "0.1"

An example how to retrieve the ANSI escape sequence as a String:

use anes::SaveCursorPosition;

fn main() {
    let string = format!("{}", SaveCursorPosition);
    assert_eq!(&string, "\x1B7");
}

An example how to use the ANSI escape sequence:

use std::io::{Result, Write};

use anes;

fn main() -> Result<()> {
    let mut stdout = std::io::stdout();
    write!(stdout, "{}", anes::SaveCursorPosition)?;
    write!(stdout, "{}", anes::RestoreCursorPosition)?;
    stdout.flush()?;
    Ok(())
}

Motivation

There're couple of terminal crates like:

All these crates do share two pieces of code:

  • ANSI escape sequences and
  • input event parsers.

I think that it's a waste of resources and asked Timon (the crossterm crate maintainer) what he thinks about a new crate as a building block for the crossterm and other crates. And here we are ...

License

The ANES crate is dual-licensed under Apache 2.0 and MIT terms.

Copyrights in the ANES project are retained by their contributors. No copyright assignment is required to contribute to the ANES project.