Skip to main content

rich/
lib.rs

1//! # rich
2//!
3//! A **faithful** Rust port of the Python [`rich`](https://github.com/Textualize/rich)
4//! terminal-rendering library. This crate mirrors upstream module-for-module.
5//! Its version is independent SemVer; the upstream release it reflects
6//! (currently `rich` 15.0.0) is recorded in `UPSTREAM.toml`.
7//!
8//! Local features and the plugin registry live in the separate `rich-ext` crate
9//! — do **not** add non-upstream behavior here. See `AGENTS.md`.
10//!
11//! ## What is ported
12//!
13//! - Console and styling: [`console`], [`style`], [`color`], [`segment`],
14//!   [`markup`], [`theme`], [`control`], [`screen`], [`export`].
15//! - Text: [`text`], [`cells`], [`wrap`], [`emoji`], [`highlighter`], [`ansi`].
16//! - Renderables: [`panel`], [`table`], [`tree`], [`layout`], [`columns`],
17//!   [`align`], [`padding`], [`constrain`], [`rule`], [`bar`], [`markdown`],
18//!   [`syntax`], [`json`], [`pretty`], [`traceback`], [`log_render`].
19//! - Live output: [`live`], [`progress`] (with [`track`]), [`progress_bar`],
20//!   [`spinner`], [`status`].
21//! - Input and paging: [`prompt`], [`pager`].
22//! - Extension points: [`protocol`], [`measure`].
23//!
24//! Most modules are partial ports of their upstream counterpart; the per-module
25//! status and parity evidence are in `docs/PORTING.md`.
26
27pub mod align;
28pub mod ansi;
29pub mod bar;
30pub mod r#box;
31mod cell_widths;
32pub mod cells;
33pub mod color;
34mod color_names;
35pub mod columns;
36pub mod console;
37pub mod constrain;
38pub mod containers;
39pub mod control;
40pub mod emoji;
41mod emoji_codes;
42pub mod errors;
43pub mod export;
44pub mod filesize;
45pub mod highlighter;
46pub mod json;
47pub mod layout;
48pub mod live;
49pub mod live_render;
50pub mod log_render;
51#[cfg(feature = "markdown")]
52pub mod markdown;
53#[cfg(feature = "markdown")]
54mod markdown_url;
55pub mod markup;
56pub mod measure;
57pub mod padding;
58pub mod pager;
59pub mod panel;
60pub mod pretty;
61pub mod progress;
62pub mod progress_bar;
63pub mod prompt;
64pub mod protocol;
65pub mod pyformat;
66pub mod ratio;
67pub mod region;
68mod repr_patterns;
69pub mod rule;
70pub mod screen;
71pub mod segment;
72pub mod spinner;
73mod spinner_data;
74pub mod status;
75pub mod style;
76pub mod styled;
77pub mod svg;
78#[cfg(feature = "syntax")]
79pub mod syntax;
80pub mod table;
81pub mod terminal_theme;
82pub mod text;
83pub mod theme;
84pub mod traceback;
85pub mod tree;
86pub mod wrap;
87
88// A small, curated prelude mirroring the most-used names from `rich`'s top level.
89pub use crate::align::{Align, HorizontalAlign, VerticalAlign, VerticalCenter};
90pub use crate::ansi::AnsiDecoder;
91pub use crate::bar::Bar;
92pub use crate::color::{Color, ColorSystem, ColorTriplet};
93pub use crate::columns::Columns;
94pub use crate::console::{
95    Console, ConsoleDimensions, ConsoleOptions, Justify, Overflow, RenderStrOptions, ScreenUpdate,
96    ThemeContext,
97};
98pub use crate::constrain::Constrain;
99pub use crate::control::{Control, ControlType};
100pub use crate::emoji::EmojiVariant;
101pub use crate::errors::{Result, RichError};
102pub use crate::highlighter::{ISO8601Highlighter, RegexHighlighter, ReprHighlighter};
103pub use crate::json::Json;
104pub use crate::layout::{Layout, LayoutRender, Splitter};
105pub use crate::live::{AutoLive, Live, LivePanic};
106pub use crate::live_render::{LiveRender, VerticalOverflow};
107pub use crate::log_render::{level_text, LogLevel, LogRecord, LogRender};
108pub use crate::padding::Padding;
109pub use crate::pager::{Pager, SystemPager};
110pub use crate::panel::Panel;
111pub use crate::pretty::Pretty;
112pub use crate::progress::{
113    track, BarColumn, CustomColumn, CustomProgressColumn, LiveProgress, Progress, ProgressColumn,
114    ProgressReader, SpinnerColumn, Task, TaskId, TaskUpdate, TextColumn, TimeRemainingColumn,
115    Track, TrackStdout,
116};
117pub use crate::progress_bar::ProgressBar;
118pub use crate::protocol::{
119    CodeHighlighter, CodeHighlighting, ConsoleCodeHighlighting, FenceRenderer, HighlightError,
120    HighlightSpan, HighlightedCode, HighlightedLine, Highlighter, LineRenderable, Renderable,
121};
122pub use crate::region::Region;
123pub use crate::rule::Rule;
124pub use crate::screen::Screen;
125pub use crate::segment::Segment;
126pub use crate::spinner::Spinner;
127pub use crate::status::Status;
128pub use crate::style::{Meta, MetaValue, Style, StyleType};
129pub use crate::styled::Styled;
130#[cfg(feature = "syntax")]
131pub use crate::syntax::{Syntax, SyntectHighlighter};
132pub use crate::table::{Cell, ColumnOptions, Table};
133pub use crate::terminal_theme::{
134    TerminalTheme, DEFAULT_TERMINAL_THEME, DIMMED_MONOKAI, MONOKAI, NIGHT_OWLISH, SVG_EXPORT_THEME,
135};
136pub use crate::text::Text;
137pub use crate::theme::Theme;
138pub use crate::traceback::Traceback;
139pub use crate::tree::Tree;