[−][src]Enum gameboard::cell::Cell
Cell content.
Variants
Empty
Empty cell. It will be filled with spaces.
ResourceId(u16)
Resource id. Content is stored in ResourceTable
.
If you use this cell type, you must add resource table to board.
Char(char)
Char (Unicode code point). If cell size is more than 1x1, the cell will be filled with this character.
Content(String)
Arbitrary string. String will be written into cell by rows.
You can use escape sequences. Termion provides termion::style
and termion::color
for
this. You don't have to reset style at the end, it'll be done automatically.
Implementation note
If you use Cursor
, do not use termion::style::Reset
and termion::color::Bg
inside
string. It will break cursor highlighting, because it uses termion::color::Bg
as well
and they will overlap.
Examples
use termion::{style, color}; fn create_resources() -> ResourceTable { let mut res = ResourceTable::new(); res.insert(0, String::from(" OO O O OO ")); res.insert(1, String::from(" X X XX X X ")); res } let cursor = Cursor::new(color::Rgb(0, 0, 200), Position(0, 0), true, None); let mut board = Board::new(3, 3, 6, 3, true, Some(create_resources())); board.init_from_vec( &vec![ Cell::Empty, Cell::ResourceId(0), Cell::ResourceId(1), Cell::Char('z'), Cell::Char('▒'), Cell::Content( format!("{}aaaaaaaa{}aaaaaaaaaa", color::Fg(color::Red), color::Fg(color::Blue)) ), // this cell breaks cursor highlighting Cell::Content( format!("{}bbb{}bbbbb{}bbbb{}bbb{}bbb", color::Fg(color::Red), style::Bold, style::Reset, color::Fg(color::Blue), style::Reset) ), // this cell breaks cursor highlighting Cell::Content( format!("{}cccccccccccc{}cccccc", color::Bg(color::Red), style::Reset) ), Cell::Content( format!("{}dddddddd{}dddddddddd", color::Fg(color::Red), style::Bold) )], Some(cursor));
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,