d_stuff/
text.rs

1pub struct Text {
2    text: String,
3    style: String,
4    color: String,
5}
6
7impl Text {
8    pub fn new<S1, S2, S3>(text: S1, style: S2, color: S3) -> Self
9    where
10        S1: Into<String>,
11        S2: Into<String>,
12        S3: Into<String>,
13    {
14        let text = text.into();
15        let style = style.into();
16        let color = color.into();
17        Self { text, style, color }
18    }
19
20    pub fn text(&self) -> &str {
21        &self.text
22    }
23
24    pub fn style(&self) -> &str {
25        &self.style
26    }
27
28    pub fn color(&self) -> &str {
29        &self.color
30    }
31
32    pub fn len(&self) -> usize {
33        self.text.len()
34    }
35
36    pub fn print(&self) {
37        print!(
38            "{}{}{}{}",
39            self.style(),
40            self.color(),
41            self.text(),
42            termion::style::Reset
43        );
44    }
45}