Struct linefeed::reader::Reader
[−]
[src]
pub struct Reader<'a, Term: 'a + Terminal> { /* fields omitted */ }
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.
Methods
impl<'a, Term: 'a + Terminal> Reader<'a, Term>
[src]
pub fn read_line(&mut self) -> Result<ReadResult>
[src]
Interactively reads a line from the terminal device.
If the user issues an end-of-file, ReadResult::Eof
is returned.
If a reported signal (see set_report_signal
) is received,
it is returned as ReadResult::Signal(_)
.
Otherwise, user input is collected until a newline is entered.
The resulting input (not containing a trailing newline character)
is returned as ReadResult::Input(_)
.
pub fn lock_prompt_data<'b>(&'b mut self) -> PromptData<'b, 'a>
[src]
Acquires the Interface
write lock and returns a PromptData
instance.
The PromptData
structure enables modification of prompt input data
before a call to read_line
. Prompt data is reset when a read_line
call completes.
pub fn set_prompt(&mut self, prompt: &str)
[src]
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'
.
pub fn application(&self) -> &str
[src]
Returns the application name
pub fn set_application<T>(&mut self, application: T) where
T: Into<Cow<'static, str>>,
[src]
T: Into<Cow<'static, str>>,
Sets the application name
pub fn completer(&self) -> &Arc<Completer<Term>>
[src]
Returns a reference to the current completer instance.
pub fn set_completer(
&mut self,
completer: Arc<Completer<Term>>
) -> Arc<Completer<Term>>
[src]
&mut self,
completer: Arc<Completer<Term>>
) -> Arc<Completer<Term>>
Replaces the current completer, returning the previous instance.
pub fn get_variable(&self, name: &str) -> Option<Variable>
[src]
Returns the value of the named variable or None
if no such variable exists.
pub fn set_variable(&mut self, name: &str, value: &str) -> Option<Variable>
[src]
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.
ⓘImportant traits for VariableIter<'a>pub fn variables(&self) -> VariableIter
[src]
Returns an iterator over stored variables.
pub fn blink_matching_paren(&self) -> bool
[src]
Returns whether to "blink" matching opening parenthesis character when a closing parenthesis character is entered.
The default value is false
.
pub fn set_blink_matching_paren(&mut self, set: bool)
[src]
Sets the blink-matching-paren
variable.
pub fn catch_signals(&self) -> bool
[src]
Returns whether linefeed
will catch certain signals.
pub fn set_catch_signals(&mut self, enabled: bool)
[src]
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.
pub fn ignore_signal(&self, signal: Signal) -> bool
[src]
Returns whether the given Signal
is ignored.
pub fn set_ignore_signal(&mut self, signal: Signal, set: bool)
[src]
Sets whether the given Signal
will be ignored.
pub fn report_signal(&self, signal: Signal) -> bool
[src]
Returns whether the given Signal
is to be reported.
pub fn set_report_signal(&mut self, signal: Signal, set: bool)
[src]
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))
.
pub fn disable_completion(&self) -> bool
[src]
Returns whether Tab completion is disabled.
The default value is false
.
pub fn set_disable_completion(&mut self, disable: bool)
[src]
Sets the disable-completion
variable.
pub fn echo_control_characters(&self) -> bool
[src]
When certain control characters are pressed, a character sequence equivalent to this character will be echoed.
The default value is true
.
pub fn set_echo_control_characters(&mut self, echo: bool)
[src]
Sets the echo-control-characters
variable.
pub fn completion_append_character(&self) -> Option<char>
[src]
Returns the character, if any, that is appended to a successful completion.
pub fn set_completion_append_character(&mut self, ch: Option<char>)
[src]
Sets the character, if any, that is appended to a successful completion.
pub fn completion_display_width(&self) -> usize
[src]
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()
.
pub fn set_completion_display_width(&mut self, n: usize)
[src]
Sets the completion-display-width
variable.
pub fn completion_query_items(&self) -> usize
[src]
Returns the minimum number of completion items that require user confirmation before listing.
The default value is 100
.
pub fn set_completion_query_items(&mut self, n: usize)
[src]
Sets the completion-query-items
variable.
pub fn keyseq_timeout(&self) -> Option<Duration>
[src]
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.
pub fn set_keyseq_timeout(&mut self, timeout: Option<Duration>)
[src]
Sets the keyseq-timeout
variable.
pub fn page_completions(&self) -> bool
[src]
Returns whether to list possible completions one page at a time.
The default value is true
.
pub fn set_page_completions(&mut self, set: bool)
[src]
Sets the page-completions
variable.
pub fn print_completions_horizontally(&self) -> bool
[src]
Returns whether to list completions horizontally, rather than down the screen.
The default value is false
.
pub fn set_print_completions_horizontally(&mut self, set: bool)
[src]
Sets the print-completions-horizontally
variable.
pub fn string_chars(&self) -> &str
[src]
Returns the set of characters that delimit strings.
pub fn set_string_chars<T>(&mut self, chars: T) where
T: Into<Cow<'static, str>>,
[src]
T: Into<Cow<'static, str>>,
Sets the set of characters that delimit strings.
pub fn word_break_chars(&self) -> &str
[src]
Returns the set of characters that indicate a word break.
pub fn set_word_break_chars<T>(&mut self, chars: T) where
T: Into<Cow<'static, str>>,
[src]
T: Into<Cow<'static, str>>,
Sets the set of characters that indicate a word break.
ⓘImportant traits for BindingIter<'a>pub fn bindings(&self) -> BindingIter
[src]
Returns an iterator over bound sequences
pub fn bind_sequence<T>(&mut self, seq: T, cmd: Command) -> Option<Command> where
T: Into<Cow<'static, str>>,
[src]
T: Into<Cow<'static, str>>,
Binds a sequence to a command.
Returns the previously bound command.
pub fn bind_sequence_if_unbound<T>(&mut self, seq: T, cmd: Command) -> bool where
T: Into<Cow<'static, str>>,
[src]
T: Into<Cow<'static, str>>,
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.
pub fn unbind_sequence(&mut self, seq: &str) -> Option<Command>
[src]
Removes a binding for the given sequence.
Returns the previously bound command.
pub fn define_function<T>(
&mut self,
name: T,
cmd: Arc<Function<Term>>
) -> Option<Arc<Function<Term>>> where
T: Into<Cow<'static, str>>,
[src]
&mut self,
name: T,
cmd: Arc<Function<Term>>
) -> Option<Arc<Function<Term>>> where
T: Into<Cow<'static, str>>,
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.
pub fn remove_function(&mut self, name: &str) -> Option<Arc<Function<Term>>>
[src]
Removes a function defined with the given name.
Returns the defined function.