#ansi #color #rgb #no-std #console

no-std ansi_rgb

Colorful console text using ANSI escape sequences

2 unstable releases

0.2.0 Jul 18, 2019
0.1.0 Jul 16, 2019

#163 in Command-line interface

Download history 70/week @ 2021-02-25 31/week @ 2021-03-04 11/week @ 2021-03-11 20/week @ 2021-03-18 28/week @ 2021-03-25 18/week @ 2021-04-01 52/week @ 2021-04-08 34/week @ 2021-04-15 194/week @ 2021-04-22 39/week @ 2021-04-29 12/week @ 2021-05-06 21/week @ 2021-05-13 44/week @ 2021-05-20 48/week @ 2021-05-27 41/week @ 2021-06-03 71/week @ 2021-06-10

199 downloads per month
Used in 6 crates (via arctk)

MIT license

9KB
122 lines

ansi_rgb

Colorful console text using ANSI escape sequences.

crates.io badge
docs.rs badge
Downloads badge

Cargo.toml:

ansi_rgb = "0.2.0"

Foreground colors

use ansi_rgb::{ Foreground, red };

println!("{}", "Hello, world!".fg(red()));

Output:

Red on natural

Background colors

use ansi_rgb::{ Background, red };

println!("{}", "Hello, world!".bg(red()));

Output:

Natural on red

Mix and match

# Cargo.toml
[dependencies]
rbg = "0.8"
use ansi_rgb::{ Foreground, Background };
use rgb::RGB8;

let fg = RGB8::new(123, 231, 111);
let bg = RGB8::new(10, 100, 20);
println!("{}", "Yuck".fg(fg).bg(bg));

Output:

Yuck

Anything formattable

#[derive(Debug)]
struct Foo(i32, i32);

let foo = Foo(1, 2);
println!("{:?}", foo.fg(green()));

Output:

Green foo

Windows users

You need to set your console mode. Otherwise you'll get garbage like this:

[48;2;159;114;0m �[0m

Dependencies

~69KB