pub fn set_fg_256(string: &str, color: u8) -> String
Expand description

Sets the foreground color of a given string for ANSI terminal output using a 256-color palette.

This function takes an input string and a color index (0-255) and formats the string with ANSI escape codes to set the foreground color of the text when printed to a terminal that supports ANSI color codes.

Arguments

  • string - The input string that you want to colorize.
  • color - The color index in the 256-color palette (0-255).

Returns

A formatted string with ANSI escape codes for setting the foreground color.

Examples

 use dev_utils::console::format::set_fg_256;

println!("{}", set_fg_256("Hello, Custom 256-color!", 123));  // Color index 123