Crate ansi_gfx

source ·
Expand description

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!

Re-exports

Modules

  • Color codes and attributes.

Macros

  • ANSI graphics mode builder for complex codes.

Structs

  • Single ANSI graphics code.
  • Format graphics codes as an ANSI escape sequence.