Crate term_ansi

source ·
Expand description

§Color Formatting Crate

This crate provides macros and functions for formatting terminal output with colors using ANSI escape codes. It supports various colors and allows nesting of colors for flexible and dynamic terminal output.

§Features

  • Apply predefined colors: Red, Green, Blue, White, Black, Yellow, Magenta, Cyan
  • Custom RGB color support
  • Nested color support

§Usage

To use this crate, add it to your Cargo.toml:

[dependencies]
term_ansi = "0.1.0"

Then you can use the provided macros to format your terminal output. Here are some examples:

use term_ansi::*; 

// Simple color application
println!("{}", red!("Error message"));

// Multiple colors in a single line
println!("{}", red!("Error: {}, {}", blue!("File not found"), green!("Please check your path")));

// Nested colors
println!("{}", white!("This is {} with {} color", red!("red"), green!("green")));

// Custom RGB color
println!("{}", rgb!(255, 0, 0, "This is red text"));

§Macros

  • red!: Apply red color.
  • green!: Apply green color.
  • blue!: Apply blue color.
  • white!: Apply white color.
  • black!: Apply black color.
  • yellow!: Apply yellow color.
  • magenta!: Apply magenta color.
  • cyan!: Apply cyan color.
  • colour!: Apply a custom RGB color.

§License

This crate is licensed under the MIT License. See the LICENSE file for details.

Macros§

  • Applies a color code to the provided format string.
  • Applies black color to the provided format string.
  • Applies blue color to the provided format string.
  • Applies a custom RGB color to the provided format string.
  • Applies cyan color to the provided format string.
  • Applies green color to the provided format string.
  • Applies magenta color to the provided format string.
  • Applies red color to the provided format string.
  • Applies white color to the provided format string.
  • Applies yellow color to the provided format string.

Structs§