From d5f5f0989d516a3954876272b496c5e9b628c66a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 3 Sep 2012 19:21:11 +0200 Subject: [PATCH] fix control key parsing --- src/keys.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/keys.cc b/src/keys.cc index 5acfdaed..5d8ef4a1 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -5,8 +5,19 @@ namespace Kakoune { +Key canonicalize_ifn(Key key) +{ + if (key.key > 0 and key.key < 27) + { + assert(key.modifiers == Key::Modifiers::None); + key.modifiers = Key::Modifiers::Control; + key.key = key.key - 1 + 'a'; + } + return key; +} + static std::unordered_map keynamemap = { - { "ret", '\n' }, + { "ret", '\r' }, { "space", ' ' }, { "esc", 27 } }; @@ -49,7 +60,8 @@ KeyList parse_keys(const String& str) auto it = keynamemap.find(keyname); if (it != keynamemap.end()) { - result.push_back(Key{ modifier, it->second }); + Key key = canonicalize_ifn(Key{ modifier, it->second }); + result.push_back(key); pos = end_pos; continue; }