1#[derive(Copy, Clone, Debug, Default)]
2pub(crate) struct Palette {
3 pub(crate) description: styled::Style,
4 pub(crate) var: styled::Style,
5 pub(crate) expected: styled::Style,
6}
7
8impl Palette {
9 #[cfg(feature = "color")]
10 pub(crate) fn current() -> Self {
11 if concolor::get(concolor::Stream::Either).ansi_color() {
12 Self {
13 description: styled::Style(yansi::Style::new(yansi::Color::Blue).bold()),
14 var: styled::Style(yansi::Style::new(yansi::Color::Red).bold()),
15 expected: styled::Style(yansi::Style::new(yansi::Color::Green).bold()),
16 }
17 } else {
18 Self::default()
19 }
20 }
21
22 #[cfg(not(feature = "color"))]
23 pub(crate) fn current() -> Self {
24 Self::default()
25 }
26}
27
28#[cfg(feature = "color")]
29mod styled {
30 #[derive(Copy, Clone, Debug, Default)]
31 pub(crate) struct Style(pub(crate) yansi::Style);
32
33 impl Style {
34 pub(crate) fn paint<T: std::fmt::Display>(self, item: T) -> impl std::fmt::Display {
35 self.0.paint(item)
36 }
37 }
38}
39
40#[cfg(not(feature = "color"))]
41mod styled {
42 #[derive(Copy, Clone, Debug, Default)]
43 pub(crate) struct Style;
44
45 impl Style {
46 pub(crate) fn paint<T: std::fmt::Display>(self, item: T) -> impl std::fmt::Display {
47 item
48 }
49 }
50}
51