Struct tuig_ui::Screen

source ·
pub struct Screen { /* private fields */ }
Expand description

A text framebuffer.

Allows you to render things onto it, then can be rendered onto the screen. This strategy avoids flickering, partial renders, etc. and helps deduplicate rendering effort.

Implementations§

source§

impl Screen

source

pub fn new(size: XY) -> Screen

Create a new Screen in the given size.

source

pub fn size(&self) -> XY

How big this Screen is, in characters.

source

pub fn cells(&self) -> &[Cell]

All of the cells of this screen, in row-major order.

i.e. for the screen:

1 2
3 4

this will return &[1, 2, 3, 4].

source

pub fn cells_mut(&mut self) -> &mut [Cell]

All of the cells of this screen, in row-major order, mutably.

source

pub fn rows(&self) -> impl Iterator<Item = &[Cell]>

Returns an iterator over the rows in a screen.

source

pub fn clear(&mut self)

Clear this screen’s contents, resetting it to the default and filling it with blank cells.

source

pub fn resize(&mut self, size: XY)

Resize the screen, clearing its contents at the same time. Does not reallocate unless the screen is growing.

source

pub fn write(&mut self, pos: XY, text: Vec<Text>)

Write some formatted text to the position on screen.

This does not handle newlines or anything else. If you want that, use a UI widget.

Trait Implementations§

source§

impl Clone for Screen

source§

fn clone(&self) -> Screen

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Screen

source§

fn default() -> Screen

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

impl Index<usize> for Screen

§

type Output = [Cell]

The returned type after indexing.
source§

fn index(&self, row: usize) -> &<Screen as Index<usize>>::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Screen

source§

fn index_mut(&mut self, row: usize) -> &mut <Screen as Index<usize>>::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl PartialEq for Screen

source§

fn eq(&self, other: &Screen) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Screen

source§

impl StructuralEq for Screen

source§

impl StructuralPartialEq for Screen

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.