papergrid

This is library for pretty tables.

It has relatively low level API. If you're interested in a more friendly one take a look at tabled.

Usage

```rust use papergrid::{ height::HeightEstimator, records::vec_records::VecRecords, width::{CfgWidthFunction, WidthEstimator}, AlignmentHorizontal, Borders, Entity::Global, Estimate, Grid, GridConfig, Indent, Padding, };

const STYLE: Borders = Borders { top: Some('-'), topleft: Some('+'), topright: Some('+'), topintersection: Some('+'), bottom: Some('-'), bottomleft: Some('+'), bottomright: Some('+'), bottomintersection: Some('+'), horizontal: Some('-'), horizontalleft: Some('+'), horizontalright: Some('+'), vertical: Some('|'), verticalleft: Some('|'), verticalright: Some('|'), intersection: Some('+'), };

fn main() { let mut cfg = GridConfig::default(); cfg.setborders(STYLE); cfg.setcolumnspan((1, 1), 3); cfg.setrowspan((0, 0), 2); cfg.setalignmenthorizontal((1, 0).into(), AlignmentHorizontal::Center); cfg.setalignmentvertical(Global, papergrid::AlignmentVertical::Center); cfg.setpadding( (0, 0).into(), Padding::new( Indent::spaced(4), Indent::spaced(4), Indent::spaced(1), Indent::spaced(1), ), );

let data = [
    ["Papergrid", "is a library", "for print tables", "!"],
    ["", "Just like this", "", ""],
];

let records = VecRecords::new(&data, (2, 4), CfgWidthFunction::from_cfg(&cfg));

let mut width = WidthEstimator::default();
width.estimate(&records, &cfg);

let mut height = HeightEstimator::default();
height.estimate(&records, &cfg);

let grid = Grid::new(&records, &cfg, &width, &height);

println!("{}", grid);

} ```

Running the example you must see.

text +-----------------+------------+----------------+-+ | |is a library|for print tables|!| + Papergrid +------------+----------------+-+ | |Just like this | +-----------------+------------+----------------+-+