Skip to main content

render_with_warn

Function render_with_warn 

Source
pub fn render_with_warn(
    segments: &[Box<dyn Segment>],
    ctx: &DataContext,
    terminal_width: u16,
    warn: &mut dyn FnMut(&str),
    theme: &Theme,
    capability: Capability,
    hyperlinks: bool,
) -> String
Expand description

Same as render but routes segment render-error diagnostics through warn and emits ANSI SGR around each segment per theme and capability. Used by crate::run_with_context so cli_main tests can capture segment errors alongside exit codes while the render path picks up theme colors.

hyperlinks gates OSC 8 emission for runs whose Style.hyperlink is set. Pass true when the terminal advertises OSC 8 support (e.g. via the supports-hyperlinks crate or an explicit user override), false otherwise — capable terminals render the run as a clickable link, others see plain text.

Thin wrapper over render_to_runs + runs_to_ansi; same layout, same bytes. Callers that need the styled-run form (e.g. the TUI preview pane) call render_to_runs directly.