1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//! A small and dependency free crate for formatting the terminal outputs
//! in a column based grid style.
//! ```text
//! [---------------------]     [---------------------]     [---------------------]
//! [---------------------]     [---------------------]     [---------------------]
//! [---------------------]     [---------------------]     [---------------------]
//! <----------1---------->                            <-2->
//!
//! 1: Grid column
//! 2: Grid padding
//! ```
//! Each `Cell` of the grid can span into 1 or more columns.
//! ```text
//! [ Cell with colspan 1 ]     [---------------------]     [---------------------]
//! [-------------- Cell with colspan 2 --------------]     [---------------------]
//! [---------------------------- Cell with colspan 3 ----------------------------]
//! ```
//!
//! Horizontal alignments of cells are [`HAlign::Left`], [`HAlign::Center`],
//! [`HAlign::Right`] and [`HAlign::Fill`],
//!
//! [`HAlign::Left`]: enum.HAlign.html#variant.Left
//! [`HAlign::Center`]: enum.HAlign.html#variant.Center
//! [`HAlign::Right`]: enum.HAlign.html#variant.Right
//! [`HAlign::Fill`]: enum.HAlign.html#variant.Fill
//!
//! Vertical alignments of cells are [`VAlign::Top`], [`VAlign::Middle`] and
//! [`VAlign::Bottom`].
//!
//! [`VAlign::Top`]: enum.VAlign.html#variant.Top
//! [`VAlign::Middle`]: enum.VAlign.html#variant.Middle
//! [`VAlign::Bottom`]: enum.VAlign.html#variant.Bottom
//!
//! # Examples:
//! ```rust
//! use cli_grid::*;
//!
//! let grid = Grid::builder(vec![
//!     Row::new(vec![
//!         Cell::new("1".into(), 1),
//!         Cell::new("1".into(), 1),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("2".into(), 2),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("3".into(), 3),
//!     ]),
//! ])
//! .default_blank_char('.')
//! .column_width(15)
//! .build();
//!
//! let expected = format!(
//!     "{}\n{}\n{}\n",
//!     "1.............. 1.............. 1..............",
//!     "2.............................. 1..............",
//!     "3..............................................",
//! );
//!
//! assert_eq!(grid.to_string(), expected);
//! ```
//! Multi line `Cell`s also is supported:
//! ```rust
//! use cli_grid::*;
//!
//! let grid = Grid::builder(vec![
//!     Row::new(vec![
//!         Cell::new("1".into(), 1),
//!         Cell::new("1\n1\n1".into(), 1),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("2".into(), 2),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("3".into(), 3),
//!     ]),
//! ])
//! .default_blank_char('.')
//! .column_width(15)
//! .build();
//!
//! let expected = format!(
//!     "{}\n{}\n{}\n{}\n{}\n",
//!     "1.............. 1.............. 1..............",
//!     "............... 1.............. ...............",
//!     "............... 1.............. ...............",
//!     "2.............................. 1..............",
//!     "3..............................................",
//! );
//!
//! assert_eq!(grid.to_string(), expected);
//! ```
//! So nested grids also is supported:
//! ```rust
//! use cli_grid::*;
//!
//! let nested_grid = Grid::builder(vec![
//!     Row::new(vec![
//!         Cell::new("1".into(), 1),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("1".into(), 1),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("1".into(), 1),
//!         Cell::new("1".into(), 1),
//!     ]),
//! ])
//! .default_h_align(HAlign::Center)
//! .default_blank_char('-')
//! .column_width(5)
//! .build();
//!
//! let grid = Grid::builder(vec![
//!     Row::new(vec![
//!         Cell::new("2".into(), 2),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("1".into(), 1),
//!         Cell::new(nested_grid.to_string(), 1),
//!         Cell::new("1".into(), 1),
//!     ]),
//!     Row::new(vec![
//!         Cell::new("3".into(), 3),
//!     ]),
//! ])
//! .default_h_align(HAlign::Center)
//! .default_v_align(VAlign::Middle)
//! .default_blank_char('.')
//! .column_width(15)
//! .build();
//!
//! let expected = format!(
//!     "{}\n{}\n{}\n{}\n{}\n",
//!     "...............2............... .......1.......",
//!     "............... ..--1-- --1--.. ...............",
//!     ".......1....... ..--1-- --1--.. .......1.......",
//!     "............... ..--1-- --1--.. ...............",
//!     ".......................3.......................",
//! );
//!
//! assert_eq!(grid.to_string(), expected);
//! ```
//! 
//! Empty cells and rows can be created by [`Cell::new_empty`] and [`Row::new_empty`] methods.
//!
//! [`Cell::new_empty`]: struct.Cell.html#method.new_empty
//! [`Row::new_empty`]: struct.Row.html#method.new_empty
//!
//! Filled cells and rows can be created by [`Cell::new_fill`] and [`Row::new_fill`] methods.
//!
//! [`Cell::new_fill`]: struct.Cell.html#method.new_fill
//! [`Row::new_fill`]: struct.Row.html#method.new_fill
//!

mod grid;
mod row;
mod cell;
mod options;

pub use cell::{Cell, CellBuilder, HAlign, VAlign};
pub use grid::{Grid, GridBuilder};
pub use row::{Row, RowBuilder};
pub use options::Options;