numeric

Function numeric 

Source
pub fn numeric<T: Into<String>>(
    name: T,
    default: f64,
    step: Option<f64>,
    min: Option<f64>,
    max: Option<f64>,
) -> TerminalMenuItem
Expand description

Make a terminal-menu item from which you can select a number between specified bounds.

ยงExample

use terminal_menu::{menu, numeric, run, mut_menu};
let menu = menu(vec![
    numeric("My Numerics Name",
        0.0,  //default
        Some(0.5),  //step (optional)
        Some(-5.0), //minimum (optional)
        Some(10.0)  //maximum (optional)
    )
]);
run(&menu);
println!("My Numerics Value: {}", mut_menu(&menu).numeric_value("My Numerics Name"))
Examples found in repository?
examples/readme.rs (line 12)
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/string_and_numeric.rs (lines 25-37)
5fn main() {
6    use terminal_menu::{menu, label, button, string, password, numeric, run, mut_menu};
7    let menu = menu(vec![
8        label("strings and numerics"),
9
10        // string:
11        //  a string of characters
12        //  the last arguments specifies if empty strings are allowed
13
14        // empty strings allowed:
15        string("ste", "default", true),
16
17        // empty strings not allowed:
18        string("stn", "default", false),
19
20        // password:
21        password("pass", "default", true),
22
23        // numeric:
24        //  a floating point number
25        numeric("num",
26            // default
27            4.5,
28
29            // step
30            Some(1.5),
31
32            // minimum
33            None,
34
35            // maximum
36            Some(150.0)
37        ),
38
39        button("exit")
40    ]);
41    run(&menu);
42    {
43        let mm = mut_menu(&menu);
44        if mm.canceled() {
45            println!("Canceled!");
46            return;
47        }
48        println!("{}", mm.selection_value("ste"));
49        println!("{}", mm.selection_value("stn"));
50        println!("{}", mm.selection_value("pass"));
51        println!("{}", mm.numeric_value("num"));
52    }
53}