Struct matrix_display::MatrixDisplay [] [src]

pub struct MatrixDisplay<'a, T> where
    T: Clone,
    T: ToString + 'a, 
{ /* fields omitted */ }

Stores a matrix of data and offers a way to pretty print it

Example: visualising a 256 colors palette:

use matrix_display::*;
let format = Format::new(5,1);
let board = (0..256)
       .map(|x| cell::Cell::new(x, 0, x as u8))
    .collect::<Vec<_>>();
let data = matrix::Matrix::new(8, board);
let display = MatrixDisplay::new(format, data);
display.print(&mut std::io::stdout(), &style::BordersStyle::Thin);

Methods

impl<'a, T> MatrixDisplay<'a, T> where
    T: Clone,
    T: ToString + 'a, 
[src]

Construct a matrix display

f: the format of a cell (width, height) m: a reference to the data (&Matrix)

The matrix's width in number of characters

The matrix's height in number of characters

Print a matrix. This is the most important method of this library

Pick a BorderStyle, an output that implements the Write trait and you're good to go!

Takes a cursor position in (usize, usize) and returns the coordinates of the cell under the cursor

Takes a cursor position in characters (x, y) and returns a mutable reference to the corresponding cell

This is used to modify a cell that was clicked