diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-07-10 21:00:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-10 21:00:33 +0000 |
commit | 9ece44e76216861fee14df6c8b635982268d254e (patch) | |
tree | ec6a65a97f17feb6c9be31ce03f9072d567161d4 /alacritty/src/input.rs | |
parent | 1e595431c006948827745e541b1da8325ba0c74d (diff) | |
download | r-alacritty-9ece44e76216861fee14df6c8b635982268d254e.tar.gz r-alacritty-9ece44e76216861fee14df6c8b635982268d254e.tar.bz2 r-alacritty-9ece44e76216861fee14df6c8b635982268d254e.zip |
Add readline bindings to search
Fixes #3938.
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index cab0f0e2..64b79002 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -99,6 +99,7 @@ pub trait ActionContext<T: EventListener> { fn cancel_search(&mut self); fn push_search(&mut self, c: char); fn pop_search(&mut self); + fn pop_word_search(&mut self); fn search_direction(&self) -> Direction; fn search_active(&self) -> bool; } @@ -807,19 +808,34 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { pub fn key_input(&mut self, input: KeyboardInput) { match input.state { ElementState::Pressed if self.ctx.search_active() => { - match input.virtual_keycode { - Some(VirtualKeyCode::Back) => { + match (input.virtual_keycode, *self.ctx.modifiers()) { + (Some(VirtualKeyCode::Back), _) => { self.ctx.pop_search(); *self.ctx.suppress_chars() = true; }, - Some(VirtualKeyCode::Return) => { + (Some(VirtualKeyCode::Return), _) + | (Some(VirtualKeyCode::J), ModifiersState::CTRL) => { self.ctx.confirm_search(); *self.ctx.suppress_chars() = true; }, - Some(VirtualKeyCode::Escape) => { + (Some(VirtualKeyCode::Escape), _) => { self.ctx.cancel_search(); *self.ctx.suppress_chars() = true; }, + (Some(VirtualKeyCode::U), ModifiersState::CTRL) => { + let direction = self.ctx.search_direction(); + self.ctx.cancel_search(); + self.ctx.start_search(direction); + *self.ctx.suppress_chars() = true; + }, + (Some(VirtualKeyCode::H), ModifiersState::CTRL) => { + self.ctx.pop_search(); + *self.ctx.suppress_chars() = true; + }, + (Some(VirtualKeyCode::W), ModifiersState::CTRL) => { + self.ctx.pop_word_search(); + *self.ctx.suppress_chars() = true; + }, _ => (), } @@ -1127,6 +1143,8 @@ mod tests { fn pop_search(&mut self) {} + fn pop_word_search(&mut self) {} + fn search_direction(&self) -> Direction { Direction::Right } |