r3blansicolor crate

What does it do?

Rust crate to generate formatted ANSI 256 (8-bit) and truecolor (24-bit) color output to stdout. On macOS, the default Terminal.app does not support truecolor, so ANSI 256 colors are used instead.

This crate only has a single dependency which is the concolor-query crate. It is used to determine whether the terminal supports truecolor or ANSI 256 colors, etc. Both this crate and the concolor-query crate are licensed under the Apache 2.0 license.

Here's a screenshot of running the main example:

Screenshot

How to use it?

The main struct that we have to consider is AnsiStyledText. It has two fields:

Here's an example.

rust AnsiStyledText { text: "Print a formatted (bold, italic, underline) string w/ ANSI color codes.", style: &[ Style::Bold, Style::Italic, Style::Underline, Style::Foreground(Color::Rgb(50, 50, 50)), Style::Background(Color::Rgb(100, 200, 1)), ], } .println();

Please a look at the main example to get a better idea of how to use this crate.

Build, run, test tasks

Fish scripts are provided to facilitate the above tasks. Here is a list of them.

References