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
pub struct Text {
text: String,
style: String,
color: String,
}
impl Text {
pub fn new<S1, S2, S3>(text: S1, style: S2, color: S3) -> Self
where
S1: Into<String>,
S2: Into<String>,
S3: Into<String>,
{
let text = text.into();
let style = style.into();
let color = color.into();
Self { text, style, color }
}
pub fn text(&self) -> &str {
&self.text
}
pub fn style(&self) -> &str {
&self.style
}
pub fn color(&self) -> &str {
&self.color
}
pub fn len(&self) -> usize {
self.text.len()
}
pub fn print(&self) {
print!(
"{}{}{}{}",
self.style(),
self.color(),
self.text(),
termion::style::Reset
);
}
}