Crate ansi_to_tui[−][src]
Parses a Vec<u8>
as an byte sequence with ansi colors to
tui::text::Text
.
Invalid ansi colors / sequences will be ignored.
Supported features
- UTF-8 using
String::from_utf8
orsimdutf8
. - Most stuff like Bold / Italic / Underline /
Striketrhough. - Supports 4-bit color palletes.
- Supports 8-bit color.
- Supports True color ( RGB / 24-bit color ).
Example
The argument to the function ansi_to_text
implements IntoIterator
so it will be consumed on
use.
use ansi_to_tui::ansi_to_text; let bytes = b"\x1b[38;2;225;192;203mAAAAA\x1b[0m".to_owned().to_vec(); let text = ansi_to_text(bytes).unwrap();
Example parsing from a file.
use ansi_to_tui::ansi_to_text; use std::io::Read; let file = std::fs::File::open("text.ascii"); let mut buffer: Vec<u8> = Vec::new(); let text = ansi_to_text(buffer);
If you want to use simdutf8
instead of String::from_utf8()
for parsing UTF-8 then enable optional feature simd
Enums
AnsiCode | This enum stores most types of ansi escape sequences |
Error | This enum stores the error types |
Functions
ansi_to_text | This functions converts the ascii byte sequence with ansi colors to tui::text::Text type |
ansi_to_text_override_style | Same as ansi_to_text but with a custom override style for the whole text. |