pub struct Buffer { /* private fields */ }Expand description
The text buffer, wrapping a ropey::Rope with position conversion helpers.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn line(&self, line_idx: usize) -> RopeSlice<'_>
pub fn line(&self, line_idx: usize) -> RopeSlice<'_>
Get text of a specific line (0-indexed), including trailing newline if present.
Sourcepub fn line_len(&self, line_idx: usize) -> usize
pub fn line_len(&self, line_idx: usize) -> usize
Number of chars in a given line (excluding trailing line-ending chars). Handles \n, \r\n, and lone \r.
Sourcepub fn char_to_byte(&self, char_idx: usize) -> usize
pub fn char_to_byte(&self, char_idx: usize) -> usize
Convert a char offset to a byte offset.
Sourcepub fn byte_to_char(&self, byte_idx: usize) -> usize
pub fn byte_to_char(&self, byte_idx: usize) -> usize
Convert a byte offset to a char offset.
Sourcepub fn line_to_char(&self, line_idx: usize) -> usize
pub fn line_to_char(&self, line_idx: usize) -> usize
Get the char offset of the start of a line.
Sourcepub fn pos_to_char(&self, pos: Position) -> usize
pub fn pos_to_char(&self, pos: Position) -> usize
Convert a Position (line, col) to a char offset in the rope. Clamps to valid range.
Sourcepub fn char_to_pos(&self, char_idx: usize) -> Position
pub fn char_to_pos(&self, char_idx: usize) -> Position
Convert a char offset to a Position (line, col).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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
Mutably borrows from an owned value. Read more