[][src]Struct matrix_display::MatrixDisplay

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 mut data = matrix::Matrix::new(8, board);
let display = MatrixDisplay::new(&format, &mut data);
display.print(&mut std::io::stdout(), &style::BordersStyle::Light);

Methods

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

pub fn new(f: &'a Format, m: &'a mut Matrix<Cell<T>>) -> MatrixDisplay<'a, T>[src]

Construct a matrix display

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

pub fn width(&self) -> usize[src]

The matrix's width in number of characters

pub fn height(&self) -> usize[src]

The matrix's height in number of characters

pub fn render(&self, borders: &BordersStyle) -> Vec<ANSIString<'static>>[src]

Render a matrix into a Vec.

Pick a BorderStyle, an output that implements the Write trait and you're good to go! This approach allows the user to customize how to display the matrix.

pub fn print<Out: Write>(&self, out: &mut Out, borders: &BordersStyle)[src]

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!

pub fn coordinates_at_cursor_position(
    &self,
    (x, y): (usize, usize)
) -> (usize, usize)
[src]

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

pub fn cell_at_cursor_position(
    &mut self,
    cursor: (usize, usize)
) -> &mut Cell<T>
[src]

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

Auto Trait Implementations

impl<'a, T> Send for MatrixDisplay<'a, T> where
    T: Send

impl<'a, T> Sync for MatrixDisplay<'a, T> where
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]