diff options
author | Joe Wilm <joe@jwilm.com> | 2016-12-25 18:54:01 -0500 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-12-25 18:54:01 -0500 |
commit | 3b7c7377c913b92c52f45660fa94001db38c8bc6 (patch) | |
tree | 6b1d9b36f292be47186425f954cd90a7b81684b8 /src/event.rs | |
parent | 7cdf06e2be91159694d39697a41d58abb0e564e9 (diff) | |
download | r-alacritty-3b7c7377c913b92c52f45660fa94001db38c8bc6.tar.gz r-alacritty-3b7c7377c913b92c52f45660fa94001db38c8bc6.tar.bz2 r-alacritty-3b7c7377c913b92c52f45660fa94001db38c8bc6.zip |
Refactor input processing to take action context
Various functions take some permutation of the current selection, the
terminal, and a notifier. Instead of having to juggle some number of
arguments everywhere, the `ActionContext` is constructed and then passed
around.
Diffstat (limited to 'src/event.rs')
-rw-r--r-- | src/event.rs | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/event.rs b/src/event.rs index 79fe9737..706e03fe 100644 --- a/src/event.rs +++ b/src/event.rs @@ -8,7 +8,7 @@ use glutin; use config::Config; use display::OnResize; -use input; +use input::{self, ActionContext}; use selection::Selection; use sync::FairMutex; use term::{Term, SizeInfo}; @@ -98,18 +98,29 @@ impl<N: input::Notify> Processor<N> { // Acquire term lock let terminal = self.terminal.lock(); let processor = &mut self.input_processor; - let notifier = &mut self.notifier; - self.selection.clear(); + { + let mut context = ActionContext { + terminal: &terminal, + notifier: &mut self.notifier, + selection: &mut self.selection, + }; - processor.process_key(state, key, mods, notifier, *terminal.mode(), string); + processor.process_key(&mut context, state, key, mods, string); + } + self.selection.clear(); }, glutin::Event::MouseInput(state, button) => { let terminal = self.terminal.lock(); let processor = &mut self.input_processor; - let notifier = &mut self.notifier; - processor.mouse_input(&mut self.selection, state, button, notifier, &terminal); + let mut context = ActionContext { + terminal: &terminal, + notifier: &mut self.notifier, + selection: &mut self.selection, + }; + + processor.mouse_input(&mut context, state, button); *wakeup_request = true; }, glutin::Event::MouseMoved(x, y) => { @@ -131,11 +142,17 @@ impl<N: input::Notify> Processor<N> { terminal.dirty = true; }, glutin::Event::MouseWheel(scroll_delta, touch_phase) => { + let mut terminal = self.terminal.lock(); let processor = &mut self.input_processor; - let notifier = &mut self.notifier; + + let mut context = ActionContext { + terminal: &terminal, + notifier: &mut self.notifier, + selection: &mut self.selection, + }; processor.on_mouse_wheel( - notifier, + &mut context, scroll_delta, touch_phase, ); |