pub struct Cursor { /* private fields */ }
Expand description
Cursor structure.
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn new(
background: Rgb,
position: Position,
wrap_around: bool,
get_direction: Option<fn(key: Key) -> Option<Direction>>,
) -> Self
pub fn new( 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§
impl Freeze for Cursor
impl RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl UnwindSafe for Cursor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more