Struct LineBuffer
struct LineBuffer { ... }
Represent the current input (text and cursor position).
The methods do text manipulations or/and cursor movements.
Implementations
impl LineBuffer
fn with_capacity(capacity: usize) -> SelfCreate a new line buffer with the given maximum
capacity.fn as_str(self: &Self) -> &strExtracts a string slice containing the entire buffer.
fn into_string(self: Self) -> StringConverts a buffer into a
Stringwithout copying or allocating.fn pos(self: &Self) -> usizeCurrent cursor position (byte position)
fn is_cursor_at_end(self: &Self) -> boolCheck if cursor is at the end of input
fn set_pos(self: &mut Self, pos: usize)Set cursor position (byte position)
fn len(self: &Self) -> usizeReturns the length of this buffer, in bytes.
fn is_empty(self: &Self) -> boolReturns
trueif this buffer has a length of zero.fn update<C: ChangeListener>(self: &mut Self, buf: &str, pos: usize, cl: &mut C)Set line content (
buf) and cursor position (pos).fn next_pos(self: &Self, n: RepeatCount) -> Option<usize>Returns the position of the character just after the current cursor position.
fn insert<C: ChangeListener>(self: &mut Self, ch: char, n: RepeatCount, cl: &mut C) -> Option<bool>Insert the character
chat current cursor position and advance cursor position accordingly. ReturnNonewhen maximum buffer size has been reached,truewhen the character has been appended to the end of the line.fn yank<C: ChangeListener>(self: &mut Self, text: &str, n: RepeatCount, cl: &mut C) -> Option<bool>Yank/paste
textat current position. ReturnNonewhen maximum buffer size has been reached or is empty,truewhen the character has been appended to the end of the line.fn yank_pop<C: ChangeListener>(self: &mut Self, yank_size: usize, text: &str, cl: &mut C) -> Option<bool>Delete previously yanked text and yank/paste
textat current position.fn move_backward(self: &mut Self, n: RepeatCount) -> boolMove cursor on the left.
fn move_forward(self: &mut Self, n: RepeatCount) -> boolMove cursor on the right.
fn move_buffer_start(self: &mut Self) -> boolMove cursor to the start of the buffer.
fn move_buffer_end(self: &mut Self) -> boolMove cursor to the end of the buffer.
fn move_home(self: &mut Self) -> boolMove cursor to the start of the line.
fn move_end(self: &mut Self) -> boolMove cursor to the end of the line.
fn is_end_of_input(self: &Self) -> boolIs cursor at the end of input (whitespaces after cursor is discarded)
fn delete<D: DeleteListener>(self: &mut Self, n: RepeatCount, dl: &mut D) -> Option<String>Delete the character at the right of the cursor without altering the cursor position. Basically this is what happens with the "Delete" keyboard key. Return the number of characters deleted.
fn backspace<D: DeleteListener>(self: &mut Self, n: RepeatCount, dl: &mut D) -> boolDelete the character at the left of the cursor. Basically that is what happens with the "Backspace" keyboard key.
fn kill_line<D: DeleteListener>(self: &mut Self, dl: &mut D) -> boolKill the text from point to the end of the line.
fn kill_buffer<D: DeleteListener>(self: &mut Self, dl: &mut D) -> boolKill the text from point to the end of the buffer.
fn discard_line<D: DeleteListener>(self: &mut Self, dl: &mut D) -> boolKill backward from point to the beginning of the line.
fn discard_buffer<D: DeleteListener>(self: &mut Self, dl: &mut D) -> boolKill backward from point to the beginning of the buffer.
fn transpose_chars<C: ChangeListener>(self: &mut Self, cl: &mut C) -> boolExchange the char before cursor with the character at cursor.
fn move_to_prev_word(self: &mut Self, word_def: Word, n: RepeatCount) -> boolMoves the cursor to the beginning of previous word.
fn delete_prev_word<D: DeleteListener>(self: &mut Self, word_def: Word, n: RepeatCount, dl: &mut D) -> boolDelete the previous word, maintaining the cursor at the start of the current word.
fn move_to_next_word(self: &mut Self, at: At, word_def: Word, n: RepeatCount) -> boolMoves the cursor to the end of next word.
fn move_to_line_up(self: &mut Self, n: RepeatCount, layout: &Layout) -> boolMoves the cursor to the same column in the line above
fn move_to_line_down(self: &mut Self, n: RepeatCount, layout: &Layout) -> boolMoves the cursor to the same column in the line above
fn move_to(self: &mut Self, cs: CharSearch, n: RepeatCount) -> boolMove cursor to the matching character position. Return
truewhen the search succeeds.fn delete_word<D: DeleteListener>(self: &mut Self, at: At, word_def: Word, n: RepeatCount, dl: &mut D) -> boolKill from the cursor to the end of the current word, or, if between words, to the end of the next word.
fn delete_to<D: DeleteListener>(self: &mut Self, cs: CharSearch, n: RepeatCount, dl: &mut D) -> boolDelete range specified by
cssearch.fn edit_word<C: ChangeListener>(self: &mut Self, a: WordAction, cl: &mut C) -> boolAlter the next word.
fn transpose_words<C: ChangeListener>(self: &mut Self, n: RepeatCount, cl: &mut C) -> boolTranspose two words
fn replace<C: ChangeListener>(self: &mut Self, range: Range<usize>, text: &str, cl: &mut C)Replaces the content between [
start..end] withtextand positions the cursor to the end of text.fn insert_str<C: ChangeListener>(self: &mut Self, idx: usize, s: &str, cl: &mut C) -> boolInsert the
string at the specified position. Returntrueif the text has been inserted at the end of the line.fn delete_range<D: DeleteListener>(self: &mut Self, range: Range<usize>, dl: &mut D)Remove the specified
rangein the line.fn copy(self: &Self, mvt: &Movement) -> Option<String>Return the content between current cursor position and
mvtposition. ReturnNonewhen the buffer is empty or when the movement fails.fn kill<D: DeleteListener>(self: &mut Self, mvt: &Movement, dl: &mut D) -> boolKill range specified by
mvt.fn indent<C: ChangeListener>(self: &mut Self, mvt: &Movement, amount: u8, dedent: bool, cl: &mut C) -> boolIndent range specified by
mvt.
impl Debug for LineBuffer
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Deref for LineBuffer
fn deref(self: &Self) -> &str
impl Freeze for LineBuffer
impl RefUnwindSafe for LineBuffer
impl Send for LineBuffer
impl Sync for LineBuffer
impl Unpin for LineBuffer
impl UnwindSafe for LineBuffer
impl<P, T> Receiver for LineBuffer
impl<T> Any for LineBuffer
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for LineBuffer
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for LineBuffer
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for LineBuffer
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for LineBuffer
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for LineBuffer
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for LineBuffer
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>