Expand description
§Sigil ✨
Human-readable ANSI escape sequences for terminal styling.
Sigil makes it easy to work with ANSI escape codes in a type-safe, readable way. It’s the Rust equivalent of sequin from Charmbracelet.
§Quick Start
use glyphs::{style, Color, Modifier};
// Style some text
let styled = style("Hello, World!")
.fg(Color::Red)
.bold()
.to_string();
println!("{}", styled);
// Use RGB colors
let rgb = style("Molten Orange")
.fg(Color::rgb(249, 115, 22))
.to_string();
// Parse existing ANSI sequences
let parsed = glyphs::parse("\x1b[31mRed text\x1b[0m");§Features
- Type-safe - No string manipulation, just types
- Human-readable - Parse ANSI codes to readable descriptions
- Zero-copy - Efficient string handling where possible
- Brand integration - Optional Molten brand colors via
brandfeature
Modules§
- cursor
- Cursor movement helpers.
- prelude
- Prelude for convenient imports.
- sequences
- Common escape sequences.
Structs§
- Escape
- A parsed escape sequence.
- Sequence
- A complete ANSI sequence that can be written to a terminal.
- Sequence
Builder - A builder for constructing ANSI escape sequences.
- Style
- A style definition (without text).
- Styled
- A styled string with colors and modifiers.
Enums§
- Color
- A terminal color.
- Escape
Kind - Kind of escape sequence.
- Modifier
- Text style modifiers.
- Parsed
Sequence - A parsed segment of text (either plain text or an escape sequence).
Constants§
- CSI
- CSI (Control Sequence Introducer) prefix.
- OSC
- OSC (Operating System Command) prefix.
- RESET
- Reset all attributes.
- SGR_
SUFFIX - SGR (Select Graphic Rendition) suffix.
Functions§
- gradient
- Apply a gradient to text (char by char).
- parse
- Parse a string containing ANSI escape sequences.
- rainbow
- Apply a rainbow gradient to text.
- strip_
ansi - Strip all ANSI escape sequences from a string.
- style
- Create a styled string.
- visible_
len - Get the visible length of a string (excluding ANSI codes).