ratagrid 0.3.1

A mouse-first interactive data grid for Ratatui
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Shared plain-text policy for terminal output, search and clipboard payloads.
use std::borrow::Cow;

pub(crate) fn is_unsafe(c: char) -> bool {
    c.is_control()
        || matches!(c, '\u{061c}' | '\u{200e}' | '\u{200f}' | '\u{202a}'..='\u{202e}' | '\u{2066}'..='\u{2069}')
}

pub(crate) fn sanitize(text: &str) -> Cow<'_, str> {
    if text.chars().any(is_unsafe) {
        Cow::Owned(text.chars().filter(|&c| !is_unsafe(c)).collect())
    } else {
        Cow::Borrowed(text)
    }
}