1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! # Utility Macros
//!
//! Helpful macros that reduce boilerplate when working with colors and other common patterns.
//!
//! The main macro here is `define_colors!` which lets you define multiple color pairs at once:
//!
//! ```rust
//! use minui::{Color, ColorPair, define_colors};
//!
//! define_colors! {
//! pub const ERROR_STYLE = (Color::Red, Color::Black);
//! pub const SUCCESS_STYLE = (Color::Green, Color::Black);
//! pub const HEADER_STYLE = (Color::White, Color::Blue);
//! }
//! ```
/// Creates multiple ColorPair constants at once.
///
/// Instead of writing individual `ColorPair::new()` calls, you can define multiple
/// color pairs in one block. Each line becomes a constant you can use in your widgets.
///
/// # Examples
///
/// ```rust
/// use minui::{Color, ColorPair, define_colors};
///
/// define_colors! {
/// pub const ERROR_STYLE = (Color::Red, Color::Black);
/// pub const SUCCESS_STYLE = (Color::Green, Color::Black);
/// pub const HEADER_STYLE = (Color::White, Color::Blue);
/// }
///
/// // Use them in your widgets
/// // let error_label = Label::new("Error!").with_colors(ERROR_STYLE);
/// ```
///
/// With RGB colors:
/// ```rust
/// use minui::{Color, ColorPair, define_colors};
///
/// define_colors! {
/// pub const BRAND_BLUE = (Color::rgb(0, 123, 255), Color::Black);
/// pub const BRAND_GRAY = (Color::rgb(108, 117, 125), Color::White);
/// }
/// ```
;
}