Skip to main content

Crate gilt

Crate gilt 

Source
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

ModuleDescription
consoleConsole output with color detection, capture, and export
styleText styles (bold, italic, colors, extended underlines)
textRich text with markup parsing and word wrapping
tableUnicode box-drawing tables with alignment and striping
panelBordered content panels with titles
treeHierarchical tree display with guide lines
syntaxCode highlighting via syntect (150+ languages)
markdownTerminal-rendered Markdown
progressMulti-bar progress display with ETA and speed
liveLive-updating terminal display
gradientTrue-color RGB gradient text
styled_strStylize trait for "text".bold().red() chaining
inspectDebug any value with rich formatting

§Feature Flags

FeatureDescription
tracingtracing subscriber with gilt formatting
derive#[derive(Table)] proc macro for struct-to-table
miettemiette diagnostic report handler
eyreeyre error report handler
anstyleBidirectional From conversions with anstyle

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 log crate.
markdown
Markdown rendering module – parses CommonMark and produces styled terminal output.
markup
Rich markup parser — parses [bold red]text[/] syntax into styled Text.
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
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.