pub struct TabMap<'a> { /* private fields */ }Expand description
The coordinates seam — a concrete type, not a trait.
Its entire durable state is tab_size; it holds no persisted visual
indices, so there is nothing derived that could drift out of sync with the
text. Built per frame from the document’s tab_size plus a borrow of the
buffer’s line index, so every conversion reads live text and the map is
current by construction.
Every method that can land on a lossy position (mid-tab, or inside a fold at
the layer above) threads Bias from the start, so no call site needs
retrofitting when a new lossy case appears.
Implementations§
Source§impl<'a> TabMap<'a>
impl<'a> TabMap<'a>
Sourcepub fn new(lines: &'a Buffer, tab_size: u32) -> Self
pub fn new(lines: &'a Buffer, tab_size: u32) -> Self
A map over lines with the given tab stop width. tab_size is expected
to be ≥ 1 (see default_tab_size).
Sourcepub fn to_display(&self, point: Point, _bias: Bias) -> DisplayPoint
pub fn to_display(&self, point: Point, _bias: Bias) -> DisplayPoint
Buffer → display. point.col is a char-boundary byte column (the buffer
guarantees this); the result column is cells. Total: every valid buffer
point maps to exactly one display point, so bias is irrelevant here.
Sourcepub fn to_buffer(&self, point: DisplayPoint, bias: Bias) -> Point
pub fn to_buffer(&self, point: DisplayPoint, bias: Bias) -> Point
Display → buffer, with the bias snap: if point.col falls strictly
inside a tab expansion it is not a caret slot — Left yields the byte of
the \t, Right the byte after it.
Sourcepub fn clip(&self, point: DisplayPoint, bias: Bias) -> DisplayPoint
pub fn clip(&self, point: DisplayPoint, bias: Bias) -> DisplayPoint
Sourcepub fn max_point(&self) -> DisplayPoint
pub fn max_point(&self) -> DisplayPoint
The bottom-right valid position: the last row and its cell length.
Sourcepub fn row_count(&self) -> u32
pub fn row_count(&self) -> u32
Number of display rows in this map — the buffer line count. (Hiding
rows is the FoldMap layer’s job, above this one.)
Sourcepub fn line_len(&self, row: DisplayRow) -> u32
pub fn line_len(&self, row: DisplayRow) -> u32
Cell width of a display row (the whole line expanded).
Sourcepub fn row_info(&self, row: DisplayRow) -> Option<BufferRow>
pub fn row_info(&self, row: DisplayRow) -> Option<BufferRow>
Gutter protocol: the buffer line number to print. Always Some in this
map; the Option lets a caller handle a display row that has no printed
line number.
Sourcepub fn sync(&mut self, _buffer_patch: &Patch)
pub fn sync(&mut self, _buffer_patch: &Patch)
Consume the transaction’s buffer-space edit patch and splice any internal
derived state. Returns (): downstream caches (line cache, paragraph
cache) invalidate off the buffer-space LineSplice they already consume,
so no display-space edit vector is emitted — widen to Vec<DisplayEdit>
only if a display-space reader ever appears. The map holds no derived
state, so this is a no-op; the borrow of live buffer text keeps every
conversion current by construction.
Sourcepub fn max_row(&self) -> DisplayRow
pub fn max_row(&self) -> DisplayRow
The last display row. row_count − 1, saturating.