aboutsummaryrefslogtreecommitdiff
path: root/alacritty
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-10-06 18:39:54 -0600
committerJosh Rahm <rahm@google.com>2021-10-06 18:39:54 -0600
commit750d1e196875a7063da5aa38673d0792911e8ad3 (patch)
tree504168e482ce8f5ecaf5382610c1e8175134f512 /alacritty
parent7a209fa45f1f4d07cb4a885e8ea3d03e47cf48ae (diff)
downloadr-alacritty-750d1e196875a7063da5aa38673d0792911e8ad3.tar.gz
r-alacritty-750d1e196875a7063da5aa38673d0792911e8ad3.tar.bz2
r-alacritty-750d1e196875a7063da5aa38673d0792911e8ad3.zip
Add some more terminal code stuff.
- The <Hyper> key now sends <C-M-S-Insert> to make keybinding easier. - the <Ctrl> key with a multibyte character now prepends <C-M-S-Insert> - <Shift-Space> now returns the "\x1b[32;2u" - <Shift-Alt> now sends ""\x1b\x1b[32;2u""
Diffstat (limited to 'alacritty')
-rw-r--r--alacritty/src/config/bindings.rs4
-rw-r--r--alacritty/src/input.rs27
2 files changed, 22 insertions, 9 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index a4271430..9f4bbaee 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -417,6 +417,10 @@ pub fn default_key_bindings() -> Vec<KeyBinding> {
Action::Esc("\x1bOD".into());
Left, ~BindingMode::APP_CURSOR, ~BindingMode::VI, ~BindingMode::SEARCH;
Action::Esc("\x1b[D".into());
+ Space, ModifiersState::SHIFT, ~BindingMode::SEARCH, ~BindingMode::VI;
+ Action::Esc("\x1b[32;2u".into());
+ Space, ModifiersState::SHIFT | ModifiersState::ALT, ~BindingMode::SEARCH, ~BindingMode::VI;
+ Action::Esc("\x1b\x1b[32;2u".into());
Back, ~BindingMode::VI, ~BindingMode::SEARCH; Action::Esc("\x7f".into());
Insert, ~BindingMode::VI, ~BindingMode::SEARCH; Action::Esc("\x1b[2~".into());
Delete, ~BindingMode::VI, ~BindingMode::SEARCH; Action::Esc("\x1b[3~".into());
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;
}