Struct gchemol_parser::TextViewer
source · pub struct TextViewer { /* private fields */ }Expand description
A simple text view 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 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.
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)
Trait Implementations§
source§impl Clone for TextViewer
impl Clone for TextViewer
source§fn clone(&self) -> TextViewer
fn clone(&self) -> TextViewer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more