Skip to main content

Crate console_table

Crate console_table 

Source
Expand description

Console table rendering with Unicode/CJK-aware alignment, truncation, and ANSI color support.

§Example

use console_table::{Align, Style, Table};

let rows = vec![
    vec!["#".to_string(), "source".to_string(), "latency".to_string()],
    vec!["1".to_string(), "rsproxy".to_string(), "57 ms".to_string()],
    vec!["2".to_string(), "tuna".to_string(), "16 ms".to_string()],
];

let table = Table::new(rows)
    .style(Style::Boxed)
    .aligns(vec![Align::Right, Align::Left, Align::Auto]);

println!("{}", table.render());

Structs§

Table
Table configuration.

Enums§

Align
Horizontal alignment of a cell.
Color
ANSI foreground color.
Style
Border style of the table.

Functions§

display_width
Terminal display width of s, ignoring ANSI escape sequences.
is_numeric_like
Return true if s looks like a number, for Align::Auto.
pad_left_with_spaces
Pad s on the left with spaces up to width display columns.
pad_right_with_spaces
Pad s on the right with spaces up to width display columns.
render_table
Convenience function: render a table directly.
strip_ansi
Strip CSI-style ANSI escape sequences (e.g. \x1b[...m) from s.
truncate_visible
Truncate s to at most max_width display columns, appending ASCII ... (3 columns) on overflow.