Expand description
Papergrid is a library for generating text-based tables for display
Example
use papergrid::{Grid, Entity, Borders, Settings};
let mut grid = Grid::new(2, 2);
grid.set_borders(Borders {
top: Some('-'),
top_left: Some('+'),
top_right: Some('+'),
top_intersection: Some('+'),
bottom: Some('-'),
bottom_left: Some('+'),
bottom_right: Some('+'),
bottom_intersection: Some('+'),
horizontal: Some('-'),
horizontal_left: Some('+'),
horizontal_right: Some('+'),
vertical_left: Some('|'),
vertical_right: Some('|'),
vertical_intersection: Some('|'),
intersection: Some('+'),
});
grid.set(Entity::Cell(0, 0), Settings::new().text("0-0"));
grid.set(Entity::Cell(0, 1), Settings::new().text("0-1"));
grid.set(Entity::Cell(1, 0), Settings::new().text("1-0"));
grid.set(Entity::Cell(1, 1), Settings::new().text("1-1"));
assert_eq!(
grid.to_string(),
concat!(
"+---+---+\n",
"|0-0|0-1|\n",
"+---+---+\n",
"|1-0|1-1|\n",
"+---+---+",
)
);
Structs
Border is a representation of a cells’s borders (left, right, top, bottom, and the corners)
An iterator over cells.
Formatting represent a logic of formatting of a cell.
Grid provides a set of methods for building a text-based table
Indent represent a filled space.
Margin represent a 4 indents of table as a whole.
Padding represent a 4 indents of cell.
Settings represent setting of a particular cell
Style represent a style of a cell on a grid.
Enums
AlignmentHorizontal
represents an horizontal alignment of a cell content.
AlignmentVertical
represents an vertical alignment of a cell content.
Entity a structure which represent a set of cells.
Functions
strip cuts the string to a specific width.
Returns a string width.
Returns a max string width of a line.