Skip to main content

Tile

Struct Tile 

Source
pub struct Tile {
    pub(crate) glyph: char,
    pub(crate) style: Style,
    pub(crate) dx: i16,
    pub(crate) dy: i16,
    pub(crate) flags: TileFlags,
    pub(crate) extra: Option<Arc<String>>,
}
Expand description

A single drawable tile in the terminal grid.

Each tile occupies one cell on a single layer (see ADR 008 for the layer model). 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.

Fields§

§glyph: char

Primary codepoint. For ASCII and most Unicode this is the whole story.

§style: Style

Style applied to this tile.

§dx: i16

Pixel offset from the cell’s left edge. Negative shifts left.

Only meaningful for graphical backends (e.g. SoftwareBackend).

§dy: i16

Pixel offset from the cell’s top edge. Negative shifts up.

Only meaningful for graphical backends (e.g. SoftwareBackend).

§flags: TileFlags

Wide-character role flags (e.g. TileFlags::WIDE_CHAR).

Only present when the egc feature is enabled.

§extra: Option<Arc<String>>

Allocated only when the grapheme cluster has more than one codepoint (combining marks, ZWJ emoji sequences, etc.).

When Some, the full EGC string is stored here. The glyph field still holds the first codepoint for fast single-char paths.

Only present when the egc feature is enabled.

Implementations§

Source§

impl Tile

Source

pub const 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).

Source

pub const fn glyph(&self) -> char

Returns the tile’s glyph (primary codepoint).

Source

pub const fn style(&self) -> Style

Returns the tile’s style.

Source

pub const fn flags(&self) -> TileFlags

Returns the wide-character flags for this tile.

Only present when the egc feature is enabled.

Source

pub fn extra(&self) -> Option<&str>

Returns the extra EGC data for this tile, if any.

Some only for multi-codepoint grapheme clusters (combining marks, ZWJ sequences, etc.). None for the common single-codepoint case.

Only present when the egc feature is enabled.

Source

pub fn grapheme(&self) -> Option<&str>

Returns the full grapheme cluster for this tile.

When the tile contains a multi-codepoint EGC (combining marks, ZWJ sequences, etc.) this returns the stored string. For the common single-codepoint case it returns None; use glyph and encode_utf8 to reconstruct the string.

Only present when the egc feature is enabled.

Source

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

Sets the glyph for this tile (builder style).

Source

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

Sets the style for this tile (builder style).

Source

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

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

Source

pub(crate) fn reset(&mut self)

Resets this tile to the default (space, default style, no offset).

Trait Implementations§

Source§

impl Clone for Tile

Source§

fn clone(&self) -> Tile

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
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 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Tile

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.