pub struct Input { /* private fields */ }Expand description
One line of text.
Implementations§
Source§impl Input
impl Input
pub fn new(prompt: impl Into<String>) -> Input
Sourcepub fn masked(prompt: impl Into<String>) -> Input
pub fn masked(prompt: impl Into<String>) -> Input
A masked input, for passwords and tokens: what is typed shows as
•, and a default only as (default set).
pub fn mask(self, mask: char) -> Self
Sourcepub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
Make keys do action (see input_keymap) on this input only;
no keys unbinds it.
Sourcepub fn placeholder(self, placeholder: impl Into<String>) -> Self
pub fn placeholder(self, placeholder: impl Into<String>) -> Self
Dim text shown while the line is empty.
Sourcepub fn default(self, default: impl Into<String>) -> Self
pub fn default(self, default: impl Into<String>) -> Self
The answer when Enter is pressed on an empty line, and without a terminal when the policy asks for defaults.
Sourcepub fn validate(
self,
validator: impl Fn(&str) -> Result<(), String> + 'static,
) -> Self
pub fn validate( self, validator: impl Fn(&str) -> Result<(), String> + 'static, ) -> Self
Check the answer on Enter; an Err message shows under the line.
Sourcepub fn history<I: IntoIterator<Item = S>, S: Into<String>>(
self,
history: I,
) -> Self
pub fn history<I: IntoIterator<Item = S>, S: Into<String>>( self, history: I, ) -> Self
Earlier answers, oldest first, for Up and Down.
Sourcepub fn suggestions<I: IntoIterator<Item = S>, S: Into<Suggestion>>(
self,
suggestions: I,
) -> Self
pub fn suggestions<I: IntoIterator<Item = S>, S: Into<Suggestion>>( self, suggestions: I, ) -> Self
Fixed suggestions, filtered by what is typed.
Sourcepub fn provider(
self,
provider: impl Fn(&str) -> Vec<Suggestion> + Send + Sync + 'static,
) -> Self
pub fn provider( self, provider: impl Fn(&str) -> Vec<Suggestion> + Send + Sync + 'static, ) -> Self
Suggestions from provider, called on a background thread after
each change; results for text since changed are dropped.
pub fn theme(self, theme: Theme) -> Self
Sourcepub fn buffer(&self) -> &TextBuffer
pub fn buffer(&self) -> &TextBuffer
The line being edited.
Sourcepub fn resolve(&self) -> Result<String, String>
pub fn resolve(&self) -> Result<String, String>
The answer Enter would give: the text, or the default when empty, checked by the validator.
Sourcepub fn field(&self, available: usize) -> (Vec<Segment>, usize)
pub fn field(&self, available: usize) -> (Vec<Segment>, usize)
The line’s text as shown (masked, or the placeholder) in
available cells, scrolled to keep the caret in view, and the
caret’s column in it.
Sourcepub fn suggesting(&self) -> bool
pub fn suggesting(&self) -> bool
Whether suggestions are showing: Tab, Up, Down and Enter (with one selected) are theirs.
Sourcepub fn has_selection(&self) -> bool
pub fn has_selection(&self) -> bool
Whether Enter would accept a selected suggestion rather than submit.
Sourcepub fn accept_selected(&mut self)
pub fn accept_selected(&mut self)
Accept the selected suggestion, as Enter does before submitting.
Sourcepub fn suggestion_rows(&self, width: usize, indent: &str) -> Vec<Vec<Segment>>
pub fn suggestion_rows(&self, width: usize, indent: &str) -> Vec<Vec<Segment>>
The suggestion rows (or a pending marker), each after indent.
Sourcepub fn display_value(&self, value: &str) -> String
pub fn display_value(&self, value: &str) -> String
value as this input shows it: masked, for a masked input.
Trait Implementations§
Source§impl Component for Input
impl Component for Input
type Output = String
Source§fn handle(&mut self, event: &Event, _: &Context<'_>) -> Flow<String>
fn handle(&mut self, event: &Event, _: &Context<'_>) -> Flow<String>
Outcome::Interrupted.Source§fn tick(&self) -> Option<Duration>
fn tick(&self) -> Option<Duration>
Event::Tick, for a spinner or a
countdown. None (the default): never.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn default_value(&self) -> Option<String>
fn default_value(&self) -> Option<String>
None: there is none.Source§fn prompt(
&mut self,
io: &mut dyn LineIo,
) -> Result<Option<String>, NotInteractive>
fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<String>, NotInteractive>
Source§fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
fn start(&mut self, context: &Context<'_>) -> Flow<Self::Output>
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
run then enables mouse reporting
for the session.Source§fn focusable(&self) -> bool
fn focusable(&self) -> bool
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
forward) or previous focus stop inside
this component, for Tab and Shift+Tab. false when there is none
after the current one, so the container moves on to its next
child. The default, for a component that is one stop: false.Auto Trait Implementations§
impl !RefUnwindSafe for Input
impl !Send for Input
impl !Sync for Input
impl !UnwindSafe for Input
impl Freeze for Input
impl Unpin for Input
impl UnsafeUnpin for Input
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> ComponentExt for Cwhere
C: Component,
impl<C> ComponentExt for Cwhere
C: Component,
Source§fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
M’s flow: Flow::Done(m) to
finish the whole composition with m, Flow::Continue to carry on
(the component stays, showing its answer, and focus moves past it).
Cancelling cancels the composition unless
on_cancel says otherwise.