aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-11-15 09:38:50 -0800
committerJoe Wilm <joe@jwilm.com>2016-11-17 17:17:54 -0800
commitd97996e19de6856c23c51d05ec10f10db41e309d (patch)
tree80e43240687249f5062bcd16d64492ae32b0625d /src/event.rs
parentcb2bc4eadd3d149fcae4d1b552be47bc5a9413d8 (diff)
downloadalacritty-d97996e19de6856c23c51d05ec10f10db41e309d.tar.gz
alacritty-d97996e19de6856c23c51d05ec10f10db41e309d.zip
Make bindings configurable from alacritty.yml
Bindings were previously hardcoded within input.rs; adding, removing, or changing a binding required a recompile! Now, bindings may be declared in alacritty.yml. Even better, bindings are live-reloaded when alacritty.yml is changed! One unexpected benefit of this change was that all of the special casing in input.rs has disappeared. Conversely, config.rs has gained complexity for all of the deserialization logic. Resolves #3.
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/event.rs b/src/event.rs
index 46b96ab0..430671cb 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -7,6 +7,7 @@ use input;
use sync::FairMutex;
use term::Term;
use util::encode_char;
+use config::Config;
/// The event processor
pub struct Processor<N> {
@@ -24,12 +25,13 @@ impl<N: input::Notify> Processor<N> {
pub fn new(
notifier: N,
terminal: Arc<FairMutex<Term>>,
- resize_tx: mpsc::Sender<(u32, u32)>
+ resize_tx: mpsc::Sender<(u32, u32)>,
+ config: &Config,
) -> Processor<N> {
Processor {
notifier: notifier,
terminal: terminal,
- input_processor: input::Processor::new(),
+ input_processor: input::Processor::new(config),
resize_tx: resize_tx,
}
}
@@ -37,28 +39,6 @@ impl<N: input::Notify> Processor<N> {
fn handle_event(&mut self, event: glutin::Event) {
match event {
glutin::Event::Closed => panic!("window closed"), // TODO ...
- // glutin::Event::ReceivedCharacter(c) => {
- // match c {
- // // Ignore BACKSPACE and DEL. These are handled specially.
- // '\u{8}' | '\u{7f}' => (),
- // // Extra thing on macOS delete?
- // '\u{f728}' => (),
- // // OSX arrow keys send invalid characters; ignore.
- // '\u{f700}' | '\u{f701}' | '\u{f702}' | '\u{f703}' => (),
- // // Same with home/end. Am I missing something? Would be
- // // nice if glutin provided the received char in
- // // KeyboardInput event so a choice could be made there
- // // instead of having to special case everything.
- // '\u{f72b}' | '\u{f729}' | '\u{f72c}' | '\u{f72d}' => (),
- // // These letters are handled in the bindings system
- // 'v' => (),
- // _ => {
- // println!("printing char {:?}", c);
- // let buf = encode_char(c);
- // self.notifier.notify(buf);
- // }
- // }
- // },
glutin::Event::Resized(w, h) => {
self.resize_tx.send((w, h)).expect("send new size");
// Acquire term lock
@@ -99,4 +79,8 @@ impl<N: input::Notify> Processor<N> {
self.handle_event(event);
}
}
+
+ pub fn update_config(&mut self, config: &Config) {
+ self.input_processor.update_config(config);
+ }
}