Struct linefeed::prompter::Prompter

source ·
pub struct Prompter<'a, 'b: 'a, Term: 'b + Terminal> { /* private fields */ }
Expand description

Provides access to the current state of input while a read_line call is in progress.

Holds read and write locks on terminal operations. See Interface for more information about concurrent operations.

Instances of this type cannot be constructed by public methods. Instead, an instance is created internally during a call to read_line.

Implementations

Returns a Writer instance using the currently held write lock.

This method will move the cursor to a new line after the prompt, allowing output to be written without corrupting the prompt text. The prompt will be redrawn when the Writer instance is dropped.

To instead erase the prompt and write text, use writer_erase.

Returns a Writer instance using the currently held write lock.

This method will erase the prompt, allowing output to be written without corrupting the prompt text. The prompt will be redrawn when the Writer instance is dropped.

To instead write text after the prompt, use writer_append.

Returns the current buffer.

Returns the “backup” buffer.

When the user is currently editing a history entry, the backup buffer contains the original user input.

Returns the command Category of the most recently executed command.

Some commands may use this to influence behavior of repeated commands.

Returns the set of characters that indicate a word break.

Sets the buffer to the given value.

The cursor is moved to the end of the buffer.

Returns the current position of the cursor.

Sets the cursor to the given position within the buffer.

Panics

If the given position is out of bounds or is not aligned to char boundaries.

Sets the prompt that will be displayed when read_line is called.

Notes

If prompt contains any terminal escape sequences (e.g. color codes), such escape sequences should be immediately preceded by the character '\x01' and immediately followed by the character '\x02'.

Returns the size of the terminal at the last draw operation.

Returns whether a numerical argument was explicitly supplied by the user.

Returns the current input sequence.

Returns an iterator over bound sequences

Returns an iterator over variable values.

Returns an iterator over history entries

Returns the index into history currently being edited.

If the user is not editing a line of history, None is returned.

Returns the current number of history entries.

source

pub fn select_history_entry(&mut self, new: Option<usize>) -> Result<()>

Selects the history entry currently being edited by the user.

Setting the entry to None will result in editing the input buffer.

Panics

If the index is out of bounds.

Returns the current set of completions.

Unless the most recent command executed was one operating on completion sets, the result is None.

Sets the current set of completions.

This completion set is accessed by commands such as complete and possible-completions.

This set will only remain active until the end of the next non-completion command’s execution. Therefore, any Function that uses this method must be of the Complete category.

Accepts the current input buffer as user input.

This method may be called by a Function implementation, immediately before ending execution, in order to simulate the accept-line command; e.g. to implement a command that extends the default behavior of the accept-line action.

Behavior of this method is undefined if called outside of a Function implementation.

Moves the cursor to the given position, waits for 500 milliseconds (or until next user input), then restores the original cursor position.

Panics

If the given position is out of bounds or is not aligned to char boundaries.

Deletes a range of text from the input buffer.

Panics

If the given range is out of bounds or is not aligned to char boundaries.

Deletes a range from the buffer and adds the removed text to the kill ring.

Panics

If the given range is out of bounds or is not aligned to char boundaries.

Transposes two regions of the buffer, src and dest. The cursor is placed at the end of the new location of src.

Panics

If src and dest overlap, are out of bounds, or are not aligned to char boundaries.

Insert text from the front of the kill ring at the current cursor position. The cursor is placed at the end of the new text.

Rotates the kill ring and replaces yanked text with the new front.

If the previous operation was not yank, this has no effect.

Insert a given character at the current cursor position n times.

The cursor position remains the same.

Insert a string at the current cursor position.

The cursor is placed at the end of the new string.

Replaces a range in the buffer and redraws.

The cursor is placed at the start of the range.

Replaces a range in the buffer and redraws.

The cursor is placed at the end of the new string.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.