use ansi_to_tui::IntoText;
use ratatui::text::Line;
pub fn strip_ansi_escapes(s: &str) -> String {
let mut result = String::with_capacity(s.len());
let mut chars = s.chars().peekable();
while let Some(c) = chars.next() {
if c == '\x1b' {
if chars.peek() == Some(&'[') {
chars.next(); while let Some(&next) = chars.peek() {
chars.next();
if next.is_ascii_alphabetic() {
break;
}
}
}
} else {
result.push(c);
}
}
result
}
pub fn parse_ansi_to_lines(content: &str) -> Vec<Line<'static>> {
content
.into_text()
.map(|text| text.lines)
.unwrap_or_else(|_| {
content.lines().map(|s| Line::raw(s.to_string())).collect()
})
}
pub use crate::tmux_style::parse_tmux_styles;