#ansi #ascii #tui #parser

ansi-to-tui

A library to convert ansi color coded text into tui::text::Text type from tui-rs library

9 unstable releases (3 breaking)

0.4.1 Sep 28, 2021
0.4.0 Aug 21, 2021
0.3.1 Sep 28, 2021
0.3.0 Jun 1, 2021
0.1.6 Apr 30, 2021

#115 in Text processing

Download history 424/week @ 2021-08-17 280/week @ 2021-08-24 573/week @ 2021-08-31 244/week @ 2021-09-07 679/week @ 2021-09-14 555/week @ 2021-09-21 618/week @ 2021-09-28 1008/week @ 2021-10-05 655/week @ 2021-10-12 1152/week @ 2021-10-19 631/week @ 2021-10-26 1066/week @ 2021-11-02 1028/week @ 2021-11-09 383/week @ 2021-11-16 384/week @ 2021-11-23 1055/week @ 2021-11-30

2,921 downloads per month
Used in 3 crates

MIT license

26KB
495 lines

ansi-to-tui

build downloads

Parse text with ANSI color codes and turn them into tui::text::Text.

Color Supported Examples
24 bit \x1b[38;2;<R>;<G>;<B>m
8 bit \x1b[38;5;<N>m
4 bit \x1b[30..37;40..47m

Example

use ansi_to_tui::ansi_to_text;
use std::io::Read;

let mut input = std::fs::File::open("ascii/text.ascii").unwrap();
let mut buffer: Vec<u8> = Vec::new();
file.read_to_end(&mut buffer);
let output = ansi_to_text(buffer);

Dependencies

~1MB
~21K SLoC