pub struct CellContent(/* private fields */);Expand description
Cell content: either a direct Unicode char or a reference to a grapheme cluster.
§Encoding Scheme (4 bytes)
Bit 31 (type discriminator):
0: Direct char (bits 0-20 contain Unicode scalar value, max U+10FFFF)
1: GraphemeId reference (bits 0-30 contain slot + width)This allows:
- 99% of cells (ASCII/BMP) to be stored without heap allocation
- Complex graphemes (emoji, ZWJ sequences) stored in pool
§Special Values
EMPTY(0x0): Empty cell, width 0CONTINUATION(0x1): Placeholder for wide character continuation
Implementations§
Source§impl CellContent
impl CellContent
Sourcepub const EMPTY: CellContent
pub const EMPTY: CellContent
Empty cell content (no character).
Sourcepub const CONTINUATION: CellContent
pub const CONTINUATION: CellContent
Continuation marker for wide characters.
When a character has display width > 1, subsequent cells are filled with this marker to indicate they are part of the previous character.
Value is 0x7FFF_FFFF (max i32), which is outside valid Unicode scalar
range (0..0x10FFFF) but fits in 31 bits (Direct Char mode).
Sourcepub const fn from_char(c: char) -> CellContent
pub const fn from_char(c: char) -> CellContent
Create content from a single Unicode character.
For characters with display width > 1, subsequent cells should be
filled with CONTINUATION.
§Tab Handling
The tab character \t is normalized to a space. This prevents cursor
desynchronization, as the Presenter cannot predict terminal tab stops.
Sourcepub const fn from_grapheme(id: GraphemeId) -> CellContent
pub const fn from_grapheme(id: GraphemeId) -> CellContent
Create content from a grapheme ID (for multi-codepoint clusters).
The grapheme ID references an entry in the GraphemePool.
Sourcepub const fn is_grapheme(self) -> bool
pub const fn is_grapheme(self) -> bool
Check if this content is a grapheme reference (vs direct char).
Sourcepub const fn is_continuation(self) -> bool
pub const fn is_continuation(self) -> bool
Check if this is a continuation cell (part of a wide character).
Sourcepub const fn is_default(self) -> bool
pub const fn is_default(self) -> bool
Check if this content is the default value.
This is equivalent to is_empty() and primarily exists for readability in tests.
Sourcepub fn as_char(self) -> Option<char>
pub fn as_char(self) -> Option<char>
Extract the character if this is a direct char (not a grapheme).
Returns None if this is empty, continuation, or a grapheme reference.
Sourcepub const fn grapheme_id(self) -> Option<GraphemeId>
pub const fn grapheme_id(self) -> Option<GraphemeId>
Extract the grapheme ID if this is a grapheme reference.
Returns None if this is a direct char.
Sourcepub const fn width_hint(self) -> usize
pub const fn width_hint(self) -> usize
Get the display width of this content.
- Empty: 0
- Continuation: 0
- Grapheme: width embedded in GraphemeId
- Char: requires external width lookup (returns 1 as default for ASCII)
Note: For accurate char width, use the unicode-display-width-based helpers in this crate. This method provides a fast path for known cases.
Trait Implementations§
Source§impl Clone for CellContent
impl Clone for CellContent
Source§fn clone(&self) -> CellContent
fn clone(&self) -> CellContent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CellContent
impl Debug for CellContent
Source§impl Default for CellContent
impl Default for CellContent
Source§fn default() -> CellContent
fn default() -> CellContent
Source§impl Hash for CellContent
impl Hash for CellContent
Source§impl PartialEq for CellContent
impl PartialEq for CellContent
impl Copy for CellContent
impl Eq for CellContent
impl StructuralPartialEq for CellContent
Auto Trait Implementations§
impl Freeze for CellContent
impl RefUnwindSafe for CellContent
impl Send for CellContent
impl Sync for CellContent
impl Unpin for CellContent
impl UnsafeUnpin for CellContent
impl UnwindSafe for CellContent
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> 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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.