ansi_rgb/
lib.rs

1#![no_std]
2/*!
3Colorful console text using [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters).
4
5 * Very simple API
6 * Full color (using the [`rgb` crate](https://crates.io/crates/rgb))
7 * Colors all the [formatting traits](https://doc.rust-lang.org/std/fmt/#formatting-traits)
8 * `no_std` compliant
9
10# Foreground colors
11
12```rust
13use ansi_rgb::{ Foreground, red };
14
15println!("{}", "Hello, world!".fg(red()));
16```
17
18Output:
19
20<code style="color: red">Hello, world!</code>
21
22# Background colors
23
24```rust
25use ansi_rgb::{ Background, red };
26
27println!("{}", "Hello, world!".bg(red()));
28```
29
30Output:
31
32<code style="background: red">Hello, world!</code>
33
34# Mix and match
35
36```toml
37# Cargo.toml
38[dependencies]
39rbg = "0.8"
40```
41
42```rust
43use ansi_rgb::{ Foreground, Background };
44use rgb::RGB8;
45
46let fg = RGB8::new(123, 231, 111);
47let bg = RGB8::new(10, 100, 20);
48println!("{}", "Yuck".fg(fg).bg(bg));
49```
50
51Output:
52
53<code style="color: #7BE76F; background: #0A6414">Yuck</code>
54
55# Anything formattable
56
57```rust
58# use ansi_rgb::*;
59#[derive(Debug)]
60struct Foo(i32, i32);
61
62let foo = Foo(1, 2);
63println!("{:?}", foo.fg(green()));
64```
65
66Output:
67
68<code style="color: #00FF00">Foo(1, 2)</code>
69
70# Windows users
71
72You need to [set your console mode](https://docs.microsoft.com/en-us/windows/console/console-modes). Otherwise you'll get garbage like this:
73
74`�[48;2;159;114;0m �[0m`
75 */
76
77mod background;
78mod colors;
79mod foreground;
80
81pub use background::*;
82pub use colors::*;
83pub use foreground::*;