pub struct DisplayDriver<T: DynamicWidget> { /* private fields */ }Expand description
Represents a display driver responsible for handling the interaction between the displays and the terminal.
Implementations§
Source§impl<T: DynamicWidget> DisplayDriver<T>
impl<T: DynamicWidget> DisplayDriver<T>
Sourcepub fn new(widget: T) -> Self
pub fn new(widget: T) -> Self
Convenience method to build a blank display struct with specified dimensions
Sourcepub fn print_display(&self) -> Result<(), Error>
pub fn print_display(&self) -> Result<(), Error>
Sourcepub fn initialize(&mut self) -> Result<(), Error>
pub fn initialize(&mut self) -> Result<(), Error>
Initializes the display driver. This function enables terminal raw mode and sets the dimensions of the screen to match the widget’s dimensions. It enters alternate screen mode, hides the cursor and disables line wrapping.
§Errors
Returns an error when any on the actions above fail. Note that resizing the terminal does not fail, if the terminal does not support it.
pub fn set_on_update<F>(&mut self, on_update: F)
pub const fn set_target_frame_time(&mut self, frame_time: Duration)
pub fn set_target_frame_rate(&mut self, frame_rate: f32)
Sourcepub fn update(&mut self)
pub fn update(&mut self)
This function encapsulates the update loop of the display.
As such it may or may not return depending on the update callback set with
set_on_update.
This function prints the display.
Queries user input and exits on Ctrl-C.
Forwards keystrokes to the provided callback and invokes it.
Sleeps so the target frame rate is not exceeded.
§Panics
This function panics when the display could not be printed.