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.
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§
- Disable
Cursor Blinking - Disables the cursor blinking.
- Disable
Mouse Events - Tells the terminal to stop reporting mouse events.
- Enable
Cursor Blinking - Enables the cursor blinking.
- Enable
Mouse Events - Tells the terminal to start reporting mouse events.
- Hide
Cursor - Hides the cursor.
- Move
Cursor Down - Moves the cursor down by the given number of rows.
- Move
Cursor Left - Moves the cursor left by the given number of columns.
- Move
Cursor Right - Moves the cursor right by the given number of columns.
- Move
Cursor To - Moves the cursor to the given location (column, row).
- Move
Cursor ToColumn - Moves the cursor to the given column.
- Move
Cursor ToNext Line - Moves the cursor to beginning of line the given number of lines down.
- Move
Cursor ToPrevious Line - Moves the cursor to beginning of line the given number of lines up.
- Move
Cursor Up - Moves the cursor up by the given number of rows.
- Report
Cursor Position - Asks for the current cursor position.
- Reset
Attributes - Resets all attributes.
- Resize
Text Area - Resizes the text area to the given width and height in characters.
- Restore
Cursor Position - Restores the cursor position.
- Save
Cursor Position - Saves the cursor position.
- Scroll
Buffer Down - Scrolls down by the given number of rows.
- Scroll
Buffer Up - Scrolls up by the given number of rows.
- SetAttribute
- Sets the display attribute.
- SetBackground
Color - Sets the background color.
- SetForeground
Color - Sets the foreground color.
- Show
Cursor - Shows the cursor.
- Switch
Buffer ToAlternate - Switches to the alternate buffer.
- Switch
Buffer ToNormal - Switches to the normal buffer.
Enums§
- Attribute
- A display attribute.
- Clear
Buffer - Clears part of the buffer.
- Clear
Line - Clears part of the line.
- Color
- A color.