Skip to main content

Tile

Struct Tile 

Source
pub struct Tile { /* private fields */ }
Expand description

A single drawable tile in the terminal grid.

Each tile occupies one cell on a single layer; a Grid holds up to 256 independent layers of tiles per cell, composited bottom-to-top. Sub-cell pixel offsets (dx, dy) are visual only, they do not affect grid logic or hit-testing. Backends that cannot represent pixel offsets (e.g. CrosstermBackend) ignore them.

A tile does not carry its own multi-codepoint grapheme text (see TileFlags::HAS_EXTRA): that lives in a sparse side-table on the owning Grid, keeping every Tile a small, fully Copy value regardless of whether the egc feature is enabled. Read it back via Grid::grapheme.

Implementations§

Source§

impl Tile

Source

pub fn new(glyph: char, style: Style) -> Self

Creates a new tile with the given glyph and style.

dx and dy default to 0 (no sub-cell offset). glyph’s display width is computed once here (see width) rather than on every render.

Source

pub const fn glyph(&self) -> char

Returns the tile’s glyph (primary codepoint).

Source

pub const fn width(&self) -> u16

Returns the precomputed display (column) width of glyph.

Computed once when the glyph is written (see with_glyph and Grid::write_grapheme), not recomputed on every render. For tiles written via write_grapheme, this reflects the full grapheme cluster’s width, not just the primary codepoint’s.

Source

pub const fn style(&self) -> Style

Returns the tile’s style.

Source

pub const fn dx(&self) -> i16

Returns the sub-cell pixel X offset.

Source

pub const fn dy(&self) -> i16

Returns the sub-cell pixel Y offset.

Source

pub const fn flags(&self) -> TileFlags

Returns the wide-character flags for this tile.

Source

pub const fn is_empty(&self) -> bool

Returns true if nothing has been written to this tile.

Empty tiles are transparent when compositing layers. An explicit space (e.g. Tile::new(' ', style)) is not empty.

Source

pub fn with_glyph(self, glyph: char) -> Self

Sets the glyph for this tile (builder style).

Writing content marks the tile non-empty (see is_empty). Recomputes the cached display width (see width) for the new glyph.

Source

pub const fn with_style(self, style: Style) -> Self

Sets the style for this tile (builder style).

Writing content marks the tile non-empty (see is_empty).

Source

pub const fn with_offset(self, dx: i16, dy: i16) -> Self

Sets the sub-cell pixel offset for this tile (builder style).

Writing content marks the tile non-empty (see is_empty).

Trait Implementations§

Source§

impl Clone for Tile

Source§

fn clone(&self) -> Tile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Tile

Source§

impl Debug for Tile

Source§

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

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

impl Default for Tile

Source§

fn default() -> Self

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

impl Eq for Tile

Source§

impl Hash for Tile

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Tile

Source§

fn eq(&self, other: &Tile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Tile

Auto Trait Implementations§

§

impl Freeze for Tile

§

impl RefUnwindSafe for Tile

§

impl Send for Tile

§

impl Sync for Tile

§

impl Unpin for Tile

§

impl UnsafeUnpin for Tile

§

impl UnwindSafe for Tile

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<C> WithAlpha for C
where C: Copy,

Source§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see AlphaFirst).
Source§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see AlphaLast).