Expand description
Rendering, theming, and structured output helpers. The UI module exists to turn structured output into predictable terminal text, while keeping rendering decisions separate from business logic.
The UI stack has three layers:
formatlowers rows and semantic outputs into a structuredcrate::ui::Document.- the internal renderer turns that document into terminal text using resolved width, color, unicode, and theme settings.
- inline/theme/style helpers provide smaller reusable building blocks for prompts, messages, and rich text fragments.
Keep the distinction between “document shaping” and “terminal rendering” clear. Most bugs become easier to localize once you know which side of that boundary is wrong.
Contract:
- UI code may depend on structured output and render settings
- it should not own config precedence, command execution, or provider I/O
- terminal styling decisions should stay here rather than leaking into the rest of the app
Public API shape:
- semantic payloads like
crate::ui::Documentstay direct and cheap to inspect crate::ui::RenderRuntimeBuilderandcrate::ui::RenderSettingsBuilderare the guided construction path for the heavier rendering configuration surfacescrate::ui::ResolvedRenderSettingsstays a derived value, not another mutable configuration object- guided render configuration follows the crate-wide naming rule:
builder(...)returns*Builder, builder setters usewith_*, andbuild()is the terminal step - callers that only need a stable default baseline can use
crate::ui::RenderSettings::builder,crate::ui::RenderRuntime::builder, orcrate::ui::RenderSettings::test_plain
Re-exports§
pub use chrome::RuledSectionPolicy;pub use chrome::SectionFrameStyle;pub use chrome::SectionRenderContext;pub use chrome::SectionStyleTokens;pub use chrome::render_section_block_with_overrides;pub use chrome::render_section_divider_with_overrides;pub use clipboard::ClipboardError;pub use clipboard::ClipboardService;pub use document::Block;pub use document::CodeBlock;pub use document::Document;pub use document::JsonBlock;pub use document::LineBlock;pub use document::LinePart;pub use document::MregBlock;pub use document::MregEntry;pub use document::MregRow;pub use document::MregValue;pub use document::PanelBlock;pub use document::PanelRules;pub use document::TableAlign;pub use document::TableBlock;pub use document::TableStyle;pub use document::ValueBlock;pub use inline::line_from_inline;pub use inline::parts_from_inline;pub use inline::render_inline;pub use interactive::Interactive;pub use interactive::InteractiveResult;pub use interactive::InteractiveRuntime;pub use interactive::Spinner;pub use messages::GroupedRenderOptions;pub use messages::MessageBuffer;pub use messages::MessageLayout;pub use messages::MessageLevel;pub use messages::UiMessage;pub use messages::adjust_verbosity;pub use style::StyleOverrides;pub use style::StyleToken;pub use theme::DEFAULT_THEME_NAME;pub use theme::ThemeDefinition;pub use theme::ThemeOverrides;pub use theme::ThemePalette;pub use theme::all_themes;pub use theme::available_theme_names;pub use theme::builtin_themes;pub use theme::display_name_from_id;pub use theme::find_builtin_theme;pub use theme::find_theme;pub use theme::is_known_theme;pub use theme::normalize_theme_name;pub use theme::resolve_theme;
Modules§
- chrome
- Reusable section chrome helpers for messages, help, and guide rendering.
- clipboard
- Clipboard integration helpers for copy-safe output flows.
- document
- Structured display blocks used as the boundary between formatting and terminal rendering.
- inline
- Lightweight inline-markup parsing and rendering helpers.
- interactive
- Interactive terminal helpers for prompts and transient status UI.
- messages
- Buffered user-facing messages and their rendering helpers.
- style
- Semantic style tokens and explicit style overrides layered over the theme.
- theme
- Built-in theme definitions and theme lookup helpers.
Structs§
- Help
Chrome Settings - User-configurable settings for rendering CLI output.
- Render
Runtime - Runtime terminal characteristics used when resolving render behavior.
- Render
Runtime Builder - Builder for
RenderRuntime. - Render
Settings - User-configurable settings for rendering CLI output.
- Render
Settings Builder - Builder for
RenderSettings. - Resolved
Render Settings - Fully resolved rendering settings used by the document renderer.
Enums§
- Guide
Default Format - Default output format to use when guide rendering is not explicitly requested.
- Help
Table Chrome - Border style override for help tables.
- Render
Backend - Rendering backend selected for the current output pass.
- Table
Border Style - Border style applied to rendered tables.
- Table
Overflow - Overflow strategy for table cell content.
Functions§
- copy_
output_ to_ clipboard - Copies rendered output to the configured clipboard service.
- copy_
rows_ to_ clipboard - Copies rendered rows to the configured clipboard service.
- render_
document - Renders a document directly with the resolved UI settings.
- render_
document_ for_ copy - Renders a document in plain copy-safe form.
- render_
output - Renders a structured output result using the configured output format.
- render_
output_ for_ copy - Renders an output result in plain copy-safe form.
- render_
rows - Renders rows using the configured output format.
- render_
rows_ for_ copy - Renders rows in plain copy-safe form.