scroll

Function scroll 

Source
pub fn scroll<T: Into<String>, T2: IntoIterator>(
    name: T,
    values: T2,
) -> TerminalMenuItem
where T2::Item: Into<String>,
Expand description

Make a terminal-menu item from which you can select a value from a selection. All values are dispalyed all the time.

ยงExample

use terminal_menu::{menu, scroll, run, mut_menu};
let menu = menu(vec![
    scroll("My Scrolls Name", vec![
        "First Option",
        "Second Option",
        "Third Option"
    ])
]);
run(&menu);
println!("My Scrolls Value: {}", mut_menu(&menu).selection_value("My Scrolls Name"));
Examples found in repository?
examples/readme.rs (line 8)
1fn main() {
2    use terminal_menu::{run, menu, label, scroll, list, string, password, numeric, submenu, back_button};
3    let menu = menu(vec![
4        label("--------------"),
5        label("MY lovely menu!"),
6        label("usage: tinker around"),
7        label("---------------"),
8        scroll("Selection", vec!["First Option", "Second Option", "Third Option"]),
9        list("Do Something", vec!["Yes", "No"]),
10        string("Your Name", "Samuel", false),
11        password("Your Password", "pass", false),
12        numeric("Numeric", 5.25, None, None, None),
13        submenu("Submenu", vec![back_button("Back")]),
14        back_button("Exit"),
15    ]);
16    run(&menu);
17}
More examples
Hide additional examples
examples/selections.rs (line 23)
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}
examples/submenus.rs (line 13)
5fn main() {
6    use terminal_menu::{menu, label, button, scroll, back_button, submenu, run, mut_menu};
7    let menu = menu(vec![
8        label("submenus"),
9
10        // submenu:
11        //  submenus are basically menus inside menus
12        submenu("sub", vec![
13            scroll("scr", vec!["Alice", "Bob", "Charlie"]),
14
15            // back button:
16            //  back buttons return to the parent menu.
17            back_button("back")
18        ]),
19
20        submenu("ret", vec![
21
22            // button:
23            //  buttons exit all the menus
24            button("Alice"),
25            button("Bob"),
26            button("Charlie"),
27
28            submenu("nested", vec![
29                button("Alice"),
30                button("Bob"),
31                button("Charlie"),
32            ])
33
34        ]),
35
36        button("exit")
37    ]);
38    run(&menu);
39
40    // name of the menu active before exiting
41    println!("{:?}", mut_menu(&menu).get_latest_menu_name());
42
43    // pull values
44    println!("{}", mut_menu(&menu).get_submenu("sub").selection_value("scr"));
45}