Skip to main content

parse_ansi_sequence

Function parse_ansi_sequence 

Source
pub fn parse_ansi_sequence(text: &str) -> Option<usize>
Expand description

Parse and determine the length of the ANSI escape sequence at the start of text.

This boundary parser is deliberately conservative: an invalid byte inside a CSI (including a C0 control other than ESC/CAN/SUB) aborts the sequence without consuming that byte. PTY echo suppression uses it to skip escape sequences without swallowing following command text on malformed input. strip_ansi follows anstream’s ECMA-48 state machine instead, where a C0 control inside CSI is executed and the sequence continues; the two parsers therefore disagree on that malformed input by design.