Skip to main content

Crate rusty_rich

Crate rusty_rich 

Source
Expand description

§rusty-rich

Rich text and beautiful formatting in the terminal — a Rust port of the popular Python Rich library.

§Features

  • 🎨 Style: foreground/background colors, bold, italic, underline, dim, blink, reverse, strikethrough
  • 📝 Console markup: [bold red]text[/bold red] for inline styling
  • 📊 Table: tabular data with headers, footers, column alignment
  • 🌲 Tree: hierarchical tree rendering
  • 📦 Panel: bordered containers with optional titles
  • Rule: horizontal dividers with optional titles
  • 📐 Padding & Align: spacing and alignment helpers
  • 📋 Columns: side-by-side layout
  • 🗂️ Layout: split-pane layout system
  • Progress: multi-task progress bars
  • 🔄 Spinner: animated spinners
  • 📌 Status: status messages with spinner
  • 🔄 Live: auto-updating live displays
  • 🖥️ Screen: full-screen rendering and alternate screen buffer
  • 🌈 Syntax highlighting: powered by syntect (like Pygments)
  • 📝 Markdown: rich markdown rendering
  • 📋 JSON: pretty-printed, syntax-highlighted JSON
  • 🔍 Logging: Rich-formatted log records
  • 🖼️ Box drawing: 12 box styles (rounded, square, heavy, double, etc.)
  • 🎯 TrueColor / 256 / 16 color support with automatic detection

§Quick Start

use rusty_rich::{
    Console, Panel, Table, Column, Rule, Tree,
    Style, Color, AlignMethod, Padding,
};

fn main() {
    let mut console = Console::new();

    // Print with markup
    console.print_str("[bold green]Hello, [red]World![/red][/bold green]");

    // Create a panel
    let panel = Panel::new("Hello inside a rounded box!")
        .title("My Panel")
        .border_style(Style::new().color(Color::parse("cyan").unwrap()));
    console.println(&panel);

    // Create a table
    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(vec!["Alice".into(), "30".into()]);
    table.add_row(vec!["Bob".into(), "25".into()]);
    console.println(&table);

    // Create a tree
    let mut tree = Tree::new("Root");
    tree.add("Child 1").add("Grandchild");
    tree.add("Child 2");
    console.println(&tree);
}

Re-exports§

pub use color::Color;
pub use color::ColorSystem;
pub use color::ColorType;
pub use style::Style;
pub use style::StyleStack;
pub use segment::Segment;
pub use segment::Segments;
pub use text::Text;
pub use text::Span;
pub use theme::Theme;
pub use align::AlignMethod;
pub use align::VerticalAlignMethod;
pub use align::Align;
pub use measure::Measurement;
pub use console::Console;
pub use console::ConsoleOptions;
pub use console::ConsoleDimensions;
pub use console::OverflowMethod;
pub use console::Renderable;
pub use console::RenderResult;
pub use console::RenderItem;
pub use console::DynRenderable;
pub use console::Group;
pub use console::get_console;
pub use console::print_objects as print;
pub use console::print_str;
pub use console::print_json_val as print_json;
pub use box_drawing::BoxStyle;
pub use box_drawing::BOX_ROUNDED;
pub use box_drawing::BOX_SQUARE;
pub use box_drawing::BOX_HEAVY;
pub use box_drawing::BOX_HEAVY_EDGE;
pub use box_drawing::BOX_HEAVY_HEAD;
pub use box_drawing::BOX_DOUBLE;
pub use box_drawing::BOX_DOUBLE_EDGE;
pub use box_drawing::BOX_SIMPLE;
pub use box_drawing::BOX_SIMPLE_HEAVY;
pub use box_drawing::BOX_MINIMAL;
pub use box_drawing::BOX_MINIMAL_HEAVY;
pub use box_drawing::BOX_ASCII;
pub use box_drawing::BOX_ASCII2;
pub use box_drawing::BOX_SQUARE_DOUBLE_HEAD;
pub use box_drawing::BOX_MINIMAL_DOUBLE_HEAD;
pub use box_drawing::BOX_SIMPLE_HEAD;
pub use box_drawing::BOX_ASCII_DOUBLE_HEAD;
pub use panel::Panel;
pub use table::Table;
pub use table::Column;
pub use table::Cell;
pub use tree::Tree;
pub use rule::Rule;
pub use padding::Padding;
pub use padding::PaddingDimensions;
pub use columns::Columns;
pub use layout::Layout;
pub use layout::LayoutNode;
pub use layout::Direction;
pub use layout::Region;
pub use progress::Progress;
pub use progress::ProgressBar;
pub use progress::ProgressFile;
pub use progress::Task;
pub use progress::TrackIterator;
pub use progress_columns::BarColumn;
pub use progress_columns::DownloadColumn;
pub use progress_columns::FileSizeColumn;
pub use progress_columns::MofNCompleteColumn;
pub use progress_columns::ProgressColumn;
pub use progress_columns::SpinnerColumn;
pub use progress_columns::TaskProgressColumn;
pub use progress_columns::TextColumn;
pub use progress_columns::TimeElapsedColumn;
pub use progress_columns::TimeRemainingColumn;
pub use progress_columns::TotalFileSizeColumn;
pub use progress_columns::TransferSpeedColumn;
pub use progress_columns::format_size;
pub use progress_columns::format_speed;
pub use spinner::Spinner;
pub use spinner::SpinnerFrames;
pub use spinner::DEFAULT_SPINNER;
pub use spinner::get_spinner;
pub use spinner::SPINNER_ARC;
pub use spinner::SPINNER_ARROW;
pub use spinner::SPINNER_ARROW2;
pub use spinner::SPINNER_ARROW3;
pub use spinner::SPINNER_BOUNCING_BAR;
pub use spinner::SPINNER_BOUNCING_BALL;
pub use spinner::SPINNER_CHRISTMAS;
pub use spinner::SPINNER_CIRCLE;
pub use spinner::SPINNER_CLOCK;
pub use spinner::SPINNER_EARTH;
pub use spinner::SPINNER_GRENADE;
pub use spinner::SPINNER_GROW_HORIZONTAL;
pub use spinner::SPINNER_GROW_VERTICAL;
pub use spinner::SPINNER_HAMBURGER;
pub use spinner::SPINNER_HEARTS;
pub use spinner::SPINNER_MONKEY;
pub use spinner::SPINNER_NOISE;
pub use spinner::SPINNER_PONG;
pub use spinner::SPINNER_RUNNER;
pub use spinner::SPINNER_SHARK;
pub use spinner::SPINNER_TOGGLE;
pub use spinner::SPINNER_TRIANGLE;
pub use spinner::SPINNER_VERTICAL_BARS;
pub use spinner::SPINNERS;
pub use prompt::Prompt;
pub use prompt::PromptBase;
pub use prompt::PromptError;
pub use prompt::IntPrompt;
pub use prompt::FloatPrompt;
pub use prompt::Confirm;
pub use prompt::Select;
pub use status::Status;
pub use live::Live;
pub use screen::Screen;
pub use screen::ScreenContext;
pub use screen::ScreenUpdate;
pub use syntax::Syntax;
pub use markdown::render_markdown;
pub use markdown::MarkdownRender;
pub use json::render_json;
pub use json::JsonRender;
pub use logging::RichHandler;
pub use traceback::Traceback;
pub use traceback::Trace;
pub use traceback::Stack;
pub use traceback::Frame;
pub use traceback::install;
pub use highlighter::Highlighter;
pub use highlighter::ReprHighlighter;
pub use highlighter::NullHighlighter;
pub use highlighter::RegexHighlighter;
pub use export::export_html;
pub use export::save_html;
pub use export::ExportHtmlOptions;
pub use export::export_svg;
pub use export::save_svg;
pub use export::ExportSvgOptions;
pub use export::export_text;
pub use export::save_text;
pub use export::ExportTextOptions;
pub use export::ExportTheme;
pub use export::EXPORT_THEME_MONOKAI;
pub use export::EXPORT_THEME_DIMMED_MONOKAI;
pub use export::EXPORT_THEME_NIGHT_OWLISH;
pub use export::EXPORT_THEME_SVG;
pub use export::segments_to_html;
pub use export::escape_html;
pub use export::strip_ansi_escapes;
pub use export::CONSOLE_HTML_FORMAT;
pub use export::CONSOLE_SVG_FORMAT;
pub use markup::render as render_markup;
pub use markup::escape as escape_markup;

Modules§

align
Text alignment — equivalent to Rich’s align.py.
box_drawing
Box drawing — equivalent to Rich’s box.py.
cells
Unicode cell width handling — equivalent to Rich’s cells.py.
color
Color system — equivalent to Rich’s color.py.
columns
Columns — render renderables side by side. Equivalent to Rich’s columns.py.
console
Console — the central rendering engine. Equivalent to Rich’s console.py.
export
HTML and SVG export — equivalent to Rich’s _export_format.py and Console export methods.
highlighter
Highlighter — applies highlighting to strings. Equivalent to Rich’s highlighter.py.
json
JSON pretty printing — equivalent to Rich’s json.py.
layout
Layout — split-pane layout system. Equivalent to Rich’s layout.py.
live
Live — auto-updating display. Equivalent to Rich’s live.py.
logging
Logging integration — equivalent to Rich’s logging.py.
markdown
Markdown rendering — equivalent to Rich’s markdown.py.
markup
Console markup parser — equivalent to Rich’s markup.py.
measure
Measurement system — equivalent to Rich’s measure.py.
padding
Padding — draw space around content. Equivalent to Rich’s padding.py.
panel
Panel — a bordered container. Equivalent to Rich’s panel.py.
progress
Progress bars and task tracking. Equivalent to Rich’s progress.py and progress_bar.py.
progress_columns
Progress column types — equivalent to Python Rich’s progress column system (SpinnerColumn, BarColumn, TextColumn, etc.).
prompt
Interactive prompts — equivalent to Rich’s rich/prompt.py.
ratio
Ratio-based space distribution — equivalent to Rich’s _ratio.py.
rule
Rule — horizontal rule / divider. Equivalent to Rich’s rule.py.
screen
Screen — full-screen renderable and alternate screen buffer.
segment
Segment — styled text unit. Equivalent to Rich’s segment.py.
spinner
Spinner — animated spinner. Equivalent to Rich’s spinner.py.
status
Status — status message with spinner. Equivalent to Rich’s status.py.
style
Text style — equivalent to Rich’s style.py.
syntax
Syntax highlighting — equivalent to Rich’s syntax.py.
table
Table — tabular data with columns. Equivalent to Rich’s table.py.
text
Text with spans — equivalent to Rich’s text.py.
theme
Theme system — equivalent to Rich’s theme.py.
traceback
Traceback – exception traceback rendering. Equivalent to Rich’s traceback.py.
tree
Tree — hierarchical tree rendering. Equivalent to Rich’s tree.py.