visual_selection/
visual_selection.rs

1use lineeditor::style::Style;
2use lineeditor::LineEditor;
3use lineeditor::LineEditorResult;
4use lineeditor::StringPrompt;
5
6fn main() {
7    let prompt = StringPrompt::new("prompt> ".to_string());
8    let mut line_editor = LineEditor::new(Box::new(prompt));
9
10    let mut style = Style::default();
11    style.set_background_color(lineeditor::Color::Cyan);
12    line_editor.set_visual_selection_style(Some(style));
13
14    let bindings = line_editor.keybinding();
15    bindings.register_common_control_bindings();
16    bindings.register_common_navigation_bindings();
17    bindings.register_common_edit_bindings();
18    bindings.register_common_selection_bindings();
19
20    match line_editor.read_line() {
21        Ok(LineEditorResult::Success(line)) => {
22            println!("Line {}", line);
23        }
24        _ => {}
25    }
26}