papergrid/config/compact/
mod.rs1use crate::ansi::ANSIStr;
6use crate::config::{AlignmentHorizontal, Borders, Indent, Sides};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
12pub struct CompactConfig {
13 borders: Borders<char>,
14 border_colors: Borders<ANSIStr<'static>>,
15 margin: Sides<Indent>,
16 margin_color: Sides<ANSIStr<'static>>,
17 padding: Sides<Indent>,
18 padding_color: Sides<ANSIStr<'static>>,
19 halignment: AlignmentHorizontal,
20}
21
22impl Default for CompactConfig {
23 fn default() -> Self {
24 Self::new()
25 }
26}
27
28impl CompactConfig {
29 pub const fn new() -> Self {
31 Self {
32 halignment: AlignmentHorizontal::Left,
33 borders: Borders::empty(),
34 border_colors: Borders::empty(),
35 margin: Sides::filled(Indent::zero()),
36 margin_color: Sides::filled(ANSIStr::new("", "")),
37 padding: Sides::new(
38 Indent::spaced(1),
39 Indent::spaced(1),
40 Indent::zero(),
41 Indent::zero(),
42 ),
43 padding_color: Sides::filled(ANSIStr::new("", "")),
44 }
45 }
46
47 pub const fn set_margin(mut self, margin: Sides<Indent>) -> Self {
49 self.margin = margin;
50 self
51 }
52
53 pub const fn get_margin(&self) -> &Sides<Indent> {
55 &self.margin
56 }
57
58 pub const fn set_borders(mut self, borders: Borders<char>) -> Self {
60 self.borders = borders;
61 self
62 }
63
64 pub const fn get_borders(&self) -> &Borders<char> {
66 &self.borders
67 }
68
69 pub const fn get_borders_color(&self) -> &Borders<ANSIStr<'static>> {
71 &self.border_colors
72 }
73
74 pub const fn set_padding(mut self, padding: Sides<Indent>) -> Self {
76 self.padding = padding;
77 self
78 }
79
80 pub const fn get_padding(&self) -> &Sides<Indent> {
82 &self.padding
83 }
84
85 pub const fn set_alignment_horizontal(mut self, alignment: AlignmentHorizontal) -> Self {
87 self.halignment = alignment;
88 self
89 }
90
91 pub const fn get_alignment_horizontal(&self) -> AlignmentHorizontal {
93 self.halignment
94 }
95
96 pub const fn set_borders_color(mut self, borders: Borders<ANSIStr<'static>>) -> Self {
98 self.border_colors = borders;
99 self
100 }
101
102 pub const fn set_margin_color(mut self, color: Sides<ANSIStr<'static>>) -> Self {
104 self.margin_color = color;
105 self
106 }
107
108 pub const fn get_margin_color(&self) -> &Sides<ANSIStr<'static>> {
110 &self.margin_color
111 }
112
113 pub const fn set_padding_color(mut self, color: Sides<ANSIStr<'static>>) -> Self {
115 self.padding_color = color;
116 self
117 }
118
119 pub const fn get_padding_color(&self) -> &Sides<ANSIStr<'static>> {
121 &self.padding_color
122 }
123}