Expand description
This crate provide an easy and zero config multiple selector in terminal.
ยงUsage
ยงFirst: add this crate to your project
cargo add valintaยงNext:
use valinta::select;
fn main() -> std::io::Result<()> {
let animals = vec![
"๐ฆ gorilla",
"๐ชผ jellyfish",
"๐ฆ lion",
"๐ honeybee",
"๐ boar",
"๐ฆ bat",
"๐ snail",
"๐จ koala",
"๐ฆ owl",
"๐ข turtle",
"๐ฌ dolphin",
];
let selected_animals = select(&animals).expect("Error message");
Ok(())
}ยงOr by using ValintaError
use valinta::{select, ValintaError};
fn main() -> Result<(), ValintaError> {
let animals = vec![
"๐ฆ gorilla",
"๐ชผ jellyfish",
"๐ฆ lion",
"๐ honeybee",
"๐ boar",
"๐ฆ bat",
"๐ snail",
"๐จ koala",
"๐ฆ owl",
"๐ข turtle",
"๐ฌ dolphin",
];
let selected_animals = select(&animals)?;
Ok(())
}ยงUser interactions
| key pressed | Action |
|---|---|
| โ | Next item |
| โ | Previous item |
| a or A | Select all |
| n or N | Deselect all |
| i or I | Invert selection |
| space | Toggle current |
| enter | Confirm selection |
| esc | Break |
ยงReturned type
A tupple which include the selected data and the indexes of selected data
pub type Returned<T> = (Vec<T>, Vec<usize>);Enumsยง
- Valinta
Error - Errors for this crate
Functionsยง
- select
selectis the main function of this crate