Skip to main content

render_with_observers

Function render_with_observers 

Source
pub fn render_with_observers(
    items: &[LineItem],
    ctx: &DataContext,
    terminal_width: u16,
    observers: &mut LayoutObservers<'_>,
    theme: &Theme,
    capability: Capability,
    hyperlinks: bool,
) -> String
Expand description

Same as render but routes segment render-error diagnostics (and LayoutDecision events, when an observer is attached) through observers, 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.