โจ Features
- ๐จ Style โ foreground/background colors, bold, italic, underline, dim, blink, reverse, strikethrough
- ๐ Console markup โ
[bold red]text[/bold red] BBCode-like inline styling
- ๐ Table โ tabular data with headers, footers, colspan/rowspan, column alignment, sections
- ๐ฒ Tree โ hierarchical tree rendering with Unicode guides
- ๐ฆ Panel โ bordered containers with titles, subtitles, 17 box styles
- โ Rule โ horizontal dividers with optional titles
- ๐ Padding & Align โ CSS-style spacing and alignment helpers
- ๐ Columns โ side-by-side layout
- ๐๏ธ Layout โ recursive split-pane layout system with ratio sizing
- โณ Progress โ multi-task progress bars with 7 column types, file tracking
- ๐ Spinner โ 36+ animated spinners with name-based lookup
- ๐ Status โ spinner + message with in-place update
- ๐ Live โ auto-updating live displays with alt-screen support
- ๐ Syntax highlighting โ powered by syntect (100+ languages)
- ๐ Markdown โ headings, code blocks, lists, blockquotes, links
- ๐ JSON โ pretty-printed, syntax-highlighted output
- ๐ Logging โ Rich-formatted log records via the
log crate
- ๐ผ๏ธ Box drawing โ 17 box styles (rounded, square, heavy, double, ASCII, etc.)
- ๐ฏ TrueColor / 256 / Standard color with automatic detection and downgrade
- ๐ฅ๏ธ Screen / Alt-screen โ full-screen terminal applications
- โจ๏ธ Prompts โ
Prompt, IntPrompt, FloatPrompt, Confirm, Select<T>, password mode
- ๐ด Traceback โ rich exception rendering with locals, source code, frame suppression
- ๐ค HTML & SVG export โ capture console output for the web
- ๐ญ Themes โ named style maps with stack-based inheritance
๐ฆ Installation
[dependencies]
rusty-rich = "0.1"
๐ Quick Start
use rusty_rich::{
Console, Panel, Table, Column, Rule, Tree,
Style, Color, AlignMethod, Padding,
};
fn main() {
let mut console = Console::new();
console.print_str("[bold green]Hello, [red]World![/red][/bold green]");
let panel = Panel::new("Hello inside a rounded box!")
.title("My Panel")
.border_style(Style::new().color(Color::parse("cyan").unwrap()));
console.println(&panel);
let mut table = Table::new();
table.add_column(Column::new("Name").justify(AlignMethod::Left));
table.add_column(Column::new("Age").justify(AlignMethod::Right));
table.add_row_str(vec!["Alice".into(), "30".into()]);
table.add_row_str(vec!["Bob".into(), "25".into()]);
console.println(&table);
let mut tree = Tree::new("Root");
tree.add("Child 1").add("Grandchild");
tree.add("Child 2");
console.println(&tree);
console.rule("Section Break", None, None, None);
}
๐ Table with Colspan & Rowspan
use rusty_rich::Table;
let mut table = Table::new().title("User Report");
table.add_column(Column::new("Name"));
table.add_column(Column::new("Details").colspan(2)); table.add_column(Column::new("Role"));
let row = vec![
Cell::new("Alice"),
Cell::new("Engineer").colspan(2),
];
table.add_row(row);
โณ Progress Bars
use rusty_rich::Progress;
use std::thread;
use std::time::Duration;
let mut progress = Progress::new();
let task_id = progress.add_task("Downloading...", Some(100.0));
for i in 0..=100 {
progress.update(task_id, i as f64);
print!("\r{}", progress.render(80));
thread::sleep(Duration::from_millis(20));
}
println!();
let items: Vec<_> = (0..100).collect();
let tracker = progress.track(items, "Processing", None);
for item in tracker {
}
โจ๏ธ Interactive Prompts
use rusty_rich::{Prompt, Confirm, IntPrompt, Select};
let name = Prompt::ask_with("Enter your name").unwrap();
let password = Prompt::new("Password").password(true).ask().unwrap();
let ok = Confirm::ask_with("Continue?", true).unwrap();
let age = IntPrompt::ask_with("Enter age").unwrap();
let choice = Select::new("Pick a color")
.add("Red", "red")
.add("Green", "green")
.add("Blue", "blue")
.ask()
.unwrap();
๐ด Rich Tracebacks
use rusty_rich::traceback;
traceback::install();
let tb = Traceback::from_exception("MyError", "something went wrong", frames)
.show_locals(true)
.max_frames(5)
.suppress(vec!["std::".into(), "core::".into()]);
๐ฅ๏ธ Full-Screen Apps
use rusty_rich::{Console, Screen, Live};
use std::thread;
use std::time::Duration;
let mut console = Console::new();
let mut screen = console.screen(); screen.enter();
let mut live = Live::new(Panel::new("Loading...").title("Status"));
live.start();
for i in 0..=100 {
let panel = Panel::new(format!("Progress: {}%", i))
.title("Status");
live.update(panel);
thread::sleep(Duration::from_millis(50));
}
live.stop();
screen.exit();
๐จ Box Styles (17 built-in)
| Style |
Preview |
BOX_ROUNDED |
โญโโฎ โ โ โฐโโฏ |
BOX_SQUARE |
โโโ โ โ โโโ |
BOX_HEAVY |
โโโ โ โ โโโ |
BOX_DOUBLE |
โโโ โ โ โโโ |
BOX_DOUBLE_EDGE |
โโโ โ โ โโโ |
BOX_HEAVY_EDGE |
โโโ โ โ โโโ |
BOX_HEAVY_HEAD |
โโโ โ โ โโโ |
BOX_SIMPLE |
borderless with separators |
BOX_MINIMAL |
minimal horizontal rules |
BOX_ASCII |
+--+ ASCII-safe |
| โฆ and 7 more |
|
๐ฏ Color System
use rusty_rich::{Color, Style};
let red = Color::parse("red").unwrap();
let hot_pink = Color::parse("#FF69B4").unwrap();
let style = Style::new()
.color(Color::parse("#FF6600").unwrap())
.bgcolor(Color::parse("#1E1E2E").unwrap())
.bold(true)
.italic(true);
๐ Module Map
src/
โโโ lib.rs # Crate root + re-exports
โโโ console.rs # Central rendering engine
โโโ screen.rs # Full-screen / alt-screen
โโโ color.rs # TrueColor / 256 / Standard
โโโ style.rs # 13 attributes + hyperlinks
โโโ theme.rs # Named style maps + stack
โโโ segment.rs # Styled text segment + control codes
โโโ text.rs # Text with Span styling
โโโ cells.rs # Unicode cell width utilities
โโโ measure.rs # Width measurement protocol
โโโ align.rs # Horizontal + vertical alignment
โโโ ratio.rs # Proportional space distribution
โโโ markup.rs # BBCode-like markup parser
โโโ highlighter.rs # Regex/Repr highlighters
โ
โโโ panel.rs # Bordered container
โโโ table.rs # Tabular data + colspan/rowspan
โโโ tree.rs # Hierarchical tree
โโโ rule.rs # Horizontal divider
โโโ padding.rs # CSS-style padding
โโโ columns.rs # Side-by-side layout
โโโ layout.rs # Split-pane layout
โโโ box_drawing.rs # 17 box/border styles
โ
โโโ progress.rs # Multi-task progress + track()
โโโ progress_columns.rs # 7 progress column types
โโโ spinner.rs # 36+ animated spinners
โโโ status.rs # Spinner + message
โโโ live.rs # Auto-updating display
โ
โโโ syntax.rs # Syntax highlighting (syntect)
โโโ markdown.rs # Markdown rendering (pulldown-cmark)
โโโ json.rs # Pretty-printed JSON
โโโ logging.rs # log crate integration
โโโ prompt.rs # Interactive prompts
โโโ traceback.rs # Rich exception tracebacks
๐ฌ Compared to Python Rich
| Feature |
Python Rich |
rusty-rich |
| Console + markup |
โ
|
โ
|
| Text / Span / Style |
โ
|
โ
|
| Table (colspan/rowspan) |
โ
|
โ
|
| Panel / Rule / Tree |
โ
|
โ
|
| Layout / Columns |
โ
|
โ
|
| Progress (7 column types) |
โ
|
โ
|
| Live / Status |
โ
|
โ
|
| Syntax highlighting |
โ
|
โ
|
| Markdown / JSON |
โ
|
โ
|
| Traceback (locals, suppress) |
โ
|
โ
|
| Screen / Alt-screen |
โ
|
โ
|
| Prompts (5 types) |
โ
|
โ
|
| 36+ Spinners |
โ
|
โ
|
| 17 Box styles |
โ
|
โ
|
| HTML / SVG export |
โ
|
โ
|
| Logging handler |
โ
|
โ
|
| Jupyter integration |
โ
|
โ |
| File watching |
โ
|
โ |
| Overall parity |
|
~90% |
๐งช Testing
cargo test cargo test --test battle_test
๐ License
MIT โ See LICENSE for details.