From 4b63bddd55853e878ec0f85b4613dd02749a3811 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Sun, 11 Dec 2016 22:02:03 -0800 Subject: Track terminal cells on mouse movement The cell under the cursor is now tracked in the input processor at `self.mouse.line` and `self.mouse.column`. This could probably be optimized to only compute the cell when in certain states, but the calculation is cheap. --- src/event.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index d8fec37e..4f28649e 100644 --- a/src/event.rs +++ b/src/event.rs @@ -10,7 +10,7 @@ use window::Window; use input; use sync::FairMutex; -use term::Term; +use term::{self, Term}; use config::Config; /// The event processor @@ -34,15 +34,27 @@ impl Processor { config: &Config, ref_test: bool, ) -> Processor { + let input_processor = { + let terminal = terminal.lock(); + input::Processor::new(config, terminal.size_info()) + }; + Processor { notifier: notifier, terminal: terminal, - input_processor: input::Processor::new(config), + input_processor: input_processor, resize_tx: resize_tx, ref_test: ref_test, } } + /// Notify that the terminal was resized + /// + /// Currently this just forwards the notice to the input processor. + pub fn resize(&mut self, size_info: &term::SizeInfo) { + self.input_processor.resize(size_info); + } + fn handle_event(&mut self, event: glutin::Event, wakeup_request: &mut bool) { match event { glutin::Event::Closed => { @@ -71,9 +83,11 @@ impl Processor { }, glutin::Event::Resized(w, h) => { self.resize_tx.send((w, h)).expect("send new size"); - // Acquire term lock - let mut terminal = self.terminal.lock(); - terminal.dirty = true; + + // Previously, this marked the terminal state as "dirty", but + // now the wakeup_request controls whether a display update is + // triggered. + *wakeup_request = true; }, glutin::Event::KeyboardInput(state, _code, key, mods, string) => { // Acquire term lock -- cgit v1.2.3-54-g00ecf