style

Macro style 

Source
macro_rules! style {
    ($($v:ident),+ => $input:expr$(,)?) => { ... };
    ($($v1:ident,)? $(($rgb:ident, $r:expr, $g:expr, $b:expr)),+ $(,$v2:ident)? => $input:expr$(,)?) => { ... };
}
Expand description

Applies ANSI styling to a string using the Style enum.

This macro simplifies the process of adding text styling, like colors and text attributes (e.g., bold, underline), to a string for output in terminal applications. It constructs an ANSI escape sequence using the provided Style variants.

§Usage

Pass one or more Style enum variants, followed by => and the string to format.

§Examples

use dekor::*;

let styled_text = style!(Bold, FGBlue, BGWhite => "Styled Text");
println!("{}", styled_text);

This example applies bold blue text on a white background to “Styled Text”.

§Notes

  • The macro appends an ANSI reset sequence at the end of the formatted string to ensure that the styling does not affect subsequent text.