Skip to main content

comfy_table/style/
presets.rs

1use super::{ContentLineStyle, LineStyle, TableStyle};
2
3/// The default style for tables.
4///
5/// ```text
6/// +-------+-------+
7/// | Hello | there |
8/// +===============+
9/// | a     | b     |
10/// |-------+-------|
11/// | c     | d     |
12/// +-------+-------+
13/// ```
14pub const ASCII_FULL: TableStyle = TableStyle::new()
15    .top_border(LineStyle::new('+', '-', '+', '+'))
16    .header_lines(ContentLineStyle::new('|', '|', '|'))
17    .header_separator(LineStyle::new('+', '=', '=', '+'))
18    .content_lines(ContentLineStyle::new('|', '|', '|'))
19    .row_separator(LineStyle::new('|', '-', '+', '|'))
20    .bottom_border(LineStyle::new('+', '-', '+', '+'));
21
22/// Just like ASCII_FULL, but without dividers between rows.
23///
24/// ```text
25/// +-------+-------+
26/// | Hello | there |
27/// +===============+
28/// | a     | b     |
29/// | c     | d     |
30/// +-------+-------+
31pub const ASCII_FULL_CONDENSED: TableStyle = TableStyle::new()
32    .top_border(LineStyle::new('+', '-', '+', '+'))
33    .header_lines(ContentLineStyle::new('|', '|', '|'))
34    .header_separator(LineStyle::new('+', '=', '=', '+'))
35    .content_lines(ContentLineStyle::new('|', '|', '|'))
36    .bottom_border(LineStyle::new('+', '-', '+', '+'));
37
38/// Just like ASCII_FULL, but without any borders.
39///
40/// ```text
41///  Hello | there
42/// ===============
43///  a     | b
44/// -------+-------
45///  c     | d
46/// ```
47pub const ASCII_NO_BORDERS: TableStyle = TableStyle::new()
48    .header_lines(ContentLineStyle::none().junction('|'))
49    .header_separator(LineStyle::none().fill('=').junction('='))
50    .content_lines(ContentLineStyle::none().junction('|'))
51    .row_separator(LineStyle::none().fill('-').junction('+'));
52
53/// Just like ASCII_FULL, but without vertical/horizontal middle lines.
54///
55/// ```text
56/// +---------------+
57/// | Hello   there |
58/// +===============+
59/// | a       b     |
60/// |               |
61/// | c       d     |
62/// +---------------+
63/// ```
64pub const ASCII_BORDERS_ONLY: TableStyle = TableStyle::new()
65    .top_border(LineStyle::new('+', '-', '-', '+'))
66    .header_lines(ContentLineStyle::none().left('|').right('|'))
67    .header_separator(LineStyle::new('+', '=', '=', '+'))
68    .content_lines(ContentLineStyle::none().left('|').right('|'))
69    .row_separator(LineStyle::none().left('|').right('|'))
70    .bottom_border(LineStyle::new('+', '-', '-', '+'));
71
72/// Just like ASCII_BORDERS_ONLY, but without spacing between rows.
73///
74/// ```text
75/// +---------------+
76/// | Hello   there |
77/// +===============+
78/// | a       b     |
79/// | c       d     |
80/// +---------------+
81/// ```
82pub const ASCII_BORDERS_ONLY_CONDENSED: TableStyle = TableStyle::new()
83    .top_border(LineStyle::new('+', '-', '-', '+'))
84    .header_lines(ContentLineStyle::none().left('|').right('|'))
85    .header_separator(LineStyle::new('+', '=', '=', '+'))
86    .content_lines(ContentLineStyle::none().left('|').right('|'))
87    .bottom_border(LineStyle::new('+', '-', '-', '+'));
88
89/// Just like ASCII_FULL, but without vertical/horizontal middle lines and no side borders.
90///
91/// ```text
92/// ---------------
93///  Hello   there
94/// ===============
95///  a       b
96/// ---------------
97///  c       d
98/// ---------------
99/// ```
100pub const ASCII_HORIZONTAL_ONLY: TableStyle = TableStyle::new()
101    .top_border(LineStyle::none().fill('-').junction('-'))
102    .header_separator(LineStyle::none().fill('=').junction('='))
103    .row_separator(LineStyle::none().fill('-').junction('-'))
104    .bottom_border(LineStyle::none().fill('-').junction('-'));
105
106/// Markdown like table styles.
107///
108/// ```text
109/// | Hello | there |
110/// |-------|-------|
111/// | a     | b     |
112/// | c     | d     |
113/// ```
114pub const ASCII_MARKDOWN: TableStyle = TableStyle::new()
115    .header_lines(ContentLineStyle::new('|', '|', '|'))
116    .header_separator(LineStyle::new('|', '-', '|', '|'))
117    .content_lines(ContentLineStyle::new('|', '|', '|'));
118
119/// The UTF8 enabled version of the default style for tables.\
120/// Quite beautiful isn't it? It's drawn with UTF8's box drawing characters.
121///
122/// ```text
123/// ┌───────┬───────┐
124/// │ Hello ┆ there │
125/// ╞═══════╪═══════╡
126/// │ a     ┆ b     │
127/// ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
128/// │ c     ┆ d     │
129/// └───────┴───────┘
130/// ```
131pub const UTF8_FULL: TableStyle = TableStyle::new()
132    .top_border(LineStyle::new('┌', '─', '┬', '┐'))
133    .header_lines(ContentLineStyle::new('│', '┆', '│'))
134    .header_separator(LineStyle::new('╞', '═', '╪', '╡'))
135    .content_lines(ContentLineStyle::new('│', '┆', '│'))
136    .row_separator(LineStyle::new('├', '╌', '┼', '┤'))
137    .bottom_border(LineStyle::new('└', '─', '┴', '┘'));
138
139/// Default UTF8 style, but without dividers between rows.
140///
141/// ```text
142/// ┌───────┬───────┐
143/// │ Hello ┆ there │
144/// ╞═══════╪═══════╡
145/// │ a     ┆ b     │
146/// │ c     ┆ d     │
147/// └───────┴───────┘
148/// ```
149pub const UTF8_FULL_CONDENSED: TableStyle = TableStyle::new()
150    .top_border(LineStyle::new('┌', '─', '┬', '┐'))
151    .header_lines(ContentLineStyle::new('│', '┆', '│'))
152    .header_separator(LineStyle::new('╞', '═', '╪', '╡'))
153    .content_lines(ContentLineStyle::new('│', '┆', '│'))
154    .bottom_border(LineStyle::new('└', '─', '┴', '┘'));
155
156/// Default UTF8 style, but without any borders.
157///
158/// ```text
159///  Hello ┆ there
160/// ═══════╪═══════
161///  a     ┆ b
162/// ╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌
163///  c     ┆ d
164/// ```
165pub const UTF8_NO_BORDERS: TableStyle = TableStyle::new()
166    .header_lines(ContentLineStyle::none().junction('┆'))
167    .header_separator(LineStyle::none().fill('═').junction('╪'))
168    .content_lines(ContentLineStyle::none().junction('┆'))
169    .row_separator(LineStyle::none().fill('╌').junction('┼'));
170
171/// Just like the UTF8_FULL style, but without vertical/horizontal middle lines.
172///
173/// ```text
174/// ┌───────────────┐
175/// │ Hello   there │
176/// ╞═══════════════╡
177/// │ a       b     │
178/// │ c       d     │
179/// └───────────────┘
180/// ```
181pub const UTF8_BORDERS_ONLY: TableStyle = TableStyle::new()
182    .top_border(LineStyle::new('┌', '─', '─', '┐'))
183    .header_lines(ContentLineStyle::none().left('│').right('│'))
184    .header_separator(LineStyle::new('╞', '═', '═', '╡'))
185    .content_lines(ContentLineStyle::none().left('│').right('│'))
186    .bottom_border(LineStyle::new('└', '─', '─', '┘'));
187
188/// Only display vertical lines.
189///
190/// ```text
191/// ───────────────
192///  Hello   there
193/// ═══════════════
194///  a       b
195/// ───────────────
196///  c       d
197/// ───────────────
198/// ```
199pub const UTF8_HORIZONTAL_ONLY: TableStyle = TableStyle::new()
200    .top_border(LineStyle::none().fill('─').junction('─'))
201    .header_separator(LineStyle::none().fill('═').junction('═'))
202    .row_separator(LineStyle::none().fill('─').junction('─'))
203    .bottom_border(LineStyle::none().fill('─').junction('─'));
204
205/// Don't draw any borders or other lines.
206/// Useful, if you want to simply organize some data without any cosmetics.
207///
208/// ```text
209///  Hello  there
210///  a      b
211///  c      d
212/// ```
213pub const NOTHING: TableStyle = TableStyle::new();