Crate anes

source ·
Expand description

ANSI Escape Sequences provider & parser

Sequences provider

The anes crate provides ANSI escape sequences you can use to control the terminal cursor (show, hide, …), colors (foreground, background), display attributes (bold, …) and many others.

Every sequence implements the standard library Display trait. It means that these sequences can be used in macros like format! or write!.

Ask if you need more sequences or use the sequence! macro to create your own sequences.

Terminal Support

Not all ANSI escape sequences are supported by all terminals. You can use the interactive-test to test them.

Examples

Retrieve the sequence as a String:

use anes::SaveCursorPosition;

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

Execute the sequence on the standard output:

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

use anes::execute;

fn main() -> Result<()> {
    let mut stdout = std::io::stdout();
    execute!(&mut stdout, anes::ResetAttributes)
}

Sequences parser

Parser isn’t available with default features. You have to enable parser feature if you’d like to use it. You can learn more about this feature in the parser module documentation.

Modules

  • An ANSI escape sequence parser module.

Macros

  • Creates a control sequence.
  • Creates an escape sequence.
  • Executes ANSI escape sequence(s).
  • Queues ANSI escape sequence(s).
  • Creates an ANSI sequence.
  • Creates a select graphic rendition sequence.

Structs

Enums