1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! This crate provide an easy and zero config multiple selector in terminal.
//!
//! # Usage
//!
//! ## First: add this crate to your project
//!
//! ```bash
//! 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*
//!
//! ```rust
//! 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>);
//! ```
//!
// Internal modules
/// Exposed and flattenned modules
pub use ValintaError;
pub use select;