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§
Source§impl StringInput
impl StringInput
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new StringInput
which accepts all characters.
Source§impl<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§
Source§impl<F: Clone> Clone for StringInput<F>
impl<F: Clone> Clone for StringInput<F>
Source§fn clone(&self) -> StringInput<F>
fn clone(&self) -> StringInput<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<F: Debug> Debug for StringInput<F>
impl<F: Debug> Debug for StringInput<F>
Source§impl Default for StringInput
impl Default for StringInput
Source§impl<F> Widget for StringInput<F>
impl<F> Widget for StringInput<F>
Source§fn 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.
Source§fn 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> Freeze for StringInput<F>where
F: Freeze,
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§
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
Mutably borrows from an owned value. Read more