Expand description
Print ASCII tables to the terminal.
§Example
use ::ascii_table::AsciiTable;
let ascii_table = AsciiTable::new();
let data = &[&["1", "2", "3"], &["4", "5", "6"], &["7", "8", "9"]];
ascii_table.println(data);
// ┌───┬───┬───┐
// │ 1 │ 2 │ 3 │
// │ 4 │ 5 │ 6 │
// │ 7 │ 8 │ 9 │
// └───┴───┴───┘§Example
use ::ascii_table::{Align, AsciiTable, Width};
let mut ascii_table = AsciiTable::new();
ascii_table.set_max_width(Width::Fixed(26));
ascii_table
.column(0)
.set_header("H1")
.set_align(Align::Left);
ascii_table
.column(1)
.set_header("H2")
.set_align(Align::Center);
ascii_table
.column(2)
.set_header("H3")
.set_align(Align::Right);
let data: &[&[&str]] = &[&["v", "v", "v"], &["123", "456", "789", "abcdef"]];
ascii_table.println(data);
// ┌─────┬─────┬─────┬──────┐
// │ H1 │ H2 │ H3 │ │
// ├─────┼─────┼─────┼──────┤
// │ v │ v │ v │ │
// │ 123 │ 456 │ 789 │ abc+ │
// └─────┴─────┴─────┴──────┘§Features
auto_table_width: Sets the default max width of the Ascii Table to the width of the terminal.color_codes: Correctly calculates the width of a string when terminal color codes are present (like those from thecolorfulcrate).wide_characters: Correctly calculates the width of a string when wide characters are present (like emoji’s).
Structs§
Enums§
- Align
- Alignment of text in a cell.
- Width
- See
set_max_width.