rusty_rich/lib.rs
1//! # rusty-rich
2//!
3//! **Rich text and beautiful formatting in the terminal** — a Rust port of
4//! the popular Python [Rich](https://github.com/Textualize/rich) library.
5//!
6//! Bring stunning terminal output to your Rust CLI tools with minimal code.
7//! Supports TrueColor/256/16-color terminals, produces ANSI escape sequences,
8//! and exports to HTML and SVG.
9//!
10//! ## Quick Start
11//!
12//! ```rust,no_run
13//! use rusty_rich::{Console, Panel, Table, Column, Style, Color};
14//!
15//! let mut console = Console::new();
16//!
17//! // Inline markup
18//! console.print_str("[bold green]Hello, [red]World![/red][/bold green]");
19//!
20//! // Panel with title
21//! let panel = Panel::new("Content inside a box")
22//! .title("My Panel")
23//! .border_style(Style::new().color(Color::parse("cyan").unwrap()));
24//! console.println(&panel);
25//!
26//! // Table with columns
27//! let mut table = Table::new();
28//! table.add_column(Column::new("Name"));
29//! table.add_column(Column::new("Age"));
30//! table.add_row_str("Alice", "30");
31//! table.add_row_str("Bob", "25");
32//! console.println(&table);
33//! ```
34//!
35//! ## Feature Overview
36//!
37//! ### Core Primitives
38//!
39//! | Module | Provides |
40//! |--------|----------|
41//! | [`color`] | 256 named colors, TrueColor/8-bit/Standard, RGB↔ANSI conversion, blending |
42//! | [`style`] | 13 text attributes (bold/italic/underline/strike/…), links, style combination |
43//! | [`segment`] | Smallest output unit: text + style + control codes; 9 utility functions |
44//! | [`text`] | [`Text`] with [`Span`]-based styling, markup parsing, truncation, wrapping |
45//! | [`cells`] | Unicode cell width utilities for CJK and emoji |
46//! | [`measure`] | Width measurement protocol for layout negotiation |
47//! | [`align`] | Horizontal (Left/Center/Right/Full) and vertical (Top/Middle/Bottom) alignment |
48//! | [`markup`] | BBCode-like parser: `[bold red]text[/bold red]` |
49//! | [`highlighter`] | Regex-based and repr-style text highlighters |
50//! | [`ratio`] | Proportional space distribution with minimums and maximums |
51//!
52//! ### Console & Rendering
53//!
54//! | Module | Provides |
55//! |--------|----------|
56//! | [`console`] | Central rendering engine: [`Console`], [`Renderable`] trait, [`RenderResult`], [`Group`] |
57//! | [`theme`] | 170+ named style maps with stack-based inheritance via [`Theme`] and `ThemeStack` |
58//! | [`screen`] | Full-screen alt-buffer via [`Screen`], [`ScreenContext`] RAII guard, [`ScreenUpdate`] |
59//!
60//! ### Layout & Renderables
61//!
62//! | Module | Provides |
63//! |--------|----------|
64//! | [`panel`] | Bordered container with title, subtitle, 17 box styles |
65//! | [`table`] | Tabular data with [`Column`], [`Cell`], colspan/rowspan, sections, 17 border styles |
66//! | [`tree`] | Hierarchical tree with Unicode/ASCII guides |
67//! | [`rule`] | Horizontal divider with optional centered title |
68//! | [`columns`] | Side-by-side column layout with equal/expand options |
69//! | [`layout`] | Recursive split-pane layout with ratio sizing and named regions |
70//! | [`padding`] | CSS-style padding (1–4 values) |
71//! | [`box_drawing`] | 17 box/border styles from ASCII to heavy double-lines |
72//!
73//! ### Dynamic Components
74//!
75//! | Module | Provides |
76//! |--------|----------|
77//! | [`progress`] | Multi-task progress bars, [`TrackIterator`] for tracking iterables, [`ProgressFile`] |
78//! | [`progress_columns`] | 11 column types: bar, text, spinner, time, file size, transfer speed, etc. |
79//! | [`spinner`] | 55 animated spinners with case-insensitive name lookup via [`get_spinner`] |
80//! | [`status`] | Animated spinner + status message with in-place refresh |
81//! | [`live`] | Auto-updating region with alt-screen support and [`LiveWriter`] for output capture |
82//!
83//! ### Content Rendering
84//!
85//! | Module | Provides |
86//! |--------|----------|
87//! | [`syntax`] | Syntax highlighting via syntect (100+ languages) |
88//! | [`markdown`] | Markdown rendering via pulldown-cmark: headings, code, lists, blockquotes, tables |
89//! | [`json`] | Pretty-printed JSON with syntax-highlighted keys/values |
90//! | [`logging`] | [`RichHandler`] for the `log` crate with colored levels |
91//! | [`traceback`] | Rich exception tracebacks with locals, source code, frame suppression, panic hook |
92//!
93//! ### Interactive
94//!
95//! | Module | Provides |
96//! |--------|----------|
97//! | [`prompt`] | 5 prompt types: [`Prompt`], [`IntPrompt`], [`FloatPrompt`], [`Confirm`], [`Select`] |
98//!
99//! ### Export
100//!
101//! | Module | Provides |
102//! |--------|----------|
103//! | [`export`] | HTML, SVG, and text export with 4 preset terminal themes |
104//!
105//! ## Examples by Use Case
106//!
107//! ### Markdown with Tables
108//!
109//! ```rust,no_run
110//! use rusty_rich::{render_markdown, Console};
111//!
112//! let md = render_markdown("# Report\n\n| Item | Qty |\n|------|-----|\n| A | 10 |\n| B | 5 |");
113//! Console::new().println(&md);
114//! ```
115//!
116//! ### Progress Bars
117//!
118//! ```rust,no_run
119//! use rusty_rich::Progress;
120//!
121//! let mut progress = Progress::new();
122//! let task = progress.add_task("Downloading...", Some(100.0));
123//! // … in a loop: progress.update(task, n as f64);
124//! println!("{}", progress.render(80));
125//! ```
126//!
127//! ### Interactive Prompts
128//!
129//! ```rust,no_run
130//! use rusty_rich::{Prompt, Confirm, IntPrompt, Select};
131//!
132//! let name = Prompt::ask_with("Enter name").unwrap();
133//! let password = Prompt::new("Password").password(true).ask().unwrap();
134//! let ok = Confirm::ask_with("Continue?", true).unwrap();
135//! let age = IntPrompt::ask_with("Age").unwrap();
136//! let choice = Select::new("Pick").choice("Red", "r").choice("Blue", "b").ask().unwrap();
137//! ```
138//!
139//! ### Live Display with Writer
140//!
141//! ```rust,no_run
142//! use rusty_rich::{Live, LiveWriter, Panel};
143//! use std::io::Write;
144//!
145//! let mut live = Live::new(Panel::new("Starting...").title("Status"));
146//! let mut writer = live.create_writer();
147//! live.start().unwrap();
148//!
149//! writeln!(writer, "Processing items...").unwrap();
150//! live.update(Panel::new("Done!").title("Status")).unwrap();
151//! live.stop().unwrap();
152//! ```
153//!
154//! ### Traceback Panic Hook
155//!
156//! ```rust,no_run
157//! use rusty_rich::traceback;
158//!
159//! // Install a global panic hook for rich tracebacks
160//! traceback::install();
161//!
162//! // Or render manually
163//! // let tb = Traceback::from_exception("MyError", "details", frames)
164//! // .show_locals(true)
165//! // .max_frames(5);
166//! ```
167//!
168//! ### Full-Screen Applications
169//!
170//! ```rust,no_run
171//! use rusty_rich::{Console, Screen};
172//!
173//! let mut console = Console::new();
174//! let mut screen = console.screen();
175//! screen.enter(); // enters alt screen
176//! // … render content …
177//! screen.exit(); // restores terminal
178//! ```
179//!
180//! ### HTML & SVG Export
181//!
182//! ```rust,no_run
183//! use rusty_rich::{export_svg, ExportSvgOptions};
184//!
185//! let svg = export_svg(ExportSvgOptions::default());
186//! std::fs::write("output.svg", svg).unwrap();
187//! ```
188//!
189//! ## Color & Style System
190//!
191//! 256 named colors via [`Color::parse`], plus hex/RGB constructors with automatic downgrade:
192//!
193//! ```rust
194//! use rusty_rich::{Color, Style};
195//!
196//! // Named colors — 256 ANSI palette
197//! let c = Color::parse("hot_pink").unwrap();
198//! let c = Color::parse("steel_blue").unwrap();
199//!
200//! // Hex / RGB
201//! let c = Color::from_hex("#FF6600").unwrap();
202//! let c = Color::from_rgb(100, 200, 50);
203//!
204//! // Style with 13 attributes + links
205//! let s = Style::new()
206//! .color(Color::parse("cyan").unwrap())
207//! .bgcolor(Color::parse("#1E1E2E").unwrap())
208//! .bold(true)
209//! .italic(true)
210//! .underline(true)
211//! .link("https://example.com");
212//! ```
213//!
214//! ## Box Styles (17 built-in)
215//!
216//! ```text
217//! BOX_ROUNDED ╭─╮ │ │ ╰─╯ BOX_HEAVY ┏━┓ ┃ ┃ ┗━┛
218//! BOX_SQUARE ┌─┐ │ │ └─┘ BOX_DOUBLE ╔═╗ ║ ║ ╚═╝
219//! BOX_ASCII +-+ | | +-+ BOX_MARKDOWN | Table style
220//! ```
221//!
222//! ## Comparison with Python Rich
223//!
224//! rusty-rich achieves ~88% feature parity with Python Rich 14.x (475+ tests).
225//! ## Feature Flags
226//!
227//! No feature flags — all functionality is included by default. Dependencies are
228//! carefully chosen for minimal compile times.
229//!
230//! ## Crate Organization
231//!
232//! The crate is organized into 5 module groups:
233//!
234//! - **Core** ([`color`], [`style`], [`segment`], [`text`], [`theme`],
235//! [`measure`], [`align`], [`markup`], [`ratio`], [`highlighter`],
236//! [`cells`], [`console`], [`box_drawing`])
237//! - **Renderables** ([`panel`], [`table`], [`tree`], [`rule`],
238//! [`padding`], [`columns`], [`layout`])
239//! - **Dynamic** ([`prompt`], [`progress`], [`progress_columns`],
240//! [`spinner`], [`status`], [`live`], [`screen`])
241//! - **Content** ([`syntax`], [`markdown`], [`json`], [`logging`],
242//! [`traceback`])
243//! - **Export** ([`export`])
244//!
245//! Most commonly-used types are re-exported at the crate root for convenience.
246
247// -- Core modules -----------------------------------------------------------
248
249/// Unicode cell width utilities for CJK and emoji text measurement.
250pub mod cells;
251/// 256 named ANSI colors, TrueColor/8-bit/Standard, RGB↔ANSI conversion, blending.
252pub mod color;
253/// 13 text attributes (bold, italic, underline, …), links, style combination.
254pub mod style;
255/// Styled text unit with control codes — the smallest rendering primitive.
256pub mod segment;
257/// Styled text with `Span`-based markup and text manipulation utilities.
258pub mod text;
259/// Named style maps (170+ defaults) with stack-based inheritance.
260pub mod theme;
261/// Width measurement protocol for layout negotiation between renderables.
262pub mod measure;
263/// Horizontal and vertical alignment wrappers for renderables.
264pub mod align;
265/// BBCode-like markup parser: `[bold red]text[/bold red]`.
266pub mod markup;
267/// Proportional space distribution algorithms with minimums and maximums.
268pub mod ratio;
269/// Regex-based and repr-style text highlighters.
270pub mod highlighter;
271/// Central rendering engine — Console, Renderable trait, capture, export.
272pub mod console;
273/// 17 box/border drawing styles from ASCII to heavy Unicode double-lines.
274pub mod box_drawing;
275
276// -- Renderable components --------------------------------------------------
277
278/// Bordered container with optional title, subtitle, and padding.
279pub mod panel;
280/// Tabular data with column definitions, colspan/rowspan, sections, and 17 border styles.
281pub mod table;
282/// Hierarchical tree with Unicode or ASCII branch guides.
283pub mod tree;
284/// Horizontal divider line with optional centered, left-, or right-aligned title.
285pub mod rule;
286/// CSS-style padding (1–4 side values) around any renderable.
287pub mod padding;
288/// Side-by-side column layout with equal-width and expand options.
289pub mod columns;
290/// Recursive split-pane layout engine with ratio sizing and named regions.
291pub mod layout;
292
293// -- Dynamic / animated components ------------------------------------------
294
295/// Interactive prompts: string, int, float, confirm, select with password mode.
296pub mod prompt;
297/// Multi-task progress bars with configurable column layouts and iterable tracking.
298pub mod progress;
299/// 11 progress column types: bar, text, spinner, time, file size, transfer speed.
300pub mod progress_columns;
301/// 55 animated spinners with case-insensitive name-based lookup.
302pub mod spinner;
303/// Animated spinner with status message, in-place refresh via carriage return.
304pub mod status;
305/// Auto-updating display region with stdout/stderr capture via `LiveWriter`.
306pub mod live;
307/// Full-screen rendering, alternate screen buffer, and screen update helpers.
308pub mod screen;
309
310// -- Content rendering ------------------------------------------------------
311
312/// Syntax highlighting via syntect (100+ languages, Sublime Text theme support).
313pub mod syntax;
314/// Markdown rendering via pulldown-cmark: headings, code, lists, blockquotes, tables.
315pub mod markdown;
316/// Pretty-printed JSON with syntax-highlighted keys, strings, numbers, booleans.
317pub mod json;
318/// `RichHandler` for the `log` crate — colored log levels with file/line info.
319pub mod logging;
320/// Rich exception tracebacks with source code, locals, frame suppression, panic hook.
321pub mod traceback;
322
323// -- Additional renderables --------------------------------------------------
324
325/// Pretty-printing for Rust data structures with tree traversal and syntax highlighting.
326pub mod pretty;
327/// Emoji shortcode replacement — `:smile:` → 😊.
328pub mod emoji;
329/// System pager integration — pipes output to `less` or `$PAGER`.
330pub mod pager;
331/// Constrain the maximum width of any renderable.
332pub mod constrain;
333/// Pre-styled renderable wrapper — applies a style to all output of a renderable.
334pub mod styled;
335/// Horizontal bar chart with labels, colors, and auto-scaling.
336pub mod bar;
337/// Human-readable file size and transfer speed formatting.
338pub mod filesize;
339/// Container renderables — `Lines` and `Renderables` for grouping output.
340pub mod containers;
341/// Color palette generation — gradients, rainbows, monochrome ramps.
342pub mod palette;
343/// Error diagnostics — rich-formatted error reporting.
344pub mod diagnose;
345/// ANSI escape sequence decoder — parse ANSI text into styled `Text`.
346pub mod ansi;
347/// Variable scope inspection — render name→value mappings as tables.
348pub mod scope;
349/// Auto-refreshing file content display — watches file for changes.
350pub mod file_proxy;
351/// Rich representation protocol — customizable pretty-printing for Rust types.
352pub mod repr;
353/// Terminal control sequence generation — cursor movement, screen, titles, bells.
354pub mod control;
355/// Object introspection — structured display of type info, attributes, and methods.
356pub mod inspect;
357/// Standalone log record formatter — renders log records as Rich tables.
358pub mod log_render;
359
360// -- Export -----------------------------------------------------------------
361
362/// HTML, SVG, and plain-text export with 4 preset terminal color themes.
363pub mod export;
364
365// -- Re-exports for convenience ---------------------------------------------
366// Most commonly-used types are re-exported at the crate root so you can write
367// `use rusty_rich::Panel` instead of `use rusty_rich::panel::Panel`.
368
369// -- Core types --------------------------------------------------------------
370
371/// 256 named colors + TrueColor/8-bit support with automatic downgrade.
372pub use color::Color;
373/// What level of color the terminal supports (Standard, EightBit, TrueColor).
374pub use color::ColorSystem;
375/// How a [`Color`] is stored internally (Default, Standard, EightBit, TrueColor).
376pub use color::ColorType;
377
378/// Terminal text style — 13 attributes, fg/bg color, links, and combination logic.
379pub use style::Style;
380/// Stack of styles for nested markup — push/pop to track inheritance.
381pub use style::StyleStack;
382
383/// A piece of styled text with optional control codes — the smallest renderable unit.
384pub use segment::Segment;
385/// A collection of [`Segment`]s with convenience methods.
386pub use segment::Segments;
387
388/// Styled text with `Span` regions, markup support, and text manipulation methods.
389pub use text::Text;
390/// A styled region within a [`Text`] — defined by start/end offsets and a [`Style`].
391pub use text::Span;
392
393/// A named style map — look up styles by key (e.g. `"repr.number"`, `"markdown.h1"`).
394pub use theme::Theme;
395
396/// Horizontal alignment: `Left`, `Center`, `Right`, or `Full` (justified).
397pub use align::AlignMethod;
398/// Vertical alignment: `Top`, `Middle`, or `Bottom`.
399pub use align::VerticalAlignMethod;
400/// Wraps a renderable with horizontal and vertical alignment.
401pub use align::Align;
402
403/// Width measurement (minimum, maximum) returned by the layout protocol.
404pub use measure::Measurement;
405
406// -- Console -----------------------------------------------------------------
407
408/// The central rendering engine — prints renderables, manages terminal state.
409pub use console::Console;
410/// Options passed to renderables during the rendering pass (width, height, overflow, etc.).
411pub use console::ConsoleOptions;
412/// Terminal size in character cells (width × height).
413pub use console::ConsoleDimensions;
414/// How text overflow is handled: `Fold`, `Crop`, `Ellipsis`, or `Ignore`.
415pub use console::OverflowMethod;
416/// Trait for types that can be rendered to terminal output.
417pub use console::Renderable;
418/// The result of rendering: lines of segments plus nested renderable items.
419pub use console::RenderResult;
420/// Either a [`Segment`] or a nested renderable — produced during rendering.
421pub use console::RenderItem;
422/// A type-erased, cloneable wrapper around any [`Renderable`].
423pub use console::DynRenderable;
424/// Renders multiple renderables sequentially as one unit.
425pub use console::Group;
426/// Returns a mutex-guarded reference to the global (singleton) [`Console`].
427pub use console::get_console;
428/// Drop-in replacement for `println!` that uses the global console.
429pub use console::print_objects as print;
430/// Print a markup string (e.g. `"[bold red]text[/bold red]"`) via the global console.
431pub use console::print_str;
432/// Pretty-print a `serde_json::Value` via the global console.
433pub use console::print_json_val as print_json;
434
435// -- Box drawing -------------------------------------------------------------
436
437/// A box/border style defined by 32 corner and edge characters.
438pub use box_drawing::BoxStyle;
439#[doc(no_inline)]
440pub use box_drawing::{
441 BOX_ROUNDED, BOX_SQUARE, BOX_HEAVY, BOX_HEAVY_EDGE, BOX_HEAVY_HEAD,
442 BOX_DOUBLE, BOX_DOUBLE_EDGE, BOX_SIMPLE, BOX_SIMPLE_HEAVY,
443 BOX_MINIMAL, BOX_MINIMAL_HEAVY, BOX_ASCII, BOX_ASCII2,
444 BOX_SQUARE_DOUBLE_HEAD, BOX_MINIMAL_DOUBLE_HEAD, BOX_SIMPLE_HEAD,
445 BOX_ASCII_DOUBLE_HEAD,
446};
447
448// -- Renderables -------------------------------------------------------------
449
450/// A bordered container with optional title, subtitle, border style, and padding.
451pub use panel::Panel;
452/// Tabular data widget with headers, footers, colspan/rowspan, and 17 box styles.
453pub use table::Table;
454/// A column definition for a [`Table`] — header, footer, width, alignment, ratio.
455pub use table::Column;
456/// A table cell with optional style, colspan, and rowspan.
457pub use table::Cell;
458
459/// A hierarchical tree with Unicode or ASCII branch guides.
460pub use tree::Tree;
461/// A horizontal divider line with optional centered, left-, or right-aligned title.
462pub use rule::Rule;
463/// CSS-style padding (1–4 side values) around any renderable.
464pub use padding::Padding;
465/// Padding dimension specification: 1, 2, or 4 values (like CSS).
466pub use padding::PaddingDimensions;
467/// Side-by-side column layout with equal-width and expand options.
468pub use columns::Columns;
469/// Recursive split-pane layout engine with ratio sizing.
470pub use layout::Layout;
471/// A node in the layout tree — either a `Split` or a `Leaf`.
472pub use layout::LayoutNode;
473/// Layout split direction: `Horizontal` (columns) or `Vertical` (rows).
474pub use layout::Direction;
475/// A screen region defined by x, y, width, and height.
476pub use layout::Region;
477
478// -- Progress ----------------------------------------------------------------
479
480/// Multi-task progress display with configurable column layouts.
481pub use progress::Progress;
482/// A single progress bar — renders as a filled bar with percentage.
483pub use progress::ProgressBar;
484/// A file wrapper that tracks read progress via a task in [`Progress`].
485pub use progress::ProgressFile;
486/// A tracked task within a [`Progress`] display — holds description, total, completed.
487pub use progress::Task;
488/// An iterator wrapper that automatically advances a progress task on each iteration.
489pub use progress::TrackIterator;
490
491/// Trait for progress column types — renders one cell per task.
492pub use progress_columns::ProgressColumn;
493/// Shows a progress bar for each task.
494pub use progress_columns::BarColumn;
495/// Shows "completed/total" as file sizes with a separator.
496pub use progress_columns::DownloadColumn;
497/// Shows the completed file size for each task.
498pub use progress_columns::FileSizeColumn;
499/// Shows "completed/total" with raw numbers.
500pub use progress_columns::MofNCompleteColumn;
501/// Shows a spinner (animated during active, checkmark when finished).
502pub use progress_columns::SpinnerColumn;
503/// Shows the completion percentage for each task.
504pub use progress_columns::TaskProgressColumn;
505/// Shows a formatted text field from task metadata.
506pub use progress_columns::TextColumn;
507/// Shows the elapsed time for each task.
508pub use progress_columns::TimeElapsedColumn;
509/// Shows the estimated remaining time for each task.
510pub use progress_columns::TimeRemainingColumn;
511/// Shows the total file size for each task.
512pub use progress_columns::TotalFileSizeColumn;
513/// Shows the transfer speed for each task.
514pub use progress_columns::TransferSpeedColumn;
515/// Format a byte count as a human-readable size string.
516pub use progress_columns::format_size;
517/// Format a bytes-per-second rate as a human-readable speed string.
518pub use progress_columns::format_speed;
519
520// -- Spinners ----------------------------------------------------------------
521
522/// An animated spinner — frames, interval, text, and style.
523pub use spinner::Spinner;
524/// A predefined spinner animation: slice of frame strings + frame interval.
525pub use spinner::SpinnerFrames;
526/// The default spinner (dots).
527pub use spinner::DEFAULT_SPINNER;
528/// Look up a spinner by name (case-insensitive).
529pub use spinner::get_spinner;
530/// All registered spinners as a slice of (name, spinner) pairs.
531pub use spinner::SPINNERS;
532#[doc(no_inline)]
533pub use spinner::{
534 SPINNER_ARC, SPINNER_ARROW, SPINNER_ARROW2, SPINNER_ARROW3,
535 SPINNER_BOUNCING_BAR, SPINNER_BOUNCING_BALL,
536 SPINNER_CHRISTMAS, SPINNER_CIRCLE, SPINNER_CLOCK,
537 SPINNER_EARTH, SPINNER_GRENADE,
538 SPINNER_GROW_HORIZONTAL, SPINNER_GROW_VERTICAL,
539 SPINNER_HAMBURGER, SPINNER_HEARTS, SPINNER_MONKEY,
540 SPINNER_NOISE, SPINNER_PONG, SPINNER_RUNNER, SPINNER_SHARK,
541 SPINNER_TOGGLE, SPINNER_TRIANGLE, SPINNER_VERTICAL_BARS,
542};
543
544// -- Prompts -----------------------------------------------------------------
545
546/// String input prompt with optional password mode and choice validation.
547pub use prompt::Prompt;
548/// Base configuration shared by all prompt types.
549pub use prompt::PromptBase;
550/// Error type for prompt operations: invalid response, I/O error, or cancellation.
551pub use prompt::PromptError;
552/// Integer input prompt — loops until a valid i64 is entered.
553pub use prompt::IntPrompt;
554/// Floating-point input prompt — loops until a valid f64 is entered.
555pub use prompt::FloatPrompt;
556/// Yes/no confirmation prompt with configurable default answer.
557pub use prompt::Confirm;
558/// Numbered-choice selection prompt — user picks from a list by number.
559pub use prompt::Select;
560
561/// An animated spinner with a status message, refreshed in-place via carriage return.
562pub use status::Status;
563
564/// Auto-updating display region — refreshs content at a configurable rate.
565pub use live::Live;
566/// A writer that captures output for display within a [`Live`] region.
567pub use live::LiveWriter;
568
569/// Full-screen renderable — fills the terminal and crops/pads to fit.
570pub use screen::Screen;
571/// RAII guard for the alternate screen buffer — enters on creation, exits on drop.
572pub use screen::ScreenContext;
573/// Wraps a renderable for screen updates at a specific x/y offset.
574pub use screen::ScreenUpdate;
575
576// -- Content rendering -------------------------------------------------------
577
578/// Syntax-highlighted code block — language, theme, line numbers, word wrap.
579pub use syntax::Syntax;
580/// Render a markdown string into a [`MarkdownRender`].
581pub use markdown::render_markdown;
582/// A markdown document renderable — headings, code, lists, blockquotes, tables.
583pub use markdown::MarkdownRender;
584/// Render a `serde_json::Value` into a [`JsonRender`].
585pub use json::render_json;
586/// Pretty-printed, syntax-highlighted JSON renderable.
587pub use json::JsonRender;
588
589/// A logging handler for the `log` crate — renders records with Rich styling.
590pub use logging::RichHandler;
591
592/// Rich exception traceback — box-drawn, with source code context and locals.
593pub use traceback::Traceback;
594/// A chain of exceptions — one or more [`Stack`]s of [`Frame`]s.
595pub use traceback::Trace;
596/// One exception level in a traceback — type, value, frames, notes.
597pub use traceback::Stack;
598/// A single stack frame — file, line number, function name, source line, locals.
599pub use traceback::Frame;
600/// Install a global panic hook that renders Rich-formatted tracebacks to stderr.
601pub use traceback::install;
602
603/// Trait for text highlighters — takes a [`Text`] and returns a styled [`Text`].
604pub use highlighter::Highlighter;
605/// Highlights Python-repr-like output: URLs, numbers, paths, quoted strings.
606pub use highlighter::ReprHighlighter;
607/// A no-op highlighter that returns text unchanged.
608pub use highlighter::NullHighlighter;
609/// Highlights text using regex patterns mapped to styles.
610pub use highlighter::RegexHighlighter;
611
612// -- Export ------------------------------------------------------------------
613
614/// Export rendered output as a full HTML document.
615pub use export::export_html;
616/// Export rendered output as HTML and save to a file.
617pub use export::save_html;
618/// Options for HTML export: font, font size, line height, theme, code styling.
619pub use export::ExportHtmlOptions;
620/// Export rendered output as an SVG document with terminal chrome.
621pub use export::export_svg;
622/// Export rendered output as SVG and save to a file.
623pub use export::save_svg;
624/// Options for SVG export: font, font size, theme, dimensions, code styling.
625pub use export::ExportSvgOptions;
626/// Export rendered output as plain text (optionally strip ANSI escapes).
627pub use export::export_text;
628/// Export rendered output as plain text and save to a file.
629pub use export::save_text;
630/// Options for text export: text content and ANSI strip flag.
631pub use export::ExportTextOptions;
632/// A terminal color theme for HTML/SVG export (background, foreground, ANSI palette).
633pub use export::ExportTheme;
634/// Monokai export theme.
635pub use export::EXPORT_THEME_MONOKAI;
636/// Dimmed Monokai export theme.
637pub use export::EXPORT_THEME_DIMMED_MONOKAI;
638/// Night Owlish export theme.
639pub use export::EXPORT_THEME_NIGHT_OWLISH;
640/// SVG-optimized export theme.
641pub use export::EXPORT_THEME_SVG;
642/// Convert segments to HTML spans with inline CSS.
643pub use export::segments_to_html;
644/// Escape text for safe HTML embedding.
645pub use export::escape_html;
646/// Strip ANSI escape sequences from a string.
647pub use export::strip_ansi_escapes;
648/// HTML document template string.
649pub use export::CONSOLE_HTML_FORMAT;
650/// SVG document template string.
651pub use export::CONSOLE_SVG_FORMAT;
652
653/// Parse a BBCode-like markup string and return a styled [`Text`].
654pub use markup::render as render_markup;
655/// Escape square brackets in a string so they are not interpreted as markup tags.
656pub use markup::escape as escape_markup;
657
658// -- New modules (Phase 2 additions) ------------------------------------------
659
660// Pretty printing
661pub use pretty::Pretty;
662pub use pretty::Node as PrettyNode;
663pub use pretty::pprint;
664pub use pretty::pretty_repr;
665pub use pretty::traverse;
666pub use pretty::install as pretty_install;
667
668// Emoji
669pub use emoji::Emoji;
670pub use emoji::NoEmoji;
671
672// Pager
673pub use pager::Pager;
674pub use pager::PagerContext;
675pub use pager::SystemPager;
676
677// Constrain
678pub use constrain::Constrain;
679
680// Styled
681pub use styled::Styled;
682
683// Bar chart
684pub use bar::Bar;
685pub use bar::BarChart;
686
687// File size
688pub use filesize::format_size as format_file_size;
689pub use filesize::format_speed as format_transfer_speed;
690pub use filesize::pick_unit_and_suffix;
691
692// Containers
693pub use containers::Lines;
694pub use containers::Renderables;
695
696// Palette
697pub use palette::Palette;
698
699// Diagnose
700pub use diagnose::report;
701pub use diagnose::diagnose;
702
703// ANSI decoder
704pub use ansi::AnsiDecoder;
705
706// Scope
707pub use scope::render_scope;
708pub use scope::scope_summary;
709
710// File proxy
711pub use file_proxy::FileProxy;
712
713// Repr protocol
714pub use repr::RichRepr;
715pub use repr::auto as repr_auto;
716pub use repr::rich_repr;
717pub use repr::ReprOptions;
718pub use repr::ReprError;
719
720// Syntax additional exports
721pub use syntax::SyntaxTheme;
722pub use syntax::ANSISyntaxTheme;
723pub use syntax::get_lexer_by_name;
724pub use syntax::get_style_by_name;
725pub use syntax::guess_lexer_for_filename;
726
727// Console additional exports
728pub use console::Capture;
729pub use console::NewLine;
730pub use console::NoChange;
731pub use console::RenderHook;
732pub use console::ThemeContext;
733pub use console::reconfigure;
734
735// Layout additional exports
736pub use layout::Splitter;
737pub use layout::ColumnSplitter;
738pub use layout::RowSplitter;
739pub use layout::NoSplitter;
740
741// Table additional exports
742pub use table::Row;
743
744// Progress additional exports
745pub use progress::RenderableColumn;
746pub use progress::track;
747pub use progress::wrap_file;
748
749// Highlighter additional exports
750pub use highlighter::ISO8601Highlighter;
751pub use highlighter::JSONHighlighter;
752pub use highlighter::PathHighlighter;
753
754// Filesize additional exports
755pub use filesize::decimal as format_size_decimal;
756
757// Control exports
758pub use control::Control;
759pub use control::control_bell;
760pub use control::control_home;
761pub use control::control_clear;
762pub use control::control_move_to;
763pub use control::strip_control_codes;
764pub use control::escape_control_codes;
765
766// Inspect exports
767pub use inspect::Inspect;
768pub use inspect::inspect;
769pub use inspect::inspect_str;
770
771// LogRender exports
772pub use log_render::LogRender;
773pub use log_render::LogRecord;
774pub use log_render::LogTable;