1use std::fmt::Display;
2
3#[derive(Debug)]
6pub enum BoxType{
7 Classic,
8 Single,
9 DoubleHorizontal,
10 DoubleVertical,
11 Double,
12 Bold,
13 Rounded,
14 BoldCorners
15}
16
17impl Display for BoxType{
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 let str = match &self {
21 BoxType::Classic => "classic".to_string(),
22 BoxType::Single => "single".to_string(),
23 BoxType::DoubleHorizontal => "double_horizontal".to_string(),
24 BoxType::DoubleVertical => "double_vertical".to_string(),
25 BoxType::Double => "double".to_string(),
26 BoxType::Bold => "bold".to_string(),
27 BoxType::Rounded => "rounded".to_string(),
28 BoxType::BoldCorners => "bold_corners".to_string(),
29 };
30 write!(f, "{}", str)
31 }
32}
33
34#[derive(Debug)]
37pub enum BoxAlign {
38 Left,
39 Center,
40 Right,
41}
42
43impl Display for BoxAlign {
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 let str = match self {
47 BoxAlign::Left => "left".to_string(),
48 BoxAlign::Center => "center".to_string(),
49 BoxAlign::Right => "right".to_string(),
50 };
51 write!(f, "{}", str)
52 }
53}
54
55
56#[derive(Debug)]
58pub struct BoxPad {
59 pub top: usize,
60 pub down: usize,
61 pub left: usize,
62 pub right: usize,
63}
64
65impl Default for BoxPad {
66 fn default() -> Self {
67 Self::new()
68 }
69}
70
71impl BoxPad {
72 pub fn new() -> Self {
73 BoxPad{
74 top: 0,
75 down: 0,
76 left: 0,
77 right: 0
78 }
79 }
80 pub fn from_tldr(top: usize, left: usize, down: usize, right: usize) -> Self {
82 BoxPad{
83 top,
84 down,
85 left,
86 right
87 }
88 }
89
90 pub fn uniform(pad: usize) -> Self{
92 BoxPad{
93 top: pad,
94 down: pad,
95 left: pad,
96 right: pad
97 }
98 }
99 pub fn vh(vertical: usize, horizontal: usize) -> Self{
101 BoxPad{
102 top: vertical,
103 down: vertical,
104 left: horizontal,
105 right: horizontal
106 }
107 }
108 pub fn lr(&self) -> usize{
110 self.right + self.left
111 }
112}