1 | #[cfg (feature = "std" )] |
2 | use crate::grid::config::{ColoredConfig, VerticalLine as VLine}; |
3 | |
4 | use super::Line; |
5 | |
6 | /// A horizontal split line which can be used to set a border. |
7 | #[cfg_attr (not(feature = "std" ), allow(dead_code))] |
8 | #[derive (Debug, Clone)] |
9 | pub struct VerticalLine { |
10 | pub(crate) index: usize, |
11 | pub(crate) line: Line, |
12 | } |
13 | |
14 | impl VerticalLine { |
15 | /// Creates a new horizontal split line. |
16 | pub const fn new(index: usize, line: Line) -> Self { |
17 | Self { index, line } |
18 | } |
19 | |
20 | /// Sets a horizontal character. |
21 | pub const fn main(mut self, c: Option<char>) -> Self { |
22 | self.line.main = c; |
23 | self |
24 | } |
25 | |
26 | /// Sets a vertical intersection character. |
27 | pub const fn intersection(mut self, c: Option<char>) -> Self { |
28 | self.line.intersection = c; |
29 | self |
30 | } |
31 | |
32 | /// Sets a top character. |
33 | pub const fn top(mut self, c: Option<char>) -> Self { |
34 | self.line.connector1 = c; |
35 | self |
36 | } |
37 | |
38 | /// Sets a bottom character. |
39 | pub const fn bottom(mut self, c: Option<char>) -> Self { |
40 | self.line.connector2 = c; |
41 | self |
42 | } |
43 | } |
44 | |
45 | #[cfg (feature = "std" )] |
46 | impl<R, D> crate::settings::TableOption<R, D, ColoredConfig> for VerticalLine { |
47 | fn change(self, _: &mut R, cfg: &mut ColoredConfig, _: &mut D) { |
48 | cfg.insert_vertical_line(self.index, val:VLine::from(self.line)); |
49 | } |
50 | } |
51 | |