pub struct Engine { /* private fields */ }Expand description
The main Flywheel engine.
This coordinates between the input and render actors, providing a simple interface for applications.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new engine with default configuration.
§Errors
Returns an error if terminal setup fails (raw mode, alternate screen, etc.).
Sourcepub fn with_config(config: EngineConfig) -> Result<Self>
pub fn with_config(config: EngineConfig) -> Result<Self>
Sourcepub const fn buffer_mut(&mut self) -> &mut Buffer
pub const fn buffer_mut(&mut self) -> &mut Buffer
Get a mutable reference to the buffer.
Sourcepub const fn input_receiver(&self) -> &Receiver<InputEvent>
pub const fn input_receiver(&self) -> &Receiver<InputEvent>
Get the input receiver for event-driven loops.
Sourcepub const fn is_running(&self) -> bool
pub const fn is_running(&self) -> bool
Check if the engine is still running.
Sourcepub fn poll_input(&self) -> Option<InputEvent>
pub fn poll_input(&self) -> Option<InputEvent>
Poll for the next input event (non-blocking).
Returns None if no event is available.
Sourcepub fn wait_input(&self, timeout: Duration) -> Option<InputEvent>
pub fn wait_input(&self, timeout: Duration) -> Option<InputEvent>
Wait for the next input event (blocking with timeout).
Sourcepub fn drain_input(&self) -> Vec<InputEvent>
pub fn drain_input(&self) -> Vec<InputEvent>
Drain all pending input events.
Sourcepub fn request_redraw(&self)
pub fn request_redraw(&self)
Request a full redraw.
Sourcepub fn request_update(&self)
pub fn request_update(&self)
Request a diff-based update.
Sourcepub fn set_cursor(&self, x: Option<u16>, y: u16)
pub fn set_cursor(&self, x: Option<u16>, y: u16)
Set the cursor position (or hide it).
Sourcepub fn handle_resize(&mut self, width: u16, height: u16)
pub fn handle_resize(&mut self, width: u16, height: u16)
Handle a resize event.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Begin a new frame.
Call this at the start of your render loop.
Sourcepub fn end_frame(&mut self)
pub fn end_frame(&mut self)
End a frame and request update.
This will sleep if necessary to maintain the target FPS.
Sourcepub const fn frame_count(&self) -> u64
pub const fn frame_count(&self) -> u64
Get the current frame count.