Expand description
§spraypaint
Terminal string styling for Rust.
§Quick Start
use spraypaint::{paint, Colorize};
// Primary API: paint! prints directly (like println!)
paint!("{red.bold Error:} something went wrong");
paint!("Hello {green.italic world}!");
paint!(inline, "{yellow Loading...}"); // no newline
paint!(stderr, "{red.bold FATAL:} disk full");
// Extension trait: chain styles, then call .paint()
"Warning".yellow().on_red().italic().paint();
// Compose styled values for format strings / loggers
let msg = "critical".red().bold();
eprintln!("status: {msg}");§Color Levels
spraypaint auto-detects terminal color support via environment variables:
NO_COLOR→ disable all colorFORCE_COLOR=3→ force truecolorCOLORTERM=truecolor→ enable RGB
Override programmatically:
use spraypaint::detect::{set_color_level, ColorLevel};
set_color_level(ColorLevel::TrueColor);Re-exports§
pub use color::Color;pub use detect::color_level;pub use detect::set_color_level;pub use detect::ColorLevel;pub use ext::Colorize;pub use gradient::Gradient;pub use style::Attrs;pub use style::Style;pub use utils::strip_ansi;
Modules§
- color
- Color types supporting Basic 16, Xterm 256, and 24-bit RGB.
- detect
- Terminal color capability detection.
- ext
- The
Colorizeextension trait: add styling to anyfmt::Displayvalue. - gradient
- Gradient text: interpolate colors smoothly across a string’s characters.
- prelude
- Convenience re-export:
use spraypaint::prelude::*brings the most common items into scope. - style
- The
Stylestruct: a composable, copy-able bundle of colors and text attributes. - utils
- Utility functions for working with ANSI-styled strings.
Macros§
- paint
- Print styled text to stdout with a trailing newline.
- styled
- Return an owned
Stringwith ANSI styling applied (does not print).