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
54
//! Catppuccin-inspired color palette for terminal output.
//!
//! Uses standard ANSI bright colors for maximum terminal compatibility,
//! mapped to approximate Catppuccin Frappe aesthetics.
//!
//! Color palette inspired by [Catppuccin](https://github.com/catppuccin/catppuccin),
//! a community-driven pastel theme. See their repository for the full palette specification.
use colored::{ColoredString, Colorize};
/// Declares [`CatppuccinExt`] and its blanket impl from one
/// `palette_name => ansi_method` row per color, so the trait and the impl
/// can't drift apart.
macro_rules! palette {
($($(#[$doc:meta])* $name:ident => $ansi:ident,)+) => {
/// Extension trait for applying Catppuccin-inspired colors to strings.
/// Uses ANSI bright colors for maximum compatibility.
pub trait CatppuccinExt {
$($(#[$doc])* fn $name(&self) -> ColoredString;)+
}
impl<S: AsRef<str>> CatppuccinExt for S {
$(fn $name(&self) -> ColoredString {
self.as_ref().$ansi()
})+
}
};
}
// Only the colors the CLI and the human formatter use; add a row (mapped
// to its ANSI approximation) when a new one is needed.
palette! {
// Accent colors
/// Red → bright red.
ctp_red => bright_red,
/// Yellow → bright yellow.
ctp_yellow => bright_yellow,
/// Green → bright green.
ctp_green => bright_green,
/// Sky → bright cyan.
sky => bright_cyan,
/// Lavender → bright purple.
lavender => bright_purple,
// Text colors
/// Subtext0 → white.
subtext0 => white,
/// White → bright white.
ctp_white => bright_white,
// Overlay colors
/// Overlay1 → bright black (gray).
overlay1 => bright_black,
}