pub struct PickerTui {
pub default_query: String,
pub header: Option<String>,
pub auto_accept: bool,
}Fields§
§default_query: StringThe default value of the query text area
header: Option<String>The header text to indicate to the user what is being chosen
auto_accept: boolIf there is zero or one options, automatically accept the choice
Implementations§
Source§impl PickerTui
impl PickerTui
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
More examples
examples/multiline.rs (line 11)
3pub fn main() -> eyre::Result<()> {
4 let choices = vec![
5 "First\nSecond\nThird",
6 "A\nB\nC",
7 "IMPORT BRUH\nDO THING\nWOOHOO!",
8 "single item",
9 "another single item",
10 ];
11 let chosen = PickerTui::new().pick_many(choices)?;
12 println!("You chose: {chosen:#?}");
13 Ok(())
14}examples/pick_a_path.rs (line 12)
4pub fn main() -> eyre::Result<()> {
5 let mut choices = Vec::new();
6 let dir = std::fs::read_dir(".")?;
7 for entry in dir {
8 let entry = entry?;
9 choices.push(entry);
10 }
11
12 let chosen = PickerTui::new()
13 .set_header("Pick a path")
14 .pick_one(choices.into_iter().map(|entry| Choice {
15 key: entry.path().display().to_string(), // the value shown to the user
16 value: entry, // the inner value we want to have after the user picks
17 }))?;
18
19 println!("You chose {}", chosen.file_name().to_string_lossy());
20
21 Ok(())
22}Sourcepub fn set_header(self, header: impl Into<String>) -> Self
pub fn set_header(self, header: impl Into<String>) -> Self
Examples found in repository?
More examples
examples/pick_a_path.rs (line 13)
4pub fn main() -> eyre::Result<()> {
5 let mut choices = Vec::new();
6 let dir = std::fs::read_dir(".")?;
7 for entry in dir {
8 let entry = entry?;
9 choices.push(entry);
10 }
11
12 let chosen = PickerTui::new()
13 .set_header("Pick a path")
14 .pick_one(choices.into_iter().map(|entry| Choice {
15 key: entry.path().display().to_string(), // the value shown to the user
16 value: entry, // the inner value we want to have after the user picks
17 }))?;
18
19 println!("You chose {}", chosen.file_name().to_string_lossy());
20
21 Ok(())
22}pub fn set_auto_accept(self, auto_accept: bool) -> Self
Sourcepub fn pick_one<T>(&self, choices: impl IntoChoices<T>) -> PickResult<T>
pub fn pick_one<T>(&self, choices: impl IntoChoices<T>) -> PickResult<T>
Examples found in repository?
More examples
examples/pick_a_path.rs (lines 14-17)
4pub fn main() -> eyre::Result<()> {
5 let mut choices = Vec::new();
6 let dir = std::fs::read_dir(".")?;
7 for entry in dir {
8 let entry = entry?;
9 choices.push(entry);
10 }
11
12 let chosen = PickerTui::new()
13 .set_header("Pick a path")
14 .pick_one(choices.into_iter().map(|entry| Choice {
15 key: entry.path().display().to_string(), // the value shown to the user
16 value: entry, // the inner value we want to have after the user picks
17 }))?;
18
19 println!("You chose {}", chosen.file_name().to_string_lossy());
20
21 Ok(())
22}Sourcepub fn pick_many<T>(&self, choices: impl IntoChoices<T>) -> PickResult<Vec<T>>
pub fn pick_many<T>(&self, choices: impl IntoChoices<T>) -> PickResult<Vec<T>>
Examples found in repository?
More examples
examples/multiline.rs (line 11)
3pub fn main() -> eyre::Result<()> {
4 let choices = vec![
5 "First\nSecond\nThird",
6 "A\nB\nC",
7 "IMPORT BRUH\nDO THING\nWOOHOO!",
8 "single item",
9 "another single item",
10 ];
11 let chosen = PickerTui::new().pick_many(choices)?;
12 println!("You chose: {chosen:#?}");
13 Ok(())
14}pub async fn pick_one_reloadable<T, F, C>( &self, choice_supplier: F, ) -> PickResult<T>
pub async fn pick_many_reloadable<T, F, C>( &self, choice_supplier: F, ) -> PickResult<Vec<T>>
pub async fn pick_inner_reloadable<T, F, C>( &self, many: bool, choice_supplier: F, ) -> PickResult<Vec<T>>
pub fn pick_inner<T>( &self, many: bool, choices: impl IntoChoices<T>, ) -> PickResult<Vec<T>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PickerTui
impl RefUnwindSafe for PickerTui
impl Send for PickerTui
impl Sync for PickerTui
impl Unpin for PickerTui
impl UnwindSafe for PickerTui
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more