Struct gchemol_parser::TextViewer
source · pub struct TextViewer { /* private fields */ }Expand description
A simple line-based text viewer for quick peeking part of text
Implementations§
source§impl TextViewer
impl TextViewer
Constructor a TextViewer like a text reader in read-only mode,
suitable for small file that can be fully read into memory.
source§impl TextViewer
impl TextViewer
Core methods
sourcepub fn current_line_num(&self) -> usize
pub fn current_line_num(&self) -> usize
Get line number at cursor
sourcepub fn current_line(&self) -> &str
pub fn current_line(&self) -> &str
Peek the line at cursor
sourcepub fn goto_line(&mut self, n: usize)
pub fn goto_line(&mut self, n: usize)
Move the cursor to line n, counting from line 1 at beginning of the text.
sourcepub fn goto_first_line(&mut self)
pub fn goto_first_line(&mut self)
Move the cursor to the beginning of the first line.
sourcepub fn goto_last_line(&mut self)
pub fn goto_last_line(&mut self)
Move the cursor to the beginning of the last line.
sourcepub fn goto_next_line(&mut self)
pub fn goto_next_line(&mut self)
Move the cursor to the beginning of the next line.
sourcepub fn goto_previous_line(&mut self)
pub fn goto_previous_line(&mut self)
Move the cursor to the beginning of the previous line.
sourcepub fn search_forward(&mut self, pattern: &str) -> Result<usize>
pub fn search_forward(&mut self, pattern: &str) -> Result<usize>
Move the cursor to the line matching pattern. Regex pattern
is allowed. Return current line number after search.
sourcepub fn search_backward(&mut self, pattern: &str) -> Result<usize>
pub fn search_backward(&mut self, pattern: &str) -> Result<usize>
Search backward from current point for pattern. Return
current line number after search.
sourcepub fn peek_lines(&self, n: usize, m: usize) -> &str
pub fn peek_lines(&self, n: usize, m: usize) -> &str
Peek the text between line n and m (including line m),
without moving cursor.
Trait Implementations§
source§impl Clone for TextViewer
impl Clone for TextViewer
source§fn clone(&self) -> TextViewer
fn clone(&self) -> TextViewer
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more