diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-08-18 00:19:14 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-08-18 00:19:14 +0100 |
| commit | f2580a366d716dc68d1f6ee744d3003f06cbcfde (patch) | |
| tree | 3c8d0139977d75782ca1daaebcd9478e24fa6a45 /src/keys.cc | |
| parent | 043ca9998396bf447c693b1e72078e840f582d11 (diff) | |
Cleanup key to codepoint conversion
Fixes #378
Fixes #365
Diffstat (limited to 'src/keys.cc')
| -rw-r--r-- | src/keys.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/keys.cc b/src/keys.cc index b01fcc52..349cbd53 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -10,7 +10,7 @@ namespace Kakoune { -Key canonicalize_ifn(Key key) +static Key canonicalize_ifn(Key key) { if (key.key > 0 and key.key < 27) { @@ -21,6 +21,18 @@ Key canonicalize_ifn(Key key) return key; } +Optional<Codepoint> Key::codepoint() const +{ + if (*this == ctrl('m')) + return '\n'; + if (*this == ctrl('i')) + return '\t'; + if (modifiers == Modifiers::None and key > 27 and + (key < 0xD800 or key > 0xDFFF)) // avoid surrogates + return key; + return {}; +} + struct KeyAndName { const char* name; Codepoint key; }; static constexpr KeyAndName keynamemap[] = { { "ret", '\r' }, |
