pub struct TextBuffer { /* private fields */ }Expand description
A text buffer backed by a ropey::Rope.
Every mutating operation increments an internal revision counter so that downstream systems (layout caches, syntax highlights, diagnostics, etc.) can cheaply detect stale data.
Implementations§
Source§impl TextBuffer
impl TextBuffer
Source§impl TextBuffer
impl TextBuffer
Sourcepub fn len_chars(&self) -> usize
pub fn len_chars(&self) -> usize
Total length in Unicode characters (grapheme-unaware; counts chars).
Sourcepub fn len_lines(&self) -> usize
pub fn len_lines(&self) -> usize
Number of lines. A trailing \n implies an additional empty final
line, matching the convention used by most editors.
Sourcepub fn line(&self, line_idx: usize) -> RopeSlice<'_>
pub fn line(&self, line_idx: usize) -> RopeSlice<'_>
Return the contents of line_idx (0-based) as a ropey::RopeSlice,
including the line terminator if present.
§Panics
Panics if line_idx >= self.len_lines().
Sourcepub fn slice(&self, byte_range: Range<usize>) -> RopeSlice<'_>
pub fn slice(&self, byte_range: Range<usize>) -> RopeSlice<'_>
Return an arbitrary byte-offset range as a RopeSlice.
Both bounds are byte offsets and must lie on char boundaries.
§Panics
Panics if the range is out of bounds or not on char boundaries.
Source§impl TextBuffer
impl TextBuffer
Sourcepub fn insert(&mut self, byte_offset: usize, text: &str)
pub fn insert(&mut self, byte_offset: usize, text: &str)
Insert text at the given byte offset.
§Panics
Panics if byte_offset is out of bounds or not on a char boundary.
Trait Implementations§
Source§impl Clone for TextBuffer
impl Clone for TextBuffer
Source§fn clone(&self) -> TextBuffer
fn clone(&self) -> TextBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more