-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinput_filter.rs
More file actions
27 lines (23 loc) · 823 Bytes
/
input_filter.rs
File metadata and controls
27 lines (23 loc) · 823 Bytes
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
use lineeditor::input_filter::InputFilter;
use lineeditor::LineEditor;
use lineeditor::LineEditorResult;
use lineeditor::StringPrompt;
fn main() {
let prompt = StringPrompt::new("prompt> ".to_string());
let mut line_editor = LineEditor::new(Box::new(prompt));
line_editor.set_input_filter(InputFilter::Options(vec![
Box::new(InputFilter::Digit),
Box::new(InputFilter::Whitespace),
]));
let bindings = line_editor.keybinding();
bindings.register_common_control_bindings();
bindings.register_common_navigation_bindings();
bindings.register_common_edit_bindings();
bindings.register_common_selection_bindings();
match line_editor.read_line() {
Ok(LineEditorResult::Success(line)) => {
println!("Line {}", line);
}
_ => {}
}
}