pub struct Window { /* private fields */ }
Expand description
The main window behind the application. Represents the terminal window, allowing it to be used similar to a buffer, but has extra event handling.
use ascii_forge::prelude::*;
let mut window = Window::init()?;
render!(
window,
[
(10, 10) => "Element Here!"
]
)
Implementations§
Source§impl Window
impl Window
Sourcepub fn new(io: Stdout) -> Result<Self>
pub fn new(io: Stdout) -> Result<Self>
Creates a new window from the given stdout. Please prefer to use init as it will do all of the terminal init stuff.
Sourcepub fn new_inline(io: Stdout, height: u16) -> Result<Self>
pub fn new_inline(io: Stdout, height: u16) -> Result<Self>
Creates a new window built for inline using the given Stdout and height.
Sourcepub fn init_inline(height: u16) -> Result<Self>
pub fn init_inline(height: u16) -> Result<Self>
Initializes a window that is prepared for inline rendering. Height is the number of columns that your terminal will need.
Sourcepub fn buffer_mut(&mut self) -> &mut Buffer
pub fn buffer_mut(&mut self) -> &mut Buffer
Returns the active Buffer, as a mutable reference.
Sourcepub fn swap_buffers(&mut self)
pub fn swap_buffers(&mut self)
Swaps the buffers, clearing the old buffer. Used automatically by the window’s update method.
Sourcepub fn restore(&mut self) -> Result<()>
pub fn restore(&mut self) -> Result<()>
Restores the window to it’s previous state from before the window’s init method. If the window is inline, restore the inline render
Sourcepub fn render(&mut self) -> Result<()>
pub fn render(&mut self) -> Result<()>
Renders the window to the screen. should really only be used by the update method, but if you need a custom system, you can use this.
Sourcepub fn handle_event(&mut self, poll: Duration) -> Result<()>
pub fn handle_event(&mut self, poll: Duration) -> Result<()>
Handles events. Used automatically by the update method, so no need to use it unless update is being used.
pub fn mouse_pos(&self) -> Vec2
Sourcepub fn hover<V: Into<Vec2>>(&self, loc: V, size: V) -> Result<bool>
pub fn hover<V: Into<Vec2>>(&self, loc: V, size: V) -> Result<bool>
Returns true if the mouse cursor is hovering the given rect.