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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use owo_colors::style;
use owo_colors::Style;
macro_rules! theme {
($(#[$meta:meta] $name:ident),* $(,)?) => {
/// Setting for appearance of `terminator` messages
#[derive(Debug, Clone, Default)]
#[must_use]
pub struct Theme {
$(
pub(crate) $name: Style,
)*
}
impl Theme {
$(
#[$meta]
#[inline]
pub fn $name(mut self, style: Style) -> Self {
self.$name = style;
self
}
)*
}
};
}
theme! {
/// Styles printed paths
file,
/// Styles the line number of a file
line,
/// Styles errors printed by `EyreHandler`
error,
/// Styles code that is not part of your crate
dependency,
/// Styles code that's in your crate
package,
/// Styles the hash after `dependency_code` and `crate_code`
hash,
/// Styles the header of a panic
header,
/// Styles the message of a panic
message,
/// Styles the "N frames hidden" message
hidden,
}
impl Theme {
/// Creates a blank theme
pub fn new() -> Self {
Self::dark()
}
/// Returns a theme for dark backgrounds. This is the default
pub fn dark() -> Self {
Self {
file: style().purple(),
line: style().purple(),
error: style().bright_red(),
dependency: style().green(),
package: style().bright_red(),
hash: style().bright_black(),
header: style().red(),
message: style().cyan(),
hidden: style().bright_cyan(),
}
}
/// Returns a theme for light backgrounds
pub fn light() -> Self {
Self {
file: style().purple(),
line: style().purple(),
error: style().red(),
dependency: style().green(),
package: style().red(),
hash: style().bright_black(),
header: style().red(),
message: style().blue(),
hidden: style().blue(),
}
}
}