Add an example of using newline
use rustyline::validate::MatchingBracketValidator;
-use rustyline::{Editor, Result};
+use rustyline::{Cmd, Editor, EventHandler, KeyCode, KeyEvent, Modifiers, Result};
use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator};
#[derive(Completer, Helper, Highlighter, Hinter, Validator)]
@@ -14,6 +14,10 @@ fn main() -> Result<()> {
};
let mut rl = Editor::new()?;
rl.set_helper(Some(h));
+ rl.bind_sequence(
+ KeyEvent(KeyCode::Char('s'), Modifiers::CTRL),
+ EventHandler::Simple(Cmd::Newline),
+ );
let input = rl.readline("> ")?;
println!("Input: {}", input);
