Struct Window

Source
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

Source

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.

Source

pub fn new_inline(io: Stdout, height: u16) -> Result<Self>

Creates a new window built for inline using the given Stdout and height.

Source

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.

Source

pub fn init() -> Result<Self>

Initializes the window, and returns a new Window for your use.

Source

pub fn keyboard(&mut self) -> Result<()>

Enables the kitty keyboard protocol

Source

pub fn buffer(&self) -> &Buffer

Returns the active Buffer, as a reference.

Source

pub fn buffer_mut(&mut self) -> &mut Buffer

Returns the active Buffer, as a mutable reference.

Source

pub fn swap_buffers(&mut self)

Swaps the buffers, clearing the old buffer. Used automatically by the window’s update method.

Source

pub fn size(&self) -> Vec2

Returns the current known size of the buffer’s window.

Source

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

Source

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.

Source

pub fn update(&mut self, poll: Duration) -> Result<()>

Handles events, and renders the screen.

Source

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.

Source

pub fn mouse_pos(&self) -> Vec2

Source

pub fn events(&self) -> &Vec<Event>

Returns the current event for the frame, as a reference.

Source

pub fn hover<V: Into<Vec2>>(&self, loc: V, size: V) -> Result<bool>

Returns true if the mouse cursor is hovering the given rect.

Source

pub fn io(&mut self) -> &mut Stdout

Trait Implementations§

Source§

impl AsMut<Buffer> for Window

Source§

fn as_mut(&mut self) -> &mut Buffer

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl Default for Window

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Window

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Window

§

impl RefUnwindSafe for Window

§

impl Send for Window

§

impl Sync for Window

§

impl Unpin for Window

§

impl UnwindSafe for Window

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.