ratatui / ansi-to-tui

Convert ansi colored text to tui::text::Text
https://crates.io/crates/ansi-to-tui
MIT License
57 stars 21 forks source link

Parser stuck on Screen Mode Escapes #16

Closed tbung closed 2 years ago

tbung commented 2 years ago

I know screen mode escapes are not supported and I don't need them to be parsed, however I noticed that the parser gets stuck on screen mode escapes (starting with \x1b[= or \x1b[?). I don't know whether the right handling of these would be to leave them as they are or remove them. Here is a test function that gets stuck:

#[test]
fn test_screen_modes() {
    let bytes: Vec<u8> = b"\x1b[?25hAAABBB".to_vec();
    let output = Ok(Text::from(Spans::from(Span::styled(
        "\x1b[?25hAAABBB",  // or "AAABBB"
        Style::default()
    ))));
    assert_eq!(bytes.into_text(), output);
}
uttarayan21 commented 2 years ago

Can you check #17 and see if that fixes the issue ?

uttarayan21 commented 2 years ago

I removed the escape sequences as I want to give only readable text as output