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.
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.
pub fn render_cursor(&mut self) -> Result<()>
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.
Sourcepub fn cursor_visible(&self) -> bool
pub fn cursor_visible(&self) -> bool
Returns whether the cursor is visible
Sourcepub fn cursor_style(&self) -> SetCursorStyle
pub fn cursor_style(&self) -> SetCursorStyle
Returns the current cursor style
Sourcepub fn set_cursor_visible(&mut self, visible: bool)
pub fn set_cursor_visible(&mut self, visible: bool)
Sets the cursor visibility
Sourcepub fn set_cursor(&mut self, pos: Vec2)
pub fn set_cursor(&mut self, pos: Vec2)
Sets the cursor position, clamping to window bounds
Sourcepub fn set_cursor_style(&mut self, style: SetCursorStyle)
pub fn set_cursor_style(&mut self, style: SetCursorStyle)
Sets the cursor style
Sourcepub fn move_cursor(&mut self, x: i16, y: i16)
pub fn move_cursor(&mut self, x: i16, y: i16)
Move the cursor by a given distance
pub fn mouse_pos(&self) -> Vec2
Sourcepub fn insert_event(&mut self, event: Event)
pub fn insert_event(&mut self, event: Event)
Pushes an event into the state Could be usefull with a custom event loop or for keyboard control from elsewhere
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.