pub struct LineIndex { /* private fields */ }Expand description
Logical line index - implemented using Rope data structure
Rope provides O(log N) line access, insertion, and deletion performance, suitable for large file editing
Implementations§
Source§impl LineIndex
impl LineIndex
Sourcepub fn append_line(&mut self, line: LineMetadata)
pub fn append_line(&mut self, line: LineMetadata)
Append a new line
Sourcepub fn insert_line(&mut self, line_number: usize, line: LineMetadata)
pub fn insert_line(&mut self, line_number: usize, line: LineMetadata)
Insert a line at the specified position
Sourcepub fn delete_line(&mut self, line_number: usize)
pub fn delete_line(&mut self, line_number: usize)
Delete the specified line
Sourcepub fn get_line(&self, line_number: usize) -> Option<LineMetadata>
pub fn get_line(&self, line_number: usize) -> Option<LineMetadata>
Get metadata for the specified line number (simulated)
Sourcepub fn get_line_mut(&mut self, line_number: usize) -> Option<&mut LineMetadata>
pub fn get_line_mut(&mut self, line_number: usize) -> Option<&mut LineMetadata>
Get mutable reference (Rope doesn’t need this method, kept for compatibility)
Sourcepub fn line_to_offset(&self, line_number: usize) -> usize
pub fn line_to_offset(&self, line_number: usize) -> usize
Get byte offset for line number (excluding newlines of previous lines)
Sourcepub fn offset_to_line(&self, offset: usize) -> usize
pub fn offset_to_line(&self, offset: usize) -> usize
Get line number from byte offset (offset excludes newlines)
Sourcepub fn char_offset_to_position(&self, char_offset: usize) -> (usize, usize)
pub fn char_offset_to_position(&self, char_offset: usize) -> (usize, usize)
Get line number and offset within line from character offset
Sourcepub fn position_to_char_offset(&self, line: usize, column: usize) -> usize
pub fn position_to_char_offset(&self, line: usize, column: usize) -> usize
Get character offset from line number and column number
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get total line count
Sourcepub fn byte_count(&self) -> usize
pub fn byte_count(&self) -> usize
Get total byte count
Sourcepub fn char_count(&self) -> usize
pub fn char_count(&self) -> usize
Get total character count
Sourcepub fn insert(&mut self, char_offset: usize, text: &str)
pub fn insert(&mut self, char_offset: usize, text: &str)
Insert text (at specified character offset)
Sourcepub fn delete(&mut self, start_char: usize, len_chars: usize)
pub fn delete(&mut self, start_char: usize, len_chars: usize)
Delete text range (character offset)
Sourcepub fn get_line_text(&self, line_number: usize) -> Option<String>
pub fn get_line_text(&self, line_number: usize) -> Option<String>
Get text of the specified line (excluding newline)