Skip to main content

clean_line

Function clean_line 

Source
pub fn clean_line(
    raw: &str,
    state: &mut SgrState,
    palette: Option<&AnsiPalette>,
) -> CleanLine
Expand description

Strip escape sequences out of one line, returning the clean text and its spans. state is updated in place so the next line continues where this one left off.

Spans are byte offsets into text (the clean output), because that is what lands in the buffer and what the renderer indexes.

A bare \r that is not ending the line restarts it: everything before the carriage return is discarded, along with its spans. That is what a terminal does with cargo’s progress redraw, and without it a build streams every intermediate Compiling … state concatenated into one unreadable row.