Skip to main content

View

Struct View 

Source
pub struct View<'a, T: ?Sized> { /* private fields */ }
Expand description

Borrowed sub-rect over an existing surface.

Implementations§

Source§

impl<'a, T: Bounded + ?Sized> View<'a, T>

Source

pub fn new(inner: &'a mut T, bounds: impl Into<Rect>) -> Self

New view bound to the intersection of bounds and inner.bounds(). If they are disjoint, the resulting view is empty.

Source

pub fn inner_mut(&mut self) -> &mut T

Reborrow the inner surface mutably. Useful when the view itself is borrowed but the caller needs to escape the clip.

Trait Implementations§

Source§

impl<T: Bounded + ?Sized> Bounded for View<'_, T>

Source§

fn bounds(&self) -> Rect

Return the valid region in this value’s own coordinate space. Read more
Source§

fn width(&self) -> u16

Return the width of Self::bounds in terminal cell columns. Read more
Source§

fn height(&self) -> u16

Return the height of Self::bounds in terminal cell rows. Read more
Source§

fn contains(&self, pos: Position) -> bool

Test whether a position lies inside Self::bounds. Read more
Source§

impl<'a, T: Debug + ?Sized> Debug for View<'a, T>

Source§

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

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

impl<T: Surface + ?Sized> Surface for View<'_, T>

Source§

fn cell(&self, pos: Position) -> Option<&Cell>

Read the cell at a position. Read more
Source§

fn draw<T: SurfaceMut + ?Sized>(&self, target: &mut T, at: Position)

Copy self’s cells into target, mapping the top-left of self.bounds() to at in target coordinates. Read more
Source§

impl<T: SurfaceMut + ?Sized> SurfaceMut for View<'_, T>

Source§

fn set_cell(&mut self, pos: Position, cell: &Cell)

Place cell at pos. Implementations are responsible for wide-cell semantics (continuation markers, blanking covered cells) and any dirty tracking they care to do. Taking &Cell lets implementations skip the clone when the destination already matches. Read more
Source§

fn cell_mut(&mut self, pos: Position) -> Option<&mut Cell>

Mutable handle to the cell at pos. Returns None for out-of-bounds positions. Read more
Source§

fn fill(&mut self, cell: &Cell)

Fill the entire surface bounds with cell. Read more
Source§

fn fill_rect(&mut self, rect: Rect, cell: &Cell)

Fill the intersection of rect and Bounded::bounds with cell. Read more
Source§

fn clear(&mut self)

Clear the entire surface bounds to Cell::BLANK. Read more
Source§

fn clear_rect(&mut self, rect: Rect)

Clear a rectangle to Cell::BLANK. Read more
Source§

fn insert_lines(&mut self, y: u16, n: u16, bounds_bottom: u16, fill: &Cell)

Insert n blank rows at y, pushing existing rows down within [y, bounds_bottom). Rows pushed past bounds_bottom are lost. Freed top rows are filled with fill. Read more
Source§

fn delete_lines(&mut self, y: u16, n: u16, bounds_bottom: u16, fill: &Cell)

Delete n rows at y, pulling existing rows up within [y, bounds_bottom). The bottom n rows of the window are filled with fill. Read more
Source§

fn insert_cells( &mut self, pos: Position, n: u16, bounds_right: u16, fill: &Cell, )

Insert n blank cells at pos, pushing cells in [pos.x, bounds_right) right within row pos.y. Cells pushed past bounds_right are lost. The freed slots [pos.x, pos.x + n) are filled with fill. Read more
Source§

fn delete_cells( &mut self, pos: Position, n: u16, bounds_right: u16, fill: &Cell, )

Delete n cells at pos, pulling cells in [pos.x + n, bounds_right) left within row pos.y. The freed slots [bounds_right - n, bounds_right) are filled with fill. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for View<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for View<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for View<'a, T>
where T: Send + ?Sized,

§

impl<'a, T> Sync for View<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for View<'a, T>
where T: ?Sized,

§

impl<'a, T> UnsafeUnpin for View<'a, T>
where T: ?Sized,

§

impl<'a, T> !UnwindSafe for View<'a, T>

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<S> Encode for S
where S: Surface + ?Sized,

Source§

fn encode<W: Write>(&self, w: &mut W) -> Result<()>

Write the surface to w as escape sequences and text. Read more
Source§

fn encode_with<W: Write>(&self, w: &mut W, profile: Profile) -> Result<()>

Write the surface to w, downsampling colors to profile. Read more
Source§

fn display(&self) -> SurfaceDisplay<'_, Self>

Borrow the surface as a Display adapter. Read more
Source§

fn display_with(&self, profile: Profile) -> SurfaceDisplay<'_, Self>

Borrow the surface as a Display adapter that downsamples colors to profile. 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.
§

impl<T> ErasedDestructor for T
where T: 'static,