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
use prototty_render::{Rgb24, ViewCell};
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy)]
pub struct TextInfo {
pub foreground_colour: Option<Rgb24>,
pub background_colour: Option<Rgb24>,
pub underline: bool,
pub bold: bool,
}
impl Default for TextInfo {
fn default() -> Self {
Self {
foreground_colour: None,
background_colour: None,
underline: false,
bold: false,
}
}
}
impl TextInfo {
pub fn foreground_colour(self, colour: Rgb24) -> Self {
Self {
foreground_colour: Some(colour),
..self
}
}
pub fn background_colour(self, colour: Rgb24) -> Self {
Self {
background_colour: Some(colour),
..self
}
}
pub fn underline(self) -> Self {
Self {
underline: true,
..self
}
}
pub fn bold(self) -> Self {
Self { bold: true, ..self }
}
pub fn view_cell_info(&self, character: char) -> ViewCell {
ViewCell {
character: Some(character),
foreground: self.foreground_colour,
background: self.background_colour,
underline: Some(self.underline),
bold: Some(self.bold),
}
}
}