#color #ansi-colors #ansi #graphics #term

no-std ansi-gfx

ANSI Graphics Colors made easily printable

1 unstable release

0.0.0 Mar 30, 2023

#81 in #term

MIT license

15KB
255 lines

ANSI Graphics Colors

MIT License crates.io docs.rs Build status

Simple library to format text with ANSI graphics colors.

To test the support of your terminal, run cargo run --example test-support.

License

Licensed under MIT License, see license.txt.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.


lib.rs:

Simple ANSI graphics code formatter.

Examples

Set attributes:

println!(
"{}Hello {}world!{}",
ansi_gfx::BOLD, ansi_gfx::UNDERLINE, ansi_gfx::RESET);
Hello world!

Change text foreground and background color:

println!(
concat!(
"Foreground {}Red {}Green {}and {}Blue{}!\n",
"Background {}Red {}Green {}and {}Blue{}!"),
ansi_gfx::RED, ansi_gfx::GREEN, ansi_gfx::RESET, ansi_gfx::BLUE, ansi_gfx::RESET,
ansi_gfx::RED_BG, ansi_gfx::GREEN_BG, ansi_gfx::RESET, ansi_gfx::BLUE_BG, ansi_gfx::RESET);
Foreground Red Green and Blue!
Foreground Red Green and Blue!

Combine attributes, colors and extended colors using the mode! macro:

println!(
"{}Here comes the sun!{}",
ansi_gfx::mode!(UNDERLINE; FG RGB 243, 159, 24; BG PAL 28),
ansi_gfx::RESET);
Hello world!

No runtime deps