INNER CODE UNIT · Rust

skip_ansi_escape_sequence

sachaos/viddy · src/bytes.rs:51

fn skip_ansi_escape_sequence<I: Iterator<Item = char>>(ch: char, chars: &mut I) -> usize {
    let mut count = 0;
    if ch != CSI.0 {
        return 0; // Nothing to skip here.
    }

    let next = chars.next();
    count += 1;
    if next == Some(CSI.1) {
        // We have found the start of an ANSI escape code, typically
        // used for colored terminal text. We skip until we find a
        // "final byte" in the range 0x40–0x7E.
        for ch in chars {
            count += 1;
            if ANSI_FINAL_BYTE.contains(&ch) {
                break;
            }
        }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…