[−][src]Struct matrix_display::MatrixDisplay
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]
T: Clone,
T: ToString + 'a,
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]
&self,
(x, y): (usize, usize)
) -> (usize, usize)
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]
&mut self,
cursor: (usize, usize)
) -> &mut Cell<T>
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,
T: Send,
impl<'a, T> Sync for MatrixDisplay<'a, T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,