basic/
basic.rs

1extern crate term_grid;
2use term_grid::{Grid, GridOptions, Direction, Filling, Cell, Alignment};
3
4// This produces:
5//
6//  1 |  128 |   16384 |   2097152 |   268435456 |   34359738368 |   4398046511104
7//  2 |  256 |   32768 |   4194304 |   536870912 |   68719476736 |   8796093022208
8//  4 |  512 |   65536 |   8388608 |  1073741824 |  137438953472 |  17592186044416
9//  8 | 1024 |  131072 |  16777216 |  2147483648 |  274877906944 |  35184372088832
10// 16 | 2048 |  262144 |  33554432 |  4294967296 |  549755813888 |  70368744177664
11// 32 | 4096 |  524288 |  67108864 |  8589934592 | 1099511627776 | 140737488355328
12// 64 | 8192 | 1048576 | 134217728 | 17179869184 | 2199023255552 |
13
14fn main() {
15    let mut grid = Grid::new(GridOptions {
16        direction:  Direction::TopToBottom,
17        filling:    Filling::Text(" | ".into()),
18    });
19
20    for i in 0..48 {
21        let mut cell = Cell::from(format!("{}", 2_isize.pow(i)));
22        cell.alignment = Alignment::Right;
23        grid.add(cell)
24    }
25
26    if let Some(grid_display) = grid.fit_into_width(80) {
27        println!("{}", grid_display);
28    }
29    else {
30        println!("Couldn't fit grid into 80 columns!");
31    }
32}