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>
impl<W: Write> Screen<W>
Sourcepub fn new(out: W, allowed: bool) -> Self
pub fn new(out: W, allowed: bool) -> Self
A screen that will draw if allowed, and never otherwise.
Sourcepub fn mapping(&self, cell: Option<(u16, u16)>) -> Maps
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.
Sourcepub fn hide(&mut self) -> Result<()>
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.
Sourcepub fn restore(&mut self) -> Result<()>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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