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