pub struct TextLines { /* private fields */ }
Implementations§
source§impl TextLines
impl TextLines
sourcepub fn new(text: &str) -> TextLines
pub fn new(text: &str) -> TextLines
Creates a new TextLines
with the specified text and default
indent width of 4.
sourcepub fn with_indent_width(text: &str, indent_width: usize) -> TextLines
pub fn with_indent_width(text: &str, indent_width: usize) -> TextLines
Creates a new TextLines
with the specified text and indent width.
The indent width sets the width of a tab character when getting
the display column.
sourcepub fn lines_count(&self) -> usize
pub fn lines_count(&self) -> usize
Gets the number of lines in the text.
sourcepub fn text_length(&self) -> usize
pub fn text_length(&self) -> usize
Gets the text length in bytes.
sourcepub fn line_index(&self, byte_index: usize) -> usize
pub fn line_index(&self, byte_index: usize) -> usize
Gets the line index from a byte index. Note that if you provide the middle byte index of a \r\n newline then it will return the index of the preceding line.
sourcepub fn line_start(&self, line_index: usize) -> usize
pub fn line_start(&self, line_index: usize) -> usize
Gets the line start byte index.
sourcepub fn line_end(&self, line_index: usize) -> usize
pub fn line_end(&self, line_index: usize) -> usize
Gets the line end byte index (before/at the newline character).
sourcepub fn line_range(&self, line_index: usize) -> (usize, usize)
pub fn line_range(&self, line_index: usize) -> (usize, usize)
Gets the line range.
sourcepub fn byte_index(&self, line_and_column: LineAndColumnIndex) -> usize
pub fn byte_index(&self, line_and_column: LineAndColumnIndex) -> usize
Gets the byte position from the provided line and column index.
sourcepub fn byte_index_from_char_index(&self, char_index: usize) -> usize
pub fn byte_index_from_char_index(&self, char_index: usize) -> usize
Gets a byte index from the provided character index.
sourcepub fn char_index(&self, byte_index: usize) -> usize
pub fn char_index(&self, byte_index: usize) -> usize
Gets a character index from the provided byte index.
sourcepub fn line_and_column_index(&self, byte_index: usize) -> LineAndColumnIndex
pub fn line_and_column_index(&self, byte_index: usize) -> LineAndColumnIndex
Gets the line and column index of the provided byte index.
sourcepub fn line_and_column_display(&self, byte_index: usize) -> LineAndColumnDisplay
pub fn line_and_column_display(&self, byte_index: usize) -> LineAndColumnDisplay
Gets the line and column display based on the indentation width and the provided byte index.
sourcepub fn line_and_column_display_with_indent_width(
&self,
byte_index: usize,
indent_width: usize
) -> LineAndColumnDisplay
pub fn line_and_column_display_with_indent_width( &self, byte_index: usize, indent_width: usize ) -> LineAndColumnDisplay
Gets the line and column display based on the provided byte index and indentation width.