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