Struct linefeed::reader::Reader

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

Provides access to data related to reading and processing user input.

Holds a lock on terminal read operations. See Interface for more information about concurrent operations.

An instance of this type can be constructed using the Interface::lock_reader method.

Implementations

Interactively reads a line from the terminal device.

User input is collected until one of the following conditions is met:

  • If the user issues an end-of-file, ReadResult::Eof is returned.
  • When the user inputs a newline ('\n'), the resulting input (not containing a trailing newline character) is returned as ReadResult::Input(_).
  • When a reported signal (see set_report_signal) is received, it is returned as ReadResult::Signal(_). The read_line operation may then be either resumed with another call to read_line or ended by calling cancel_read_line.

Performs one step of the interactive read_line loop.

This method can be used to drive the read_line process asynchronously. It will wait for input only up to the specified duration, then process any available input from the terminal.

If the user completes the input process, Ok(Some(result)) is returned. Otherwise, Ok(None) is returned to indicate that the interactive loop may continue.

The interactive prompt may be cancelled prematurely using the cancel_read_line method.

See read_line for details on the return value.

Cancels an in-progress read_line operation.

This method will reset internal data structures to their original state and move the terminal cursor to a new, empty line.

This method is called to prematurely end the interactive loop when using the read_line_step method.

It is not necessary to call this method if using the read_line method.

Sets the input buffer to the given string.

This method internally acquires the Interface write lock.

Notes

To prevent invalidating the cursor, this method sets the cursor position to the end of the new buffer.

Sets the cursor position in the input buffer.

This method internally acquires the Interface write lock.

Panics

If the given position is out of bounds or not on a char boundary.

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

This method internally acquires the Interface write lock.

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

Adds a line to history.

This method internally acquires the Interface write lock.

If a read_line call is in progress, this method has no effect.

Adds a line to history, unless it is identical to the most recent entry.

This method internally acquires the Interface write lock.

If a read_line call is in progress, this method has no effect.

Removes all history entries.

This method internally acquires the Interface write lock.

If a read_line call is in progress, this method has no effect.

Removes the history entry at the given index.

This method internally acquires the Interface write lock.

If the index is out of bounds, this method has no effect.

If a read_line call is in progress, this method has no effect.

Sets the maximum number of history entries.

This method internally acquires the Interface write lock.

If n is less than the current number of history entries, the oldest entries are truncated to meet the given requirement.

If a read_line call is in progress, this method has no effect.

Truncates history to the only the most recent n entries.

This method internally acquires the Interface write lock.

If a read_line call is in progress, this method has no effect.

Returns the application name

Sets the application name

Returns a reference to the current completer instance.

Replaces the current completer, returning the previous instance.

Returns the value of the named variable or None if no such variable exists.

Sets the value of the named variable and returns the previous value.

If name does not refer to a variable or the value is not a valid value for the variable, None is returned.

Returns an iterator over stored variables.

Returns whether to “blink” matching opening parenthesis character when a closing parenthesis character is entered.

The default value is false.

Sets the blink-matching-paren variable.

Returns whether linefeed will catch certain signals.

Sets whether linefeed will catch certain signals.

This setting is true by default. It can be disabled to allow the host program to handle signals itself.

Returns whether the given Signal is ignored.

Sets whether the given Signal will be ignored.

Returns whether the given Signal is to be reported.

Sets whether to report the given Signal.

When a reported signal is received via the terminal, it will be returned from Interface::read_line as Ok(Signal(signal)).

Returns whether Tab completion is disabled.

The default value is false.

Sets the disable-completion variable.

When certain control characters are pressed, a character sequence equivalent to this character will be echoed.

The default value is true.

Sets the echo-control-characters variable.

Returns the character, if any, that is appended to a successful completion.

Sets the character, if any, that is appended to a successful completion.

Returns the width of completion listing display.

If this value is greater than the terminal width, terminal width is used instead.

The default value is equal to usize::max_value().

Sets the completion-display-width variable.

Returns the minimum number of completion items that require user confirmation before listing.

The default value is 100.

Sets the completion-query-items variable.

Returns the timeout to wait for further user input when an ambiguous sequence has been entered. If the value is None, wait is indefinite.

The default value 500 milliseconds.

Sets the keyseq-timeout variable.

Returns whether to list possible completions one page at a time.

The default value is true.

Sets the page-completions variable.

Returns whether to list completions horizontally, rather than down the screen.

The default value is false.

Sets the print-completions-horizontally variable.

Returns the set of characters that delimit strings.

Sets the set of characters that delimit strings.

Returns the set of characters that indicate a word break.

Sets the set of characters that indicate a word break.

Returns an iterator over bound sequences

Binds a sequence to a command.

Returns the previously bound command.

Binds a sequence to a command, if and only if the given sequence is not already bound to a command.

Returns true if a new binding was created.

Removes a binding for the given sequence.

Returns the previously bound command.

Defines a named function to which sequences may be bound.

The name should consist of lowercase ASCII letters and numbers, containing no spaces, with words separated by hyphens. However, this is not a requirement.

Returns the function previously defined with the same name.

Removes a function defined with the given name.

Returns the defined function.

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.