pub struct TermGrid<E, S> { /* private fields */ }term only.Expand description
๐ฎ ๐๏ธ A dense row-major grid of terminal-space elements.
๐ sys/os/term/grid::TermGrid
The grid occupies the first width ร height elements of its storage.
Any remaining storage is retained but lies outside the grid.
ยงMethods
-
- as_mut_slice.
- storage_slice_mut.
- get_mut (xy).
- row_mut.
- set (xy).
-
- fill_region.
- hline.
- vline.
- frame.
Implementationsยง
Sourceยงimpl<E, S: AsRef<[E]>> TermGrid<E, S>
ยงConstruction and structural access
impl<E, S: AsRef<[E]>> TermGrid<E, S>
ยงConstruction and structural access
Sourcepub fn new(storage: S, extent: Extent2<usize>) -> Result<Self, TermGridError> โ
pub fn new(storage: S, extent: Extent2<usize>) -> Result<Self, TermGridError> โ
Creates a grid over the active prefix of storage.
ยงErrors
Returns an error if the extent overflows or the storage is too short.
Sourcepub fn into_storage(self) -> S
pub fn into_storage(self) -> S
Consumes the grid and returns its backing storage.
Sourcepub fn storage_slice(&self) -> &[E] โ
pub fn storage_slice(&self) -> &[E] โ
Returns the complete backing-storage slice.
Sourceยงimpl<E, S: AsRef<[E]>> TermGrid<E, S>
ยงCoordinate queries
impl<E, S: AsRef<[E]>> TermGrid<E, S>
ยงCoordinate queries
Sourcepub const fn contains(&self, pos: Position2<usize>) -> bool
pub const fn contains(&self, pos: Position2<usize>) -> bool
Returns whether the position lies within the grid.
Sourcepub const fn index_of(&self, pos: Position2<usize>) -> Option<usize> โ
pub const fn index_of(&self, pos: Position2<usize>) -> Option<usize> โ
Returns the row-major index of pos, or None when outside the grid.
Sourcepub const fn position_of(&self, index: usize) -> Option<Position2<usize>> โ
pub const fn position_of(&self, index: usize) -> Option<Position2<usize>> โ
Returns the position of an active row-major index.
Sourceยงimpl<E, S: AsRef<[E]> + AsMut<[E]>> TermGrid<E, S>
ยงMutable access
impl<E, S: AsRef<[E]> + AsMut<[E]>> TermGrid<E, S>
ยงMutable access
Sourcepub fn as_mut_slice(&mut self) -> &mut [E] โ
pub fn as_mut_slice(&mut self) -> &mut [E] โ
Returns the active row-major grid elements exclusively.
Sourcepub fn storage_slice_mut(&mut self) -> &mut [E] โ
pub fn storage_slice_mut(&mut self) -> &mut [E] โ
Returns the complete backing-storage slice exclusively.
Sourcepub fn get_mut(&mut self, pos: Position2<usize>) -> Option<&mut E> โ
pub fn get_mut(&mut self, pos: Position2<usize>) -> Option<&mut E> โ
Returns the element at pos exclusively.
Sourcepub fn get_xy_mut(&mut self, x: usize, y: usize) -> Option<&mut E> โ
pub fn get_xy_mut(&mut self, x: usize, y: usize) -> Option<&mut E> โ
Returns the element at the given coordinates exclusively.
Sourcepub fn row_mut(&mut self, y: usize) -> Option<&mut [E]> โ
pub fn row_mut(&mut self, y: usize) -> Option<&mut [E]> โ
Returns the active row exclusively.
Sourceยงimpl<E: Copy, S: AsRef<[E]> + AsMut<[E]>> TermGrid<E, S>
ยงCopy-oriented operations
impl<E: Copy, S: AsRef<[E]> + AsMut<[E]>> TermGrid<E, S>
ยงCopy-oriented operations
Sourceยงimpl<S: Copy, C: Copy, D> TermGrid<Termel<char, S, C>, D>
ยงText drawing
impl<S: Copy, C: Copy, D> TermGrid<Termel<char, S, C>, D>
ยงText drawing
Sourcepub fn write_str_at(
&mut self,
position: Position2<usize>,
text: &str,
pen: TermPen<S, C>,
) -> usize
pub fn write_str_at( &mut self, position: Position2<usize>, text: &str, pen: TermPen<S, C>, ) -> usize
Writes width-one Unicode scalars horizontally at position.
Writing stops at the right grid edge. No wrapping, line-break handling, grapheme segmentation, or terminal-width calculation is performed.
Returns the number of cells written.
Sourceยงimpl<E: Copy, S: AsRef<[E]> + AsMut<[E]>> TermGrid<E, S>
ยงRegion drawing
impl<E: Copy, S: AsRef<[E]> + AsMut<[E]>> TermGrid<E, S>
ยงRegion drawing
Sourcepub fn fill_region(&mut self, region: RegionS2<usize>, element: impl Into<E>)
pub fn fill_region(&mut self, region: RegionS2<usize>, element: impl Into<E>)
Fills the part of region lying within the grid.
Regions extending beyond the grid are clipped.
Sourcepub fn hline(&mut self, x: usize, y: usize, len: usize, element: impl Into<E>)
pub fn hline(&mut self, x: usize, y: usize, len: usize, element: impl Into<E>)
Fills a clipped horizontal span.
Trait Implementationsยง
impl<E: Copy, S: Copy> Copy for TermGrid<E, S>
impl<E: Eq, S: Eq> Eq for TermGrid<E, S>
impl<E: PartialEq, S: PartialEq> StructuralPartialEq for TermGrid<E, S>
Auto Trait Implementationsยง
impl<E, S> Freeze for TermGrid<E, S>
impl<E, S> RefUnwindSafe for TermGrid<E, S>
impl<E, S> Send for TermGrid<E, S>
impl<E, S> Sync for TermGrid<E, S>
impl<E, S> Unpin for TermGrid<E, S>
impl<E, S> UnsafeUnpin for TermGrid<E, S>
impl<E, S> UnwindSafe for TermGrid<E, S>
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.