macro_rules! mode { ($($tt:tt)*) => { ... }; }
Expand description
ANSI graphics mode builder for complex codes.
Returns an instance of Print
.
The macro accepts any number of arguments separated by a semicolon ;
.
A single argument can be:
- A code name identifier (e.g.
BOLD
). Seecodes
for a list of all codes. - A runtime
Code
value (e.g.{ansi_gfx::BOLD}
). - A foreground palette color (e.g.
FG PAL 28
). - A background palette color (e.g.
BG PAL 28
). - A foreground RGB color (e.g.
FG RGB 255, 0, 0
). - A background RGB color (e.g.
BG RGB 255, 0, 0
).
Examples
println!("{}Bold and underlined{}\n", ansi_gfx::mode!(BOLD; UNDERLINE), ansi_gfx::RESET);
println!("{}Red on yellow{}\n", ansi_gfx::mode!(FG PAL 9; BG PAL 11), ansi_gfx::RESET);
let style = ansi_gfx::INVERSE;
println!("{}Inverted{}\n", ansi_gfx::mode!({style}; BOLD), ansi_gfx::RESET);
Bold and underlined Red on yellow Inverted