1 | //! This module contains a list of primitives which can be applied to change [`Table`] style. |
2 | //! |
3 | //! ## [`Style`] |
4 | //! |
5 | //! It is responsible for a table border style. |
6 | //! An individual cell border can be set by [`Border`]. |
7 | //! |
8 | //! ### Example |
9 | //! |
10 | #![cfg_attr (feature = "std" , doc = "```" )] |
11 | #![cfg_attr (not(feature = "std" ), doc = "```ignore" )] |
12 | //! use tabled::{Table, settings::Style}; |
13 | //! |
14 | //! let data = vec!["Hello" , "2022" ]; |
15 | //! let mut table = Table::new(&data); |
16 | //! table.with(Style::psql()); |
17 | //! |
18 | //! assert_eq!( |
19 | //! table.to_string(), |
20 | //! concat!( |
21 | //! " &str \n" , |
22 | //! "------- \n" , |
23 | //! " Hello \n" , |
24 | //! " 2022 " , |
25 | //! ) |
26 | //! ) |
27 | //! ``` |
28 | //! |
29 | //! ## [`BorderText`] |
30 | //! |
31 | //! It's used to override a border with a custom text. |
32 | //! |
33 | //! ### Example |
34 | //! |
35 | #![cfg_attr (feature = "std" , doc = "```" )] |
36 | #![cfg_attr (not(feature = "std" ), doc = "```ignore" )] |
37 | //! use tabled::{Table, settings::style::{BorderText, Style}}; |
38 | //! |
39 | //! let data = vec!["Hello" , "2022" ]; |
40 | //! let table = Table::new(&data) |
41 | //! .with(Style::psql()) |
42 | //! .with(BorderText::new("Santa" ).horizontal(1)) |
43 | //! .to_string(); |
44 | //! |
45 | //! assert_eq!( |
46 | //! table, |
47 | //! concat!( |
48 | //! " &str \n" , |
49 | //! "Santa-- \n" , |
50 | //! " Hello \n" , |
51 | //! " 2022 " , |
52 | //! ) |
53 | //! ) |
54 | //! ``` |
55 | //! |
56 | //! ## [`Border`] |
57 | //! |
58 | //! [`Border`] can be used to modify cell's borders. |
59 | //! |
60 | //! It's possible to set a collored border when `color` feature is on. |
61 | //! |
62 | //! ### Example |
63 | //! |
64 | #![cfg_attr (feature = "std" , doc = "```" )] |
65 | #![cfg_attr (not(feature = "std" ), doc = "```ignore" )] |
66 | //! use tabled::{Table, settings::{Modify, Style}}; |
67 | //! |
68 | //! let data = vec!["Hello" , "2022" ]; |
69 | //! let table = Table::new(&data) |
70 | //! .with(Style::psql()) |
71 | //! .with(Modify::new((0, 0)).with(Style::modern().get_frame())) |
72 | //! .to_string(); |
73 | //! |
74 | //! assert_eq!( |
75 | //! table, |
76 | //! concat!( |
77 | //! "┌───────┐ \n" , |
78 | //! "│ &str │ \n" , |
79 | //! "└───────┘ \n" , |
80 | //! " Hello \n" , |
81 | //! " 2022 " , |
82 | //! ) |
83 | //! ) |
84 | //! ``` |
85 | //! |
86 | //! ## [`RawStyle`] |
87 | //! |
88 | //! A different representation of [`Style`]. |
89 | //! With no checks in place. |
90 | //! |
91 | //! It also contains a list of types to support colors. |
92 | //! |
93 | //! [`Table`]: crate::Table |
94 | //! [`BorderText`]: crate::settings::style::BorderText |
95 | //! [`RawStyle`]: crate::settings::style::RawStyle |
96 | |
97 | #[cfg (feature = "std" )] |
98 | mod border; |
99 | #[cfg (feature = "std" )] |
100 | mod border_char; |
101 | #[cfg (feature = "std" )] |
102 | mod border_color; |
103 | #[cfg (feature = "std" )] |
104 | mod border_text; |
105 | #[cfg (feature = "std" )] |
106 | mod offset; |
107 | #[cfg (feature = "std" )] |
108 | mod raw_style; |
109 | #[cfg (feature = "std" )] |
110 | mod span_border_correction; |
111 | |
112 | mod builder; |
113 | mod horizontal_line; |
114 | mod line; |
115 | mod vertical_line; |
116 | |
117 | #[cfg (feature = "std" )] |
118 | #[cfg_attr (docsrs, doc(cfg(feature = "std" )))] |
119 | pub use self::{ |
120 | border::Border, border_char::BorderChar, border_color::BorderColor, border_text::BorderText, |
121 | offset::Offset, raw_style::RawStyle, span_border_correction::BorderSpanCorrection, |
122 | }; |
123 | |
124 | pub use builder::{HorizontalLineIter, On, Style, VerticalLineIter}; |
125 | pub use horizontal_line::HorizontalLine; |
126 | pub use line::Line; |
127 | pub use vertical_line::VerticalLine; |
128 | |