[][src]Crate anes

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

parser

An ANSI escape sequence parser module.

Macros

csi

Creates a control sequence.

esc

Creates an escape sequence.

execute

Executes ANSI escape sequence(s).

queue

Queues ANSI escape sequence(s).

sequence

Creates an ANSI sequence.

sgr

Creates a select graphic rendition sequence.

Structs

DisableCursorBlinking

Disables the cursor blinking.

DisableMouseEvents

Tells the terminal to stop reporting mouse events.

EnableCursorBlinking

Enables the cursor blinking.

EnableMouseEvents

Tells the terminal to start reporting mouse events.

HideCursor

Hides the cursor.

MoveCursorDown

Moves the cursor down by the given number of rows.

MoveCursorLeft

Moves the cursor left by the given number of columns.

MoveCursorRight

Moves the cursor right by the given number of columns.

MoveCursorTo

Moves the cursor to the given location (column, row).

MoveCursorToColumn

Moves the cursor to the given column.

MoveCursorToNextLine

Moves the cursor to beginning of line the given number of lines down.

MoveCursorToPreviousLine

Moves the cursor to beginning of line the given number of lines up.

MoveCursorUp

Moves the cursor up by the given number of rows.

ReportCursorPosition

Asks for the current cursor position.

ResetAttributes

Resets all attributes.

ResizeTextArea

Resizes the text area to the given width and height in characters.

RestoreCursorPosition

Restores the cursor position.

SaveCursorPosition

Saves the cursor position.

ScrollBufferDown

Scrolls down by the given number of rows.

ScrollBufferUp

Scrolls up by the given number of rows.

SetAttribute

Sets the display attribute.

SetBackgroundColor

Sets the background color.

SetForegroundColor

Sets the foreground color.

ShowCursor

Shows the cursor.

SwitchBufferToAlternate

Switches to the alternate buffer.

SwitchBufferToNormal

Switches to the normal buffer.

Enums

Attribute

A display attribute.

ClearBuffer

Clears part of the buffer.

ClearLine

Clears part of the line.

Color

A color.