summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-01-29 22:49:14 +0000
committerMaxime Coste <frrrwww@gmail.com>2012-01-29 22:49:14 +0000
commit6579b43ffb76b77917a9c3fcf158375485a4e6ca (patch)
treea2d38a8ed98455186e98c971e873a4cafb3901f2 /src
parent73a8950e73ecb8769848c2c9b993d0d88d7c9fef (diff)
make parse_keys handle <c-*> and <a-*> keys.
Diffstat (limited to 'src')
-rw-r--r--src/keys.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/keys.cc b/src/keys.cc
index bf6a4cdc..a2f65e2c 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -5,8 +5,10 @@
namespace Kakoune
{
-static std::unordered_map<std::string, Key> keynamemap = {
- { "ret", { Key::Modifiers::None, '\n' } }
+static std::unordered_map<std::string, char> keynamemap = {
+ { "ret", '\n' },
+ { "space", ' ' },
+ { "esc", 27 }
};
KeyList parse_keys(const std::string& str)
@@ -22,11 +24,32 @@ KeyList parse_keys(const std::string& str)
if (end_pos < str.length())
{
+ Key::Modifiers modifier = Key::Modifiers::None;
+
std::string keyname = str.substr(pos+1, end_pos - pos - 1);
+ if (keyname.length() > 2)
+ {
+ if (tolower(keyname[0]) == 'c' and keyname[1] == '-')
+ {
+ modifier = Key::Modifiers::Control;
+ keyname = keyname.substr(2);
+ }
+ if (tolower(keyname[0]) == 'a' and keyname[1] == '-')
+ {
+ modifier = Key::Modifiers::Control;
+ keyname = keyname.substr(2);
+ }
+ }
+ if (keyname.length() == 1)
+ {
+ result.push_back(Key{ modifier, keyname[0] });
+ pos = end_pos;
+ continue;
+ }
auto it = keynamemap.find(keyname);
if (it != keynamemap.end())
{
- result.push_back(it->second);
+ result.push_back(Key{ modifier, it->second });
pos = end_pos;
continue;
}