Struct requestty_ui::widgets::StringInput
source · [−]pub struct StringInput<F = FilterMapChar> { /* private fields */ }
Expand description
A widget that inputs a string.
A filter_map
function can optionally be provided to limit and change the characters allowed,
similar to Iterator::filter_map
.
If only a single character is required, use CharInput
.
Implementations
sourceimpl StringInput
impl StringInput
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new StringInput
which accepts all characters.
sourceimpl<F> StringInput<F>
impl<F> StringInput<F>
sourcepub fn with_filter_map(filter_map: F) -> Self
pub fn with_filter_map(filter_map: F) -> Self
Creates a new StringInput
which only accepts characters as per the filter_map
function.
sourcepub fn mask(self, mask: char) -> Self
pub fn mask(self, mask: char) -> Self
A mask to render instead of the actual characters.
This is useful for passwords.
sourcepub fn hide_output(self) -> Self
pub fn hide_output(self) -> Self
Hide the value being entered, and render nothing.
This is useful for passwords.
sourcepub fn password(self, mask: Option<char>) -> Self
pub fn password(self, mask: Option<char>) -> Self
A helper that sets mask if mask is some, otherwise hides the output
sourcepub fn replace_with<W: FnOnce(String) -> String>(&mut self, with: W)
pub fn replace_with<W: FnOnce(String) -> String>(&mut self, with: W)
Replaces the value with the result of the function
Trait Implementations
sourceimpl<F: Clone> Clone for StringInput<F>
impl<F: Clone> Clone for StringInput<F>
sourcefn clone(&self) -> StringInput<F>
fn clone(&self) -> StringInput<F>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: Debug> Debug for StringInput<F>
impl<F: Debug> Debug for StringInput<F>
sourceimpl Default for StringInput
impl Default for StringInput
sourceimpl<F> Widget for StringInput<F> where
F: Fn(char) -> Option<char>,
impl<F> Widget for StringInput<F> where
F: Fn(char) -> Option<char>,
sourcefn render<B: Backend>(
&mut self,
layout: &mut Layout,
backend: &mut B
) -> Result<()>
fn render<B: Backend>(
&mut self,
layout: &mut Layout,
backend: &mut B
) -> Result<()>
This widget ignores layout.offset_x
and wraps around in the terminal.
sourcefn handle_key(&mut self, key: KeyEvent) -> bool
fn handle_key(&mut self, key: KeyEvent) -> bool
Handle a key input. It should return whether key was handled.
Auto Trait Implementations
impl<F> RefUnwindSafe for StringInput<F> where
F: RefUnwindSafe,
impl<F> Send for StringInput<F> where
F: Send,
impl<F> Sync for StringInput<F> where
F: Sync,
impl<F> Unpin for StringInput<F> where
F: Unpin,
impl<F> UnwindSafe for StringInput<F> where
F: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more