diff options
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index b8ae4b00..a3b9fdf9 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -790,28 +790,37 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { self.ctx.clear_selection(); let utf8_len = c.len_utf8(); - let mut bytes = Vec::with_capacity(utf8_len); + let mut char_bytes = Vec::with_capacity(utf8_len); + let mut all_bytes = Vec::new(); unsafe { - bytes.set_len(utf8_len); - c.encode_utf8(&mut bytes[..]); + char_bytes.set_len(utf8_len); + c.encode_utf8(&mut char_bytes[..]); } if self.ctx.config().ui_config.alt_send_esc && *self.ctx.received_count() == 0 && self.ctx.modifiers().alt() { - bytes.insert(0, b'\x1b'); + all_bytes.push(b'\x1b'); } if self.ctx.modifiers().logo() { - bytes.insert(0, b'\\'); - bytes.insert(0, b'\x1b'); - bytes.insert(0, b'@'); - bytes.insert(0, b'\x1b'); + // In this case, either the Hyper or Windows key is held down, in + // this case prepend with '^[[2;8~', whic is <C-S-M-Insert>. THis + // is better keybinding in Vim. + all_bytes.append(&mut vec![b'\x1b', b'[', b'2', b';', b'8', b'~']); } - self.ctx.write_to_pty(bytes); + if self.ctx.modifiers().ctrl() && utf8_len > 1 { + // In this case, it's a multibyte character that also has CTRL + // down. This prepends said character with '^[[1;8H', which + // is <C-S-M-Home>. This is for even better keybinding in vim. + all_bytes.append(&mut vec![b'\x1b', b'[', b'1', b';', b'8', b'H']); + } + + all_bytes.append(&mut char_bytes); + self.ctx.write_to_pty(all_bytes); *self.ctx.received_count() += 1; } |