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