aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <jwilm@users.noreply.github.com>2017-01-08 21:43:27 -0800
committerGitHub <noreply@github.com>2017-01-08 21:43:27 -0800
commit2fa271419c4765f7758dcf336fe0b913c12c18a6 (patch)
tree36b43ff5b0de3e326a96e0e92313e395d63db574
parent9e856bc9d2c99f8cef143786d42c8f4c40de4a5f (diff)
parentd7a59810484015eda26ab34938512c54f6477d4e (diff)
downloadalacritty-2fa271419c4765f7758dcf336fe0b913c12c18a6.tar.gz
alacritty-2fa271419c4765f7758dcf336fe0b913c12c18a6.zip
Merge pull request #236 from tcrayford/print_glutin_events
print glutin events if --print-events is passed
-rw-r--r--src/cli.rs3
-rw-r--r--src/event.rs7
-rw-r--r--src/main.rs1
3 files changed, 11 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index e95114c7..8500ebab 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -16,6 +16,7 @@ use index::{Line, Column};
/// Options specified on the command line
pub struct Options {
+ pub print_events: bool,
pub ref_test: bool,
pub columns: Column,
pub lines: Line,
@@ -25,6 +26,7 @@ pub struct Options {
impl Default for Options {
fn default() -> Options {
Options {
+ print_events: false,
ref_test: false,
columns: Column(80),
lines: Line(24),
@@ -43,6 +45,7 @@ impl Options {
match &arg[..] {
// Generate ref test
"--ref-test" => options.ref_test = true,
+ "--print-events" => options.print_events = true,
// Set dimensions
"-d" | "--dimensions" => {
args_iter.next()
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<N> {
key_bindings: Vec<KeyBinding>,
mouse_bindings: Vec<MouseBinding>,
+ print_events: bool,
notifier: N,
mouse: Mouse,
resize_tx: mpsc::Sender<(u32, u32)>,
@@ -83,6 +85,7 @@ impl<N: Notify> Processor<N> {
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<N: Notify> Processor<N> {
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<N: Notify> Processor<N> {
// 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,
diff --git a/src/main.rs b/src/main.rs
index fb305e7c..cda28d13 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -118,6 +118,7 @@ fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> {
let mut processor = event::Processor::new(
event_loop::Notifier(loop_tx),
display.resize_channel(),
+ &options,
&config,
options.ref_test,
display.size().to_owned(),