[−][src]Struct gameboard::cursor::Cursor
Cursor structure.
Methods
impl Cursor
[src]
pub fn new(
background: Rgb,
position: Position,
wrap_around: bool,
get_direction: Option<fn(key: Key) -> Option<Direction>>
) -> Self
[src]
background: Rgb,
position: Position,
wrap_around: bool,
get_direction: Option<fn(key: Key) -> Option<Direction>>
) -> Self
Creates new cursor.
Arguments
background
- background color of the cell where cursor is placed. Use termion::color
.
position
- cursor start position.
wrap_around
- should cursor be wrapped around or not.
get_direction
- pointer to key handler function (optional). This function should
translate key into cursor move direction. Function must return None
if key is not
handled. If function isn't provided the default function is used.
fn get_direction_default(key: Key) -> Option<Direction> { match key { Key::Char('a') | Key::Left => Some(Direction::Left), Key::Char('s') | Key::Down => Some(Direction::Down), Key::Char('w') | Key::Up => Some(Direction::Up), Key::Char('d') | Key::Right => Some(Direction::Right), _ => None, } }
Examples
use termion::color; const START_POSITION: Position = Position(1, 1); let cursor = Cursor::new(color::Rgb(0, 0, 200), START_POSITION, true, None);
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
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,