1use charset::{Charset, TableChars};
2
3pub mod ansi;
4pub mod charset;
5mod fancy;
6mod juststr;
7
8#[derive(Debug)]
9pub enum Layout {
10 Slim,
11 Fixed(usize),
12 Expandable(usize),
13}
14
15#[derive(Debug)]
16pub enum Overflow {
17 Wrap,
18 Truncate,
19}
20
21#[derive(Debug)]
22pub enum Align {
23 Center,
24 Left,
25 Right,
26}
27
28pub enum TitleAlign {
29 LeftOffset(usize),
30 RightOffset(usize),
31}
32
33pub enum Separator {
34 Single,
35 Double,
36 Custom(char),
37}
38
39pub enum Width {
40 Fixed(usize),
41 Percentage(u8),
42}
43
44impl From<usize> for Width {
45 fn from(v: usize) -> Self {
46 Width::Fixed(v)
47 }
48}
49
50pub struct FancyTableOpts {
51 pub title_align: TitleAlign,
52 pub charset: Charset,
53 pub headers_separator: Option<Separator>,
54 pub rows_separator: Option<Separator>,
55 pub max_lines: usize,
56}
57
58pub struct FancyTable<'a, T: AsRef<str>> {
59 width: usize,
60 chars: TableChars,
61 padding: usize,
62 columns: Vec<ColSpec>,
63 headers: Vec<T>,
64 rows_separator: Option<Separator>,
65 headers_separator: Option<Separator>,
66 title: Option<TitleSpec<'a>>,
67}
68
69pub struct FancyTableBuilder<'a, T: AsRef<str>> {
70 width: Width,
71 padding: usize,
72 max_lines: usize,
73 rows_separator: Option<Separator>,
74 headers_separator: Option<Separator>,
75 charset: Charset,
76 headers: Vec<T>,
77 columns: Vec<ColSpec>,
78 title: Option<&'a str>,
79 title_align: TitleAlign,
80}
81
82#[derive(Debug)]
83struct ColSpec {
84 width: usize,
85 max_lines: usize,
86 align: Align,
87 layout: Layout,
88 overflow: Overflow,
89}
90
91struct TitleSpec<'a> {
92 title: &'a str,
93 align: TitleAlign,
94}
95
96#[doc(hidden)]
97pub use juststr::JustedString;
98
99#[doc(hidden)]
100pub use juststr::Justify;