selections/
selections.rs

1///
2/// List and scroll terminal-menu items explained.
3///
4
5fn main() {
6    use terminal_menu::{menu, label, button, list, scroll, run, mut_menu};
7    let menu = menu(vec![
8        label("lists and scrolls"),
9
10        // with list and scroll you can select a value from a group of values
11        // you can change the selected value with arrow keys, wasd, or enter
12
13        // use arrow keys or wasd
14        // enter to select
15
16        // list:
17        //  show all values
18        //  surround the selected value with brackets
19        list("li", vec!["Alice", "Bob", "Charlie"]),
20
21        // scroll:
22        //  show only the selected item
23        scroll("sc", vec!["Alice", "Bob", "Charlie"]),
24
25        button("exit")
26    ]);
27    run(&menu);
28    {
29        let mm = mut_menu(&menu);
30        if mm.canceled() {
31            println!("Canceled!");
32            return;
33        }
34        println!("{}", mm.selection_value("li"));
35        println!("{}", mm.selection_value("sc"));
36    }
37}