Expand description
§gilt — Rich terminal formatting for Rust
gilt is a Rust port of Python’s rich library, providing beautiful terminal output with styles, tables, trees, syntax highlighting, progress bars, and more — all rendered as ANSI escape sequences.
§Quick Start
use gilt::prelude::*;
let mut console = Console::builder().width(80).build();
console.begin_capture();
console.print_text("Hello, [bold magenta]gilt[/bold magenta]!");
let output = console.end_capture();
assert!(output.contains("Hello"));§Global Console
For quick one-off output, use the global convenience functions:
gilt::print_text("Hello, [bold]world[/bold]!");
gilt::print_json(r#"{"name": "gilt"}"#);
gilt::inspect(&vec![1, 2, 3]);§Core Modules
| Module | Description |
|---|---|
console | Console output with color detection, capture, and export |
style | Text styles (bold, italic, colors, extended underlines) |
text | Rich text with markup parsing and word wrapping |
table | Unicode box-drawing tables with alignment and striping |
panel | Bordered content panels with titles |
tree | Hierarchical tree display with guide lines |
syntax | Code highlighting via syntect (150+ languages) |
markdown | Terminal-rendered Markdown |
progress | Multi-bar progress display with ETA and speed |
live | Live-updating terminal display |
gradient | True-color RGB gradient text |
styled_str | Stylize trait for "text".bold().red() chaining |
inspect | Debug any value with rich formatting |
§Feature Flags
Modules§
- align_
widget - Alignment widget – positions renderable content within available space.
- ansi
- ANSI escape code parsing and conversion to styled Text.
- bar
- Bar renderable – a solid block-character bar.
- box_
chars - Box-drawing character sets for tables.
- cells
- Cell width calculation for terminal display.
- color
- Terminal color representation and manipulation.
- color_
env - Environment variable detection for color overrides.
- color_
triplet - RGB color triplet representation.
- columns
- Columns module – displays renderables in neat auto-fitted columns.
- console
- Console engine — the central orchestrator of gilt rendering output.
- constrain
- Constrain widget – limits the width of a renderable to a given number of characters.
- containers
- Container types for grouping renderables.
- control
- Control codes and sequences for terminal manipulation.
- default_
styles - Default style definitions for the gilt library.
- emoji
- Emoji widget for terminal rendering.
- emoji_
codes - Emoji code mappings from name to Unicode character.
- emoji_
replace - Emoji replacement in text strings.
- errors
- Error types used throughout the gilt library.
- export_
format - Export format templates for Console HTML and SVG output.
- filesize
- Functions for reporting file sizes in human-readable form.
- gradient
- True color gradient rendering across text.
- group
- Group widget – renders a collection of renderables in sequence.
- highlighter
- Regex-based text highlighting.
- inspect
- Inspect any Rust value in a beautifully formatted panel.
- json
- Pretty-printed, syntax-highlighted JSON display.
- layout
- Layout module — a recursive screen-splitting layout system.
- live
- Live display module – a terminal display that refreshes at regular intervals.
- live_
render - Live render module – a renderable that can be updated and tracks its dimensions.
- logging_
handler - Rich logging handler for the
logcrate. - markdown
- Markdown rendering module – parses CommonMark and produces styled terminal output.
- markup
- Rich markup parser — parses
[bold red]text[/]syntax into styledText. - measure
- Measurement module for tracking minimum and maximum rendering widths.
- padding
- Padding widget – adds whitespace around renderable content.
- pager
- Pager module for displaying content through a system pager.
- palette
- Color palette management and color matching.
- panel
- Panel widget – a bordered box around content with optional title/subtitle.
- prelude
- Convenience re-exports for common gilt types.
- pretty
- Pretty-printing module for structured data.
- progress
- Progress tracking system – configurable progress bars with live display.
- progress_
bar - Progress bar renderable – a styled progress bar with pulse animation.
- prompt
- Interactive prompt module for styled user input with validation, choices, and defaults.
- ratio
- Algorithms for distributing integers proportionally.
- region
- Region type for rectangular screen areas.
- rule
- Rule widget – a horizontal line with optional title.
- scope
- Scope module – renders a mapping of key-value pairs in a panel.
- screen
- Screen module – a renderable that fills the terminal screen and crops excess.
- segment
- Segment - the atomic unit of terminal rendering.
- spinner
- Spinner animation widget.
- spinners
- Spinner animation frame data.
- status
- Status indicator with a spinner animation.
- style
- Style representation and manipulation for terminal text.
- styled
- Apply a style to a renderable.
- styled_
str - Rust-idiomatic style extension trait for string types.
- syntax
- Syntax highlighting module for terminal display.
- table
- Table module – rich table rendering with columns, rows, and box borders.
- terminal_
theme - Terminal theme definitions for color resolution and export rendering.
- text
- Rich text module - the core text manipulation type.
- theme
- Theme and ThemeStack for managing named style collections.
- traceback
- Traceback formatting module for terminal display.
- tree
- Tree widget for rendering hierarchical structures with guide characters.
- wrap
- Word wrapping utilities for terminal text.
Functions§
- inspect
- Inspect a value in the default console.
- Print a renderable to the default console.
- print_
json - Pretty-print JSON to the default console.
- print_
text - Print a text string to the default console, processing markup.
- with_
console - Access the global default console.