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) -> Self

Create a new line buffer with the given maximum capacity.

fn as_str(self: &Self) -> &str

Extracts a string slice containing the entire buffer.

fn into_string(self: Self) -> String

Converts a buffer into a String without copying or allocating.

fn pos(self: &Self) -> usize

Current cursor position (byte position)

fn is_cursor_at_end(self: &Self) -> bool

Check 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) -> usize

Returns the length of this buffer, in bytes.

fn is_empty(self: &Self) -> bool

Returns true if 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 ch at current cursor position and advance cursor position accordingly. Return None when maximum buffer size has been reached, true when 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 text at current position. Return None when maximum buffer size has been reached or is empty, true when 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 text at current position.

fn move_backward(self: &mut Self, n: RepeatCount) -> bool

Move cursor on the left.

fn move_forward(self: &mut Self, n: RepeatCount) -> bool

Move cursor on the right.

fn move_buffer_start(self: &mut Self) -> bool

Move cursor to the start of the buffer.

fn move_buffer_end(self: &mut Self) -> bool

Move cursor to the end of the buffer.

fn move_home(self: &mut Self) -> bool

Move cursor to the start of the line.

fn move_end(self: &mut Self) -> bool

Move cursor to the end of the line.

fn is_end_of_input(self: &Self) -> bool

Is 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) -> bool

Delete 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) -> bool

Kill the text from point to the end of the line.

fn kill_buffer<D: DeleteListener>(self: &mut Self, dl: &mut D) -> bool

Kill the text from point to the end of the buffer.

fn discard_line<D: DeleteListener>(self: &mut Self, dl: &mut D) -> bool

Kill backward from point to the beginning of the line.

fn discard_buffer<D: DeleteListener>(self: &mut Self, dl: &mut D) -> bool

Kill backward from point to the beginning of the buffer.

fn transpose_chars<C: ChangeListener>(self: &mut Self, cl: &mut C) -> bool

Exchange the char before cursor with the character at cursor.

fn move_to_prev_word(self: &mut Self, word_def: Word, n: RepeatCount) -> bool

Moves 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) -> bool

Delete 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) -> bool

Moves the cursor to the end of next word.

fn move_to_line_up(self: &mut Self, n: RepeatCount, layout: &Layout) -> bool

Moves the cursor to the same column in the line above

fn move_to_line_down(self: &mut Self, n: RepeatCount, layout: &Layout) -> bool

Moves the cursor to the same column in the line above

fn move_to(self: &mut Self, cs: CharSearch, n: RepeatCount) -> bool

Move cursor to the matching character position. Return true when the search succeeds.

fn delete_word<D: DeleteListener>(self: &mut Self, at: At, word_def: Word, n: RepeatCount, dl: &mut D) -> bool

Kill 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) -> bool

Delete range specified by cs search.

fn edit_word<C: ChangeListener>(self: &mut Self, a: WordAction, cl: &mut C) -> bool

Alter the next word.

fn transpose_words<C: ChangeListener>(self: &mut Self, n: RepeatCount, cl: &mut C) -> bool

Transpose two words

fn replace<C: ChangeListener>(self: &mut Self, range: Range<usize>, text: &str, cl: &mut C)

Replaces the content between [start..end] with text and positions the cursor to the end of text.

fn insert_str<C: ChangeListener>(self: &mut Self, idx: usize, s: &str, cl: &mut C) -> bool

Insert the string at the specified position. Return true if 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 range in the line.

fn copy(self: &Self, mvt: &Movement) -> Option<String>

Return the content between current cursor position and mvt position. Return None when the buffer is empty or when the movement fails.

fn kill<D: DeleteListener>(self: &mut Self, mvt: &Movement, dl: &mut D) -> bool

Kill range specified by mvt.

fn indent<C: ChangeListener>(self: &mut Self, mvt: &Movement, amount: u8, dedent: bool, cl: &mut C) -> bool

Indent 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) -> T

Returns the argument unchanged.

impl<T, U> Into for LineBuffer

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>