diff options
author | Josh Rahm <rahm@google.com> | 2021-10-25 22:49:16 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2021-10-25 22:49:16 -0600 |
commit | b28edbad4eea1c4c8b233925ec520ec8f401d407 (patch) | |
tree | be33004cff5a196a03ee469de0b650f685fc81f7 /alacritty/src/input.rs | |
parent | 01554367f00f7c39ad17163cd5922a069284844a (diff) | |
download | r-alacritty-experimental.tar.gz r-alacritty-experimental.tar.bz2 r-alacritty-experimental.zip |
add logo key prefix and alt behavior configuration optionsexperimental
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 7851b6e4..a5f9590b 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -9,6 +9,7 @@ use std::borrow::Cow; use std::cmp::{max, min, Ordering}; use std::marker::PhantomData; use std::time::{Duration, Instant}; +use log::{trace}; use glutin::dpi::PhysicalPosition; use glutin::event::{ @@ -29,7 +30,7 @@ use alacritty_terminal::term::{ClipboardType, SizeInfo, Term, TermMode}; use alacritty_terminal::vi_mode::ViMotion; use crate::clipboard::Clipboard; -use crate::config::{Action, BindingMode, Config, Key, MouseAction, SearchAction, ViAction}; +use crate::config::{Action, BindingMode, Config, Key, MouseAction, SearchAction, ViAction, AltBehavior}; use crate::daemon::start_daemon; use crate::display::hint::HintMatch; use crate::display::window::Window; @@ -723,6 +724,7 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { /// Process key input. pub fn key_input(&mut self, input: KeyboardInput) { + trace!("Input {:?}\n", input); // All key bindings are disabled while a hint is being selected. if self.ctx.display().hint_state.active() { *self.ctx.suppress_chars() = false; @@ -792,10 +794,13 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { let utf8_len = c.len_utf8(); let mut all_bytes = Vec::new(); - let shift = self.ctx.modifiers().shift(); + let mut shift = self.ctx.modifiers().shift(); let alt = self.ctx.modifiers().alt(); let ctrl = self.ctx.modifiers().ctrl(); let logo = self.ctx.modifiers().logo(); + let termkey = alt && self.ctx.config().ui_config.alt_behavior == AltBehavior::TERMKEY; + + trace!("Got Char {}", c as u32); fn encode_extended_ctrl_char(c: char) -> bool { return ! c.is_ascii_control() @@ -804,11 +809,24 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { || c == '\x07'; } - if ((shift || alt || encode_extended_ctrl_char(c)) && ctrl) || logo { + if logo { + let prefix = &self.ctx.config().ui_config.logo_key_prefix; + all_bytes.append(&mut prefix.as_bytes().to_vec()); + } + + if ((shift || alt) && (ctrl || c.is_ascii_control())) || termkey { + + let newshift = if c > 0x20.into() && c != 0x7f.into() { + // Really shift is only good for characters that don't have an + // associated shifted form. + false + } else { + shift + }; + // Special, extended character code let modifier_code = - 1 + (shift as u32) + (alt as u32) * 2 + (ctrl as u32) * 4 + (logo as u32) * 8; - + 1 + (newshift as u32) + (alt as u32) * 2 + (ctrl as u32) * 4; let out = format!("\x1b[{};{}u", c as u32, modifier_code); all_bytes.append(&mut out.into_bytes()); } else { @@ -819,7 +837,7 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { c.encode_utf8(&mut char_bytes[..]); } - if self.ctx.config().ui_config.alt_send_esc + if self.ctx.config().ui_config.alt_behavior == AltBehavior::SEND_ESC && *self.ctx.received_count() == 0 && alt { |