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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use plotters::style::RGBColor;
#[allow(dead_code)]
pub mod default_pallette {
use plotters::style::RGBColor;
pub const DARK_C: RGBColor = RGBColor(184, 187, 38); pub const DARK_U: RGBColor = RGBColor(131, 165, 146); pub const DARK_G: RGBColor = RGBColor(251, 73, 52); pub const DARK_A: RGBColor = RGBColor(250, 189, 47); pub const DARK_X: RGBColor = RGBColor(211, 134, 155); pub const DARK_BG: RGBColor = RGBColor(40, 40, 40); pub const DARK_FG: RGBColor = RGBColor(235, 219, 178); pub const BRIGHT_C: RGBColor = RGBColor(152, 151, 26);
pub const BRIGHT_U: RGBColor = RGBColor(69, 133, 136);
pub const BRIGHT_G: RGBColor = RGBColor(204, 36, 29);
pub const BRIGHT_A: RGBColor = RGBColor(215, 153, 33);
pub const BRIGHT_X: RGBColor = RGBColor(211, 134, 155);
pub const BRIGHT_BG: RGBColor = RGBColor(251, 241, 199);
pub const BRIGHT_FG: RGBColor = RGBColor(60, 56, 54);
pub const HIGHLIGHTS: [RGBColor; 9] = [
RGBColor(221, 37, 30), RGBColor(54, 111, 177), RGBColor(128, 255, 0), RGBColor(106, 47, 107), RGBColor(255, 253, 56), RGBColor(255, 84, 3), RGBColor(217, 87, 122), RGBColor(164, 134, 69), RGBColor(141, 215, 145), ];
}
pub fn user_input_to_highlight_indices(hls: &str) -> Vec<Option<usize>> {
hls.bytes()
.map(|c| (c as usize).checked_sub(0x31))
.collect()
}
#[derive(Debug, Clone)]
pub struct ColorTheme {
pub c: RGBColor,
pub u: RGBColor,
pub g: RGBColor,
pub a: RGBColor,
pub x: RGBColor,
pub bg: RGBColor,
pub fg: RGBColor,
pub highlights: [RGBColor; 9],
}
impl ColorTheme {
pub fn dark() -> Self {
Self {
a: default_pallette::DARK_A,
c: default_pallette::DARK_C,
g: default_pallette::DARK_G,
u: default_pallette::DARK_U,
x: default_pallette::DARK_X,
bg: default_pallette::DARK_BG,
fg: default_pallette::DARK_FG,
highlights: default_pallette::HIGHLIGHTS,
}
}
pub fn bright() -> Self {
Self {
a: default_pallette::BRIGHT_A,
c: default_pallette::BRIGHT_C,
g: default_pallette::BRIGHT_G,
u: default_pallette::BRIGHT_U,
x: default_pallette::BRIGHT_X,
bg: default_pallette::BRIGHT_BG,
fg: default_pallette::BRIGHT_FG,
highlights: default_pallette::HIGHLIGHTS,
}
}
pub fn black() -> Self {
Self {
bg: RGBColor(0, 0, 0),
..Self::bright()
}
}
pub fn white() -> Self {
Self {
bg: RGBColor(255, 255, 255),
..Self::bright()
}
}
}
impl Default for ColorTheme {
fn default() -> Self {
Self::dark()
}
}