From d7a59810484015eda26ab34938512c54f6477d4e Mon Sep 17 00:00:00 2001 From: Tom Crayford Date: Sun, 8 Jan 2017 21:09:02 +0000 Subject: print glutin events if --print-events is passed When debugging many issues, it's often very helpful to have the raw glutin events printed out to stderr as they come in. This does that. Note that since `glutin::Event` doesn't implement `Display`, we just use rust's debugging output for now via `{:?}`. --- src/event.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index bdfe2708..03d0ef7f 100644 --- a/src/event.rs +++ b/src/event.rs @@ -9,6 +9,7 @@ use parking_lot::MutexGuard; use glutin::{self, ElementState}; use config::Config; +use cli::Options; use display::OnResize; use index::{Line, Column, Side}; use input::{self, ActionContext, MouseBinding, KeyBinding}; @@ -58,6 +59,7 @@ impl Default for Mouse { pub struct Processor { key_bindings: Vec, mouse_bindings: Vec, + print_events: bool, notifier: N, mouse: Mouse, resize_tx: mpsc::Sender<(u32, u32)>, @@ -83,6 +85,7 @@ impl Processor { pub fn new( notifier: N, resize_tx: mpsc::Sender<(u32, u32)>, + options: &Options, config: &Config, ref_test: bool, size_info: SizeInfo, @@ -90,6 +93,7 @@ impl Processor { Processor { key_bindings: config.key_bindings().to_vec(), mouse_bindings: config.mouse_bindings().to_vec(), + print_events: options.print_events, notifier: notifier, resize_tx: resize_tx, ref_test: ref_test, @@ -184,6 +188,9 @@ impl Processor { // Convenience macro which curries most arguments to handle_event. macro_rules! process { ($event:expr) => { + if self.print_events { + err_println!("glutin event: {:?}", $event); + } Processor::handle_event( &mut processor, $event, -- cgit v1.2.3-54-g00ecf