pub struct TextViewer { /* private fields */ }
Expand description
A simple line-based text viewer for quick peeking part of text
Implementations§
Source§impl TextViewer
Constructor a TextViewer
like a text reader in read-only mode,
suitable for small file that can be fully read into memory.
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
Core methods
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 moreAuto Trait Implementations§
impl Freeze for TextViewer
impl RefUnwindSafe for TextViewer
impl Send for TextViewer
impl Sync for TextViewer
impl Unpin for TextViewer
impl UnwindSafe for TextViewer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more