diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-12-11 08:12:08 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-12-11 08:12:08 +1100 |
| commit | 658b6b0f1aad8dc85c2a49bb50d50e71d0174f1e (patch) | |
| tree | e6e11685df3d743497083db5d641ffd776e497c7 /src/keys.cc | |
| parent | 36eebbce4f803cf08c60bd10c094d06692d84195 (diff) | |
Make space a named key to correctly handle shift modifier
Diffstat (limited to 'src/keys.cc')
| -rw-r--r-- | src/keys.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/keys.cc b/src/keys.cc index 25466fd3..8eb3fce0 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -49,6 +49,8 @@ Optional<Codepoint> Key::codepoint() const return '\n'; if (*this == Key::Tab) return '\t'; + if (*this == Key::Space) + return ' '; if (*this == Key::Escape) return 0x1B; if (modifiers == Modifiers::None and key > 27 and @@ -60,7 +62,7 @@ Optional<Codepoint> Key::codepoint() const struct KeyAndName { const char* name; Codepoint key; }; static constexpr KeyAndName keynamemap[] = { { "ret", Key::Return }, - { "space", ' ' }, + { "space", Key::Space }, { "tab", Key::Tab }, { "lt", '<' }, { "gt", '>' }, @@ -99,6 +101,7 @@ KeyList parse_keys(StringView str) case '\r': return Key::Return; case '\b': return Key::Backspace; case '\t': return Key::Tab; + case ' ': return Key::Space; case '\033': return Key::Escape; default: return cp; } @@ -225,9 +228,9 @@ String key_to_str(Key key) UnitTest test_keys{[]() { KeyList keys{ - { ' ' }, + {Key::Space}, { 'c' }, - { Key::Up }, + {Key::Up}, alt('j'), ctrl('r'), shift(Key::Up), |
