pub fn terminal_safe_text(value: &str) -> String {
    value
        .chars()
        .filter(|character| matches!(character, '\n' | '\r' | '\t') || !character.is_control())
        .collect()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn terminal_safe_text_strips_control_sequences() {
        assert_eq!(
            terminal_safe_text("Title\x1b]52;c;secret\x07\nNext\tLine"),
            "Title]52;c;secret\nNext\tLine"
        );
    }
}
