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
#[derive(Debug, Clone, Copy)]
pub enum Style {
Plain,
Ascii,
Sharp,
Rounded,
Markdown,
}
impl Style {
pub fn new(s: String) -> Self {
match s.to_lowercase().as_str() {
"plane" => Self::Plain,
"plain" => Self::Plain,
"ascii" => Self::Ascii,
"sharp" => Self::Sharp,
"rounded" => Self::Rounded,
"markdown" => Self::Markdown,
_ => Self::Ascii,
}
}
}
pub struct Frame {
pub has_cover: bool,
pub border: String,
pub separator: String,
pub center: String,
pub top: String,
pub left: String,
pub bottom: String,
pub right: String,
pub top_left: String,
pub top_right: String,
pub bottom_left: String,
pub bottom_right: String,
}
impl From<Style> for Frame {
fn from(style: Style) -> Self {
match style {
Style::Plain => Self {
has_cover: false,
border: "".into(),
separator: "\t".into(),
center: "".into(),
top: "".into(),
left: "".into(),
bottom: "".into(),
right: "".into(),
top_left: "".into(),
top_right: "".into(),
bottom_left: "".into(),
bottom_right: "".into(),
},
Style::Ascii => Self {
has_cover: true,
border: "-".into(),
separator: "|".into(),
center: "+".into(),
top: "+".into(),
left: "+".into(),
bottom: "+".into(),
right: "+".into(),
top_left: "+".into(),
top_right: "+".into(),
bottom_left: "+".into(),
bottom_right: "+".into(),
},
Style::Sharp => Self {
has_cover: true,
border: "─".into(),
separator: "│".into(),
center: "┼".into(),
top: "┬".into(),
left: "├".into(),
bottom: "┴".into(),
right: "┤".into(),
top_left: "┌".into(),
top_right: "┐".into(),
bottom_left: "└".into(),
bottom_right: "┘".into(),
},
Style::Rounded => Self {
has_cover: true,
border: "─".into(),
separator: "│".into(),
center: "┼".into(),
top: "┬".into(),
left: "├".into(),
bottom: "┴".into(),
right: "┤".into(),
top_left: "╭".into(),
top_right: "╮".into(),
bottom_left: "╰".into(),
bottom_right: "╯".into(),
},
Style::Markdown => Self {
has_cover: false,
border: "-".into(),
separator: "|".into(),
center: "|".into(),
top: "".into(),
left: "|".into(),
bottom: "".into(),
right: "|".into(),
top_left: "".into(),
top_right: "".into(),
bottom_left: "".into(),
bottom_right: "".into(),
},
}
}
}