[][src]Struct rustyline::line_buffer::LineBuffer

pub struct LineBuffer { /* fields omitted */ }

Represent the current input (text and cursor position).

The methods do text manipulations or/and cursor movements.

Implementations

impl LineBuffer[src]

pub fn with_capacity(capacity: usize) -> Self[src]

Create a new line buffer with the given maximum capacity.

pub fn as_str(&self) -> &str[src]

Extracts a string slice containing the entire buffer.

pub fn into_string(self) -> String[src]

Converts a buffer into a String without copying or allocating.

pub fn pos(&self) -> usize[src]

Current cursor position (byte position)

pub fn set_pos(&mut self, pos: usize)[src]

Set cursor position (byte position)

pub fn len(&self) -> usize[src]

Returns the length of this buffer, in bytes.

pub fn is_empty(&self) -> bool[src]

Returns true if this buffer has a length of zero.

pub fn update(&mut self, buf: &str, pos: usize)[src]

Set line content (buf) and cursor position (pos).

pub fn next_pos(&self, n: RepeatCount) -> Option<usize>[src]

Returns the position of the character just after the current cursor position.

pub fn insert(&mut self, ch: char, n: RepeatCount) -> Option<bool>[src]

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.

pub fn yank(&mut self, text: &str, n: RepeatCount) -> Option<bool>[src]

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.

pub fn yank_pop(&mut self, yank_size: usize, text: &str) -> Option<bool>[src]

Delete previously yanked text and yank/paste text at current position.

pub fn move_backward(&mut self, n: RepeatCount) -> bool[src]

Move cursor on the left.

pub fn move_forward(&mut self, n: RepeatCount) -> bool[src]

Move cursor on the right.

pub fn move_buffer_start(&mut self) -> bool[src]

Move cursor to the start of the buffer.

pub fn move_buffer_end(&mut self) -> bool[src]

Move cursor to the end of the buffer.

pub fn move_home(&mut self) -> bool[src]

Move cursor to the start of the line.

pub fn move_end(&mut self) -> bool[src]

Move cursor to the end of the line.

pub fn is_end_of_input(&self) -> bool[src]

Is cursor at the end of input (whitespaces after cursor is discarded)

pub fn delete(&mut self, n: RepeatCount) -> Option<String>[src]

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.

pub fn backspace(&mut self, n: RepeatCount) -> bool[src]

Delete the character at the left of the cursor. Basically that is what happens with the "Backspace" keyboard key.

pub fn kill_line(&mut self) -> bool[src]

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

pub fn kill_buffer(&mut self) -> bool[src]

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

pub fn discard_line(&mut self) -> bool[src]

Kill backward from point to the beginning of the line.

pub fn discard_buffer(&mut self) -> bool[src]

Kill backward from point to the beginning of the buffer.

pub fn transpose_chars(&mut self) -> bool[src]

Exchange the char before cursor with the character at cursor.

pub fn move_to_prev_word(&mut self, word_def: Word, n: RepeatCount) -> bool[src]

Moves the cursor to the beginning of previous word.

pub fn delete_prev_word(&mut self, word_def: Word, n: RepeatCount) -> bool[src]

Delete the previous word, maintaining the cursor at the start of the current word.

pub fn move_to_next_word(
    &mut self,
    at: At,
    word_def: Word,
    n: RepeatCount
) -> bool
[src]

Moves the cursor to the end of next word.

pub fn move_to_line_up(&mut self, n: RepeatCount) -> bool[src]

Moves the cursor to the same column in the line above

pub fn move_to_line_down(&mut self, n: RepeatCount) -> bool[src]

Moves the cursor to the same column in the line above

pub fn move_to(&mut self, cs: CharSearch, n: RepeatCount) -> bool[src]

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

pub fn delete_word(&mut self, at: At, word_def: Word, n: RepeatCount) -> bool[src]

Kill from the cursor to the end of the current word, or, if between words, to the end of the next word.

pub fn delete_to(&mut self, cs: CharSearch, n: RepeatCount) -> bool[src]

Delete range specified by cs search.

pub fn edit_word(&mut self, a: WordAction) -> bool[src]

Alter the next word.

pub fn transpose_words(&mut self, n: RepeatCount) -> bool[src]

Transpose two words

pub fn replace(&mut self, range: Range<usize>, text: &str)[src]

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

pub fn insert_str(&mut self, idx: usize, s: &str) -> bool[src]

Insert the string at the specified position. Return true if the text has been inserted at the end of the line.

pub fn delete_range(&mut self, range: Range<usize>)[src]

Remove the specified range in the line.

pub fn copy(&self, mvt: &Movement) -> Option<String>[src]

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

pub fn kill(&mut self, mvt: &Movement) -> bool[src]

Kill range specified by mvt.

Trait Implementations

impl Debug for LineBuffer[src]

impl Deref for LineBuffer[src]

type Target = str

The resulting type after dereferencing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.