Skip to main content

Cursor

Trait Cursor 

Source
pub trait Cursor {
    // Provided methods
    fn set_cursor_visible(&mut self, _visible: bool) { ... }
    fn set_cursor_position(&mut self, _position: Pos) { ... }
    fn set_cursor_style(&mut self, _style: CursorStyle) { ... }
}
Expand description

Shows, hides, and moves a text cursor.

Both methods default to a no-op so backends with no text cursor to manage (pixel/windowed backends, where games draw their own cursor if they want one) can use an empty impl Cursor for X {} instead of writing dead stub bodies by hand.

§Examples

use retroglyph_core::backend::Cursor;
use retroglyph_core::grid::Pos;

struct TrackedCursor {
    visible: bool,
    position: Pos,
}

impl Cursor for TrackedCursor {
    fn set_cursor_visible(&mut self, visible: bool) {
        self.visible = visible;
    }

    fn set_cursor_position(&mut self, position: Pos) {
        self.position = position;
    }
}

Provided Methods§

Source

fn set_cursor_visible(&mut self, _visible: bool)

Show or hide the cursor.

Source

fn set_cursor_position(&mut self, _position: Pos)

Move the cursor to a position.

Source

fn set_cursor_style(&mut self, _style: CursorStyle)

Set the cursor’s shape (and blink behavior).

Defaults to a no-op, matching set_cursor_visible/ set_cursor_position: backends with no text cursor to manage, or that render on a terminal emulator with no shape-changing escape sequence, can ignore this via the default impl Cursor for X {}.

Implementors§