Skip to main content

Screen

Struct Screen 

Source
pub struct Screen<W: Write> { /* private fields */ }
Expand description

The image on the terminal, and the promise to take it back.

Generic over its sink for super::chrome::Chrome’s reason, which is sharper here: every byte this writes is invisible to every other kind of test, and the one that matters most — an image left in the terminal’s memory after the process has gone — is invisible to the reader too.

Implementations§

Source§

impl<W: Write> Screen<W>

Source

pub fn new(out: W, allowed: bool) -> Self

A screen that will draw if allowed, and never otherwise.

Source

pub fn mapping(&self, cell: Option<(u16, u16)>) -> Maps

Whether a map could appear at all, given what the terminal has just said one cell measures — None when it will not say.

The one predicate, asked here rather than in two places: this is the half of the answer only the screen knows, and the cell size is the half only the terminal knows, and #656 was those two halves being combined nowhere. Asked every frame, because only one of them is a constant: a window can lose its pixel fields without the program at the other end changing — a tmux client attaching, a pane moving between displays.

Source

pub fn show(&mut self, view: &View, pane: Pane, now: Instant) -> Result<Drawn>

Draws the map of whatever the cursor is on, if anything has changed since the last one.

Answers what it left on the screen rather than Ok(()): see Drawn, and #656 for what a silent decline costs.

§Errors

Anything the terminal refuses.

Source

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

Takes the image down, if one is up.

Called whenever the map cannot be right: an overlay is over it, the terminal has no room, or the reader turned it off. Forgetting the fingerprint with it is the part that is easy to miss — a map hidden behind the help page and then unhidden is the same picture, so a show that only compared fingerprints would leave the pane blank for as long as nothing else changed.

§Errors

Anything the terminal refuses.

Source

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

Puts back everything this took, and can be called twice.

The state being given back here lives in another program’s memory: an image is stored by the terminal, and a process that exits without deleting one leaves a megabyte behind with nothing alive to notice. #619’s rule — a state that cannot be given back is a state you do not take — with the same answer, an id and a delete.

§Errors

Anything the terminal refuses.

Trait Implementations§

Source§

impl<W: Debug + Write> Debug for Screen<W>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for Screen<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for Screen<W>
where W: RefUnwindSafe,

§

impl<W> Send for Screen<W>
where W: Send,

§

impl<W> Sync for Screen<W>
where W: Sync,

§

impl<W> Unpin for Screen<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Screen<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for Screen<W>
where W: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.