summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-05-27 06:18:39 +0100
committerMaxime Coste <mawww@kakoune.org>2017-05-27 06:18:39 +0100
commit72acb0177dfa97de749b148597b31c9044b5bbda (patch)
tree20814bb0c0cf39027f8c3c5c2392db3829ccfc5b /src/input_handler.cc
parentb9080d8b2c2898e6bba7e26a945ffe564eb38c6c (diff)
Parse meta as 8 bit in Normal mode to fix the terminals using that
The solution is a bit hackish, as we only consider the 8th bit to mean alt in normal mode, because its unlikely accentuated characters are going to be mapped there. It fixes using Alt on xterm, and probably on iterm2 as well (not requiring the meta-sends-esc config change anymore)
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 51c88b57..8c0a7618 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -202,6 +202,15 @@ public:
{
ScopedSetBool set_in_on_key{m_in_on_key};
+ // Hack to parse keys sent by terminals using the 8th bit to mark the
+ // meta key. In normal mode, give priority to a potential alt-key than
+ // the accentuated character.
+ if (key.key >= 127 and key.key < 256)
+ {
+ key.modifiers |= Key::Modifiers::Alt;
+ key.key &= 0x7f;
+ }
+
bool do_restore_hooks = false;
auto restore_hooks = on_scope_end([&, this]{
if (m_hooks_disabled and enabled() and do_restore_hooks)