Skip to content

Commit

Permalink
Add example for custom key bindings
Browse files Browse the repository at this point in the history
- custom key sequence binding
  • Loading branch information
gwenn committed Mar 7, 2021
1 parent 3d692d3 commit bf55c10
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/custom_key_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use smallvec::smallvec;
use std::borrow::Cow::{self, Borrowed, Owned};

use rustyline::highlight::Highlighter;
Expand Down Expand Up @@ -88,6 +89,10 @@ fn main() {
KeyEvent::from('\t'),
EventHandler::Conditional(Box::new(TabEventHandler)),
);
rl.bind_sequence(
Event::KeySeq(smallvec![KeyEvent::ctrl('X'), KeyEvent::ctrl('E')]),
EventHandler::Simple(Cmd::Suspend), // TODO external editor
);

loop {
let readline = rl.readline("> ");
Expand Down

0 comments on commit bf55c10

Please sign in to comment.