summaryrefslogtreecommitdiff
path: root/src/keys.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/keys.cc')
-rw-r--r--src/keys.cc14
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' },