pub struct Headless {
grid: Grid,
cursor_visible: bool,
cursor_pos: Pos,
event_queue: VecDeque<Event>,
}Expand description
In-memory backend for testing. Stores presented content and allows injecting synthetic events.
Fields§
§grid: Grid§cursor_visible: bool§cursor_pos: Pos§event_queue: VecDeque<Event>Implementations§
Source§impl Headless
impl Headless
Sourcepub fn new(width: u16, height: u16) -> Self
pub fn new(width: u16, height: u16) -> Self
Creates a new headless backend of the given dimensions.
Sourcepub const fn cursor_visible(&self) -> bool
pub const fn cursor_visible(&self) -> bool
Returns the cursor visibility.
Sourcepub const fn cursor_position(&self) -> Pos
pub const fn cursor_position(&self) -> Pos
Returns the cursor position.
Sourcepub fn push_event(&mut self, event: Event)
pub fn push_event(&mut self, event: Event)
Injects a synthetic event into the queue.
Sourcepub fn format_view(&self) -> String
pub fn format_view(&self) -> String
Converts the current grid state into a readable string for snapshot testing.
Space cells are rendered as · so layout is visible in text diffs.
Trait Implementations§
Source§impl Backend for Headless
impl Backend for Headless
Source§fn poll_event(&mut self, _timeout: Duration) -> Option<Event>
fn poll_event(&mut self, _timeout: Duration) -> Option<Event>
Poll for an input event, waiting up to
timeout.Source§fn push_event(&mut self, event: Event)
fn push_event(&mut self, event: Event)
Push an event into the backend’s event buffer. Read more
Source§fn set_cursor_visible(&mut self, visible: bool)
fn set_cursor_visible(&mut self, visible: bool)
Show or hide the cursor.
Source§fn set_cursor_position(&mut self, position: Pos)
fn set_cursor_position(&mut self, position: Pos)
Move the cursor to a position.
Source§fn draw_layers<'a, I>(&mut self, content: I)
fn draw_layers<'a, I>(&mut self, content: I)
Draw changed cells across all layers. Read more
Source§fn needs_full_frame(&self) -> bool
fn needs_full_frame(&self) -> bool
Returns
true if the backend needs the entire frame (all cells on
all layers) on every call to draw_layers, rather
than just the changed cells. Read moreSource§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Returns
false if the backend has been disconnected from its
output (e.g. the window was closed). The game loop should
terminate when this returns false. Read moreAuto Trait Implementations§
impl Freeze for Headless
impl RefUnwindSafe for Headless
impl Send for Headless
impl Sync for Headless
impl Unpin for Headless
impl UnsafeUnpin for Headless
impl UnwindSafe for Headless
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