[][src]Struct linefeed::prompter::Prompter

pub struct Prompter<'a, 'b: 'a, Term: 'b + Terminal> { /* fields omitted */ }

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.

Methods

impl<'a, 'b: 'a, Term: 'b + Terminal> Prompter<'a, 'b, Term>[src]

pub fn writer_append<'c>(&'c mut self) -> Result<Writer<'c, 'b, Term>>[src]

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.

pub fn writer_erase<'c>(&'c mut self) -> Result<Writer<'c, 'b, Term>>[src]

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.

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

Returns the current buffer.

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

Returns the "backup" buffer.

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

pub fn last_command_category(&self) -> Category[src]

Returns the command Category of the most recently executed command.

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

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

Returns the set of characters that indicate a word break.

pub fn set_buffer(&mut self, buf: &str) -> Result<()>[src]

Sets the buffer to the given value.

The cursor is moved to the end of the buffer.

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

Returns the current position of the cursor.

pub fn set_cursor(&mut self, pos: usize) -> Result<()>[src]

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.

pub fn set_prompt(&mut self, prompt: &str) -> Result<()>[src]

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'.

pub fn screen_size(&self) -> Size[src]

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

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

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

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

Returns the current input sequence.

Important traits for BindingIter<'a>
pub fn bindings(&self) -> BindingIter[src]

Returns an iterator over bound sequences

Important traits for VariableIter<'a>
pub fn variables(&self) -> VariableIter[src]

Returns an iterator over variable values.

Important traits for HistoryIter<'a>
pub fn history(&self) -> HistoryIter[src]

Returns an iterator over history entries

pub fn history_index(&self) -> Option<usize>[src]

Returns the index into history currently being edited.

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

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

Returns the current number of history entries.

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

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.

pub fn completions(&self) -> Option<&[Completion]>[src]

Returns the current set of completions.

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

pub fn set_completions(&mut self, completions: Option<Vec<Completion>>)[src]

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.

pub fn accept_input(&mut self) -> Result<()>[src]

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.

pub fn delete_range<R: RangeArgument<usize>>(&mut self, range: R) -> Result<()>[src]

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.

pub fn kill_range<R: RangeArgument<usize>>(&mut self, range: R) -> Result<()>[src]

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.

pub fn transpose_range(
    &mut self,
    src: Range<usize>,
    dest: Range<usize>
) -> Result<()>
[src]

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.

pub fn yank(&mut self) -> Result<()>[src]

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.

pub fn yank_pop(&mut self) -> Result<()>[src]

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

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

pub fn insert(&mut self, n: usize, ch: char) -> Result<()>[src]

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

The cursor position remains the same.

pub fn insert_str(&mut self, s: &str) -> Result<()>[src]

Insert a string at the current cursor position.

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

pub fn replace_str_backward<R: RangeArgument<usize>>(
    &mut self,
    range: R,
    s: &str
) -> Result<()>
[src]

Replaces a range in the buffer and redraws.

The cursor is placed at the start of the range.

pub fn replace_str_forward<R: RangeArgument<usize>>(
    &mut self,
    range: R,
    s: &str
) -> Result<()>
[src]

Replaces a range in the buffer and redraws.

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

Auto Trait Implementations

impl<'a, 'b, Term> !Send for Prompter<'a, 'b, Term>

impl<'a, 'b, Term> !Sync for Prompter<'a, 'b, Term>

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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