| Crates.io | glyphs |
| lib.rs | glyphs |
| version | 0.1.1 |
| created_at | 2025-12-14 18:23:10.828497+00 |
| updated_at | 2025-12-14 21:57:18.364783+00 |
| description | Beautiful ANSI escape sequences for terminal styling ✨ |
| homepage | https://molten.dev/sigil |
| repository | https://github.com/moltenlabs/glyphs |
| max_upload_size | |
| id | 1984889 |
| size | 69,870 |
Beautiful ANSI escape sequences for Rust.
Features • Installation • Quick Start • Parsing • Ecosystem
Glyphs is a Rust library for working with ANSI escape sequences. It lets you:
Think of it as the Rust equivalent of sequin from Charmbracelet.
use glyphs::{style, Color, parse};
// Style text beautifully
let output = style("Hello, Terminal!")
.fg(Color::rgb(249, 115, 22)) // Molten Orange
.bold()
.to_string();
println!("{}", output);
// Parse mystery sequences
for segment in parse("\x1b[1;31mError\x1b[0m") {
println!("{:?}", segment);
// Escape: [SGR (style)] bold, red fg
// Text: "Error"
// Escape: [SGR (style)] reset
}
🎨 Fluent Styling API
|
🔍 Sequence Parsing
|
🌈 Full Color Support
|
🧹 String Utilities
|
cargo add glyphs
Or add to your Cargo.toml:
[dependencies]
glyphs = "0.1"
[dependencies]
glyphs = { version = "0.1", features = ["brand"] }
use glyphs::{style, Color};
// Simple colors
let red = style("Error!").fg(Color::Red).to_string();
let warning = style("Warning").fg(Color::Yellow).bold().to_string();
// RGB colors
let custom = style("Custom")
.fg(Color::rgb(255, 128, 0))
.to_string();
// Hex colors
let hex = style("Hex")
.fg(Color::from_hex("#F97316"))
.to_string();
// 256-color palette
let palette = style("Palette")
.fg(Color::ansi256(208))
.to_string();
use glyphs::{style, Color};
let styled = style("Important")
.bold() // Bold text
.italic() // Italic
.underline() // Underlined
.strikethrough() // Strikethrough
.dim() // Dimmed
.reverse() // Inverted colors
.blink() // Blinking (if supported)
.to_string();
use glyphs::{style, Color};
let fancy = style("🔥 Molten Labs")
.fg(Color::rgb(249, 115, 22))
.bold()
.underline()
.to_string();
println!("{}", fancy);
Turn cryptic escape codes into readable descriptions:
use glyphs::{parse, ParsedSequence};
let input = "\x1b[1;38;2;249;115;22mMolten\x1b[0m";
for segment in parse(input) {
match segment {
ParsedSequence::Text(text) => {
println!("Text: {}", text);
}
ParsedSequence::Escape(escape) => {
println!("Escape: {}", escape.human_readable());
// "bold, fg: rgb(249, 115, 22)"
}
}
}
use glyphs::strip_ansi;
let styled = "\x1b[1;31mBold Red\x1b[0m Normal";
let plain = strip_ansi(styled);
assert_eq!(plain, "Bold Red Normal");
use glyphs::visible_len;
let styled = "\x1b[31mHello\x1b[0m";
assert_eq!(visible_len(styled), 5); // Not 14!
use glyphs::cursor;
// Move cursor
print!("{}", cursor::up(5)); // Move up 5 lines
print!("{}", cursor::down(3)); // Move down 3 lines
print!("{}", cursor::left(10)); // Move left 10 columns
print!("{}", cursor::right(10)); // Move right 10 columns
// Position cursor
print!("{}", cursor::goto(10, 20)); // Row 10, Column 20
print!("{}", cursor::column(1)); // Start of line
use glyphs::sequences;
// Clear screen
print!("{}", sequences::CLEAR_SCREEN);
print!("{}", sequences::CLEAR_LINE);
// Cursor visibility
print!("{}", sequences::CURSOR_HIDE);
// ... do stuff ...
print!("{}", sequences::CURSOR_SHOW);
// Alternate screen buffer (for TUIs)
print!("{}", sequences::ALT_SCREEN_ENTER);
// ... your TUI ...
print!("{}", sequences::ALT_SCREEN_EXIT);
| Color | Code | Bright Variant |
|---|---|---|
Color::Black |
30 | Color::BrightBlack |
Color::Red |
31 | Color::BrightRed |
Color::Green |
32 | Color::BrightGreen |
Color::Yellow |
33 | Color::BrightYellow |
Color::Blue |
34 | Color::BrightBlue |
Color::Magenta |
35 | Color::BrightMagenta |
Color::Cyan |
36 | Color::BrightCyan |
Color::White |
37 | Color::BrightWhite |
Color::rgb(255, 128, 0) // Orange
Color::from_hex("#F97316") // Molten Orange
Color::from_hex("7C3AED") // Goblin Purple (# optional)
Color::ansi256(0) // Black
Color::ansi256(196) // Bright red
Color::ansi256(208) // Orange
Color::ansi256(255) // White
| Modifier | ANSI Code | Description |
|---|---|---|
.bold() |
1 | Bold text |
.dim() |
2 | Dimmed text |
.italic() |
3 | Italic text |
.underline() |
4 | Underlined |
.blink() |
5 | Blinking text |
.reverse() |
7 | Inverted colors |
.hidden() |
8 | Hidden text |
.strikethrough() |
9 |
Glyphs is part of the Molten Labs open source ecosystem:
| Crate | Description | Status |
|---|---|---|
| molten_brand | Design tokens & colors | ✅ Published |
| glyphs | ANSI sequences (you are here) | ✅ Published |
| lacquer | Terminal styling (like lipgloss) | ✅ Published |
| cauldron | TUI framework (like bubbletea) | 📋 Planned |
A glyph is a symbolic mark or character—like the hidden ANSI codes that transform plain text into beautiful terminal output. In the forge, we inscribe glyphs to add magic to our creations. ✨
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
git clone https://github.com/moltenlabs/glyphs
cd glyphs
cargo test
Licensed under either of:
at your option.
Built with ✨ by Molten Labs
"Let them cook."