Skip to main content

render_to_runs

Function render_to_runs 

Source
pub fn render_to_runs(
    items: &[LineItem],
    ctx: &DataContext,
    terminal_width: u16,
    observers: &mut LayoutObservers<'_>,
) -> Vec<StyledRun>
Expand description

Render items into a flat StyledRun sequence. One run per surviving segment, plus one run per non-empty surviving separator (in render order). Layout decisions — priority-drop, shrink_to_fit, truncatable reflow, width-bound truncation — match render / render_with_observers exactly; only the emit form differs.

Separator::None contributes no run; it would be an empty-text run with no consumer use. Separator runs carry Style::default; separators inherit no styling from their flanking segments.

Segment render errors and Ok(None) go through observers.warn exactly as in the ANSI path; the run sequence reflects only segments that survived to the layout pass, with separators surviving only between two surviving segments.

When the caller has attached an on_decision callback via LayoutObservers::with_decision, the engine routes a typed LayoutDecision event through it at each of the five emit sites (PriorityDrop, ShrinkApplied, ReflowApplied, WidthBoundUnderMinDrop, WidthBoundOverMaxTruncate). Width-bound events fire during [collect_items_with]; the rest fire inside [apply_layout]’s reflow loop.