Struct reedline::LineBuffer
source · [−]pub struct LineBuffer { /* private fields */ }
Expand description
In memory representation of the entered line(s) including a cursor position to facilitate cursor based editing.
Implementations
sourceimpl LineBuffer
impl LineBuffer
sourcepub fn new() -> LineBuffer
pub fn new() -> LineBuffer
Create a line buffer instance
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if the line buffer is valid utf-8 and the cursor sits on a valid grapheme boundary
sourcepub fn insertion_point(&self) -> usize
pub fn insertion_point(&self) -> usize
Gets the current edit position
sourcepub fn set_insertion_point(&mut self, offset: usize)
pub fn set_insertion_point(&mut self, offset: usize)
Sets the current edit position
Unicode safety:
Not checked, inproper use may cause panics in following operations
sourcepub fn get_buffer(&self) -> &str
pub fn get_buffer(&self) -> &str
Output the current line in the multiline buffer
sourcepub fn set_buffer(&mut self, buffer: String)
pub fn set_buffer(&mut self, buffer: String)
Set to a single line of buffer
and reset the InsertionPoint
cursor to the end
sourcepub fn ends_with(&self, c: char) -> bool
pub fn ends_with(&self, c: char) -> bool
Checks to see if the buffer ends with a given character
sourcepub fn move_to_start(&mut self)
pub fn move_to_start(&mut self)
Reset the insertion point to the start of the buffer
sourcepub fn move_to_line_start(&mut self)
pub fn move_to_line_start(&mut self)
Move the cursor before the first character of the line
sourcepub fn move_to_line_end(&mut self)
pub fn move_to_line_end(&mut self)
Move cursor position to the end of the line
Insertion will append to the line.
Cursor on top of the potential \n
or \r
of \r\n
sourcepub fn move_to_end(&mut self)
pub fn move_to_end(&mut self)
Set the insertion point behind the last character.
sourcepub fn find_current_line_end(&self) -> usize
pub fn find_current_line_end(&self) -> usize
Returns where the current line terminates
Either:
- end of buffer (
len()
) \n
or\r\n
(on the first byte)
sourcepub fn grapheme_right_index(&self) -> usize
pub fn grapheme_right_index(&self) -> usize
Cursor position behind the next unicode grapheme to the right
sourcepub fn grapheme_left_index(&self) -> usize
pub fn grapheme_left_index(&self) -> usize
Cursor position in front of the next unicode grapheme to the left
sourcepub fn word_right_index(&self) -> usize
pub fn word_right_index(&self) -> usize
Cursor position behind the next word to the right
sourcepub fn big_word_right_index(&self) -> usize
pub fn big_word_right_index(&self) -> usize
Cursor position behind the next WORD to the right
sourcepub fn word_right_end_index(&self) -> usize
pub fn word_right_end_index(&self) -> usize
Cursor position at end of the next word to the right
sourcepub fn big_word_right_end_index(&self) -> usize
pub fn big_word_right_end_index(&self) -> usize
Cursor position at end of the next WORD to the right
sourcepub fn word_right_start_index(&self) -> usize
pub fn word_right_start_index(&self) -> usize
Cursor position in front of the next word to the right
sourcepub fn big_word_right_start_index(&self) -> usize
pub fn big_word_right_start_index(&self) -> usize
Cursor position in front of the next WORD to the right
sourcepub fn word_left_index(&self) -> usize
pub fn word_left_index(&self) -> usize
Cursor position in front of the next word to the left
sourcepub fn big_word_left_index(&self) -> usize
pub fn big_word_left_index(&self) -> usize
Cursor position in front of the next WORD to the left
sourcepub fn next_whitespace(&self) -> usize
pub fn next_whitespace(&self) -> usize
Cursor position on the next whitespace
sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor position behind the next unicode grapheme to the right
sourcepub fn move_left(&mut self)
pub fn move_left(&mut self)
Move cursor position in front of the next unicode grapheme to the left
sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move cursor position in front of the next word to the left
sourcepub fn move_big_word_left(&mut self)
pub fn move_big_word_left(&mut self)
Move cursor position in front of the next WORD to the left
sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move cursor position behind the next word to the right
sourcepub fn move_word_right_start(&mut self)
pub fn move_word_right_start(&mut self)
Move cursor position to the start of the next word
sourcepub fn move_big_word_right_start(&mut self)
pub fn move_big_word_right_start(&mut self)
Move cursor position to the start of the next WORD
sourcepub fn move_word_right_end(&mut self)
pub fn move_word_right_end(&mut self)
Move cursor position to the end of the next word
sourcepub fn move_big_word_right_end(&mut self)
pub fn move_big_word_right_end(&mut self)
Move cursor position to the end of the next WORD
sourcepub fn insert_char(&mut self, c: char)
pub fn insert_char(&mut self, c: char)
Insert a single character at the insertion point and move right
sourcepub fn insert_str(&mut self, string: &str)
pub fn insert_str(&mut self, string: &str)
Insert &str
at the cursor position in the current line.
Sets cursor to end of inserted string
Unicode safety:
Does not validate the incoming string or the current cursor position
sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Inserts the system specific new line character
- On Unix systems LF (
"\n"
) - On Windows CRLF (
"\r\n"
)
sourcepub fn clear_to_end(&mut self)
pub fn clear_to_end(&mut self)
Clear everything beginning at the cursor to the right/end. Keeps the cursor at the end.
sourcepub fn clear_to_line_end(&mut self)
pub fn clear_to_line_end(&mut self)
Clear beginning at the cursor up to the end of the line. Newline character at the end remains.
sourcepub fn clear_to_insertion_point(&mut self)
pub fn clear_to_insertion_point(&mut self)
Clear from the start of the buffer to the cursor. Keeps the cursor at the beginning of the line/buffer.
sourcepub fn replace_range<R>(&mut self, range: R, replace_with: &str)where
R: RangeBounds<usize>,
pub fn replace_range<R>(&mut self, range: R, replace_with: &str)where
R: RangeBounds<usize>,
Substitute text covered by range
in the current line
Safety: Does not change the insertion point/offset and is thus not unicode safe!
sourcepub fn on_whitespace(&self) -> bool
pub fn on_whitespace(&self) -> bool
Checks to see if the current edit position is pointing to whitespace
sourcepub fn grapheme_right(&self) -> &str
pub fn grapheme_right(&self) -> &str
Get the grapheme immediately to the right of the cursor, if any
sourcepub fn grapheme_left(&self) -> &str
pub fn grapheme_left(&self) -> &str
Get the grapheme immediately to the left of the cursor, if any
sourcepub fn current_word_range(&self) -> Range<usize>
pub fn current_word_range(&self) -> Range<usize>
Gets the range of the word the current edit position is pointing to
sourcepub fn current_line_range(&self) -> Range<usize>
pub fn current_line_range(&self) -> Range<usize>
Range over the current line
Starts on the first non-newline character and is an exclusive range extending beyond the potential carriage return and line feed characters terminating the line
sourcepub fn uppercase_word(&mut self)
pub fn uppercase_word(&mut self)
Uppercases the current word
sourcepub fn lowercase_word(&mut self)
pub fn lowercase_word(&mut self)
Lowercases the current word
sourcepub fn switchcase_char(&mut self)
pub fn switchcase_char(&mut self)
Switches the ASCII case of the current char
sourcepub fn capitalize_char(&mut self)
pub fn capitalize_char(&mut self)
Capitalize the character at insertion point (or the first character following the whitespace at the insertion point) and move the insertion point right one grapheme.
sourcepub fn delete_left_grapheme(&mut self)
pub fn delete_left_grapheme(&mut self)
Deletes on grapheme to the left
sourcepub fn delete_right_grapheme(&mut self)
pub fn delete_right_grapheme(&mut self)
Deletes one grapheme to the right
sourcepub fn delete_word_left(&mut self)
pub fn delete_word_left(&mut self)
Deletes one word to the left
sourcepub fn delete_word_right(&mut self)
pub fn delete_word_right(&mut self)
Deletes one word to the right
sourcepub fn swap_words(&mut self)
pub fn swap_words(&mut self)
Swaps current word with word on right
sourcepub fn swap_graphemes(&mut self)
pub fn swap_graphemes(&mut self)
Swaps current grapheme with grapheme on right
sourcepub fn move_line_up(&mut self)
pub fn move_line_up(&mut self)
Moves one line up
sourcepub fn move_line_down(&mut self)
pub fn move_line_down(&mut self)
Moves one line down
sourcepub fn is_cursor_at_first_line(&self) -> bool
pub fn is_cursor_at_first_line(&self) -> bool
Checks to see if the cursor is on the first line of the buffer
sourcepub fn is_cursor_at_last_line(&self) -> bool
pub fn is_cursor_at_last_line(&self) -> bool
Checks to see if the cursor is on the last line of the buffer
sourcepub fn find_char_right(&self, c: char, current_line: bool) -> Option<usize>
pub fn find_char_right(&self, c: char, current_line: bool) -> Option<usize>
Finds index for the first occurrence of a char to the right of offset
sourcepub fn find_char_left(&self, c: char, current_line: bool) -> Option<usize>
pub fn find_char_left(&self, c: char, current_line: bool) -> Option<usize>
Finds index for the first occurrence of a char to the left of offset
sourcepub fn move_right_until(&mut self, c: char, current_line: bool) -> usize
pub fn move_right_until(&mut self, c: char, current_line: bool) -> usize
Moves the insertion point until the next char to the right
sourcepub fn move_right_before(&mut self, c: char, current_line: bool) -> usize
pub fn move_right_before(&mut self, c: char, current_line: bool) -> usize
Moves the insertion point before the next char to the right
sourcepub fn move_left_until(&mut self, c: char, current_line: bool) -> usize
pub fn move_left_until(&mut self, c: char, current_line: bool) -> usize
Moves the insertion point until the next char to the left of offset
sourcepub fn move_left_before(&mut self, c: char, current_line: bool) -> usize
pub fn move_left_before(&mut self, c: char, current_line: bool) -> usize
Moves the insertion point before the next char to the left of offset
sourcepub fn delete_right_until_char(&mut self, c: char, current_line: bool)
pub fn delete_right_until_char(&mut self, c: char, current_line: bool)
Deletes until first character to the right of offset
sourcepub fn delete_right_before_char(&mut self, c: char, current_line: bool)
pub fn delete_right_before_char(&mut self, c: char, current_line: bool)
Deletes before first character to the right of offset
sourcepub fn delete_left_until_char(&mut self, c: char, current_line: bool)
pub fn delete_left_until_char(&mut self, c: char, current_line: bool)
Deletes until first character to the left of offset
sourcepub fn delete_left_before_char(&mut self, c: char, current_line: bool)
pub fn delete_left_before_char(&mut self, c: char, current_line: bool)
Deletes before first character to the left of offset
Trait Implementations
sourceimpl Clone for LineBuffer
impl Clone for LineBuffer
sourcefn clone(&self) -> LineBuffer
fn clone(&self) -> LineBuffer
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more