Struct termit::Screen

source ·
pub struct Screen {
    pub wipe: bool,
    pub true_color: bool,
    /* private fields */
}
Expand description

Terminal screen buffer

It helps prevent unnecessary trafic to the terminal:

  • collect all the painting in one cycle, then print the result
  • print only the diff between last and new cycle

You probably won’t use it directly and instead use the crate::Painter. If you do, however, it should be fairly straightforward.

Fields§

§wipe: bool§true_color: bool

Implementations§

source§

impl Screen

source

pub fn new(size: Point) -> Self

New screen buffer of the given size

source

pub fn clear(&mut self)

Clear the buffer

source

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

source

pub fn size(&self) -> Point

source

pub fn set_last_write(&mut self, pos: Point)

Set the position of the last write

source

pub fn last_write(&self) -> Option<Point>

Get the position of the last write

source

pub fn get(&self, point: Point) -> Option<(&ScreenStyle, &str)>

Get a symbol at given coordinates

If the coordinates are out of bounds or if the symbol is not set you get None

source

pub fn get_idx(&self, idx: usize) -> Option<(&ScreenStyle, &str)>

Get a symbol at given order index

If the coordinates are out of bounds or if the symbol is not set you get None

source

pub fn set( &mut self, point: Point, style: impl Into<ScreenStyle>, symbol: impl AsRef<str> )

Set a symbol at given coordinates

If the coordinates are out of bounds the symbol is ignored

source

pub fn set_idx( &mut self, idx: usize, style: impl Into<ScreenStyle>, symbol: impl AsRef<str> )

Set a symbol at given order index

If the coordinates are out of bounds the symbol is ignored

source

pub fn symbols<'a>( &'a self ) -> impl Iterator<Item = (Point, &'a ScreenStyle, &'a str)> + 'a

Dump all the currently set screen symbols

source

pub fn diffs<'a>( &'a mut self, scope: Option<Window>, refresh: bool ) -> impl Iterator<Item = (Point, &'a ScreenStyle, &'a str)>

Trait Implementations§

source§

impl Debug for Screen

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Screen

source§

fn default() -> Screen

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Screen

§

impl Send for Screen

§

impl !Sync for Screen

§

impl Unpin for Screen

§

impl UnwindSafe for Screen

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, 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.