pub struct LineLayout {
pub len_bytes: usize,
pub width: u16,
/* private fields */
}Expand description
A laid-out line: grapheme spans in order.
Fields§
§len_bytes: usizeThe line’s byte length (cursor-at-end needs it).
width: u16Total rendered width in cells.
Implementations§
Source§impl LineLayout
impl LineLayout
Sourcepub fn build(text: &str, tab: u16) -> Self
pub fn build(text: &str, tab: u16) -> Self
Lay out one line’s text (no trailing newline). tab is the tab
stop; control chars render zero-width (terminals show them raw).
Sourcepub fn spans(&self) -> &[GraphemeSpan]
pub fn spans(&self) -> &[GraphemeSpan]
The grapheme spans, in order.
Sourcepub fn cell_at_byte(&self, byte: usize) -> u16
pub fn cell_at_byte(&self, byte: usize) -> u16
Display cell where a byte offset renders (cursor placement). A byte mid-cluster maps to the cluster’s cell; at/past the end maps to the line’s end cell (vim’s virtual cursor position).
Sourcepub fn byte_at_cell(&self, cell: u16) -> usize
pub fn byte_at_cell(&self, cell: u16) -> usize
Byte offset of the cluster at a display cell (mouse hit-testing, desired-column). A cell inside a wide cluster maps to its start; past the end maps to the line’s byte length… caller clamps.
Sourcepub fn is_ascii_fast(&self) -> bool
pub fn is_ascii_fast(&self) -> bool
Is the line free of wide/zero-width complications? Hot paths may skip the layout for the common ASCII case.
Trait Implementations§
Source§impl Clone for LineLayout
impl Clone for LineLayout
Source§fn clone(&self) -> LineLayout
fn clone(&self) -> LineLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more