summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-05-12 08:50:27 +1000
committerMaxime Coste <mawww@kakoune.org>2020-05-12 08:50:27 +1000
commit151eb3299d3bf3c966eaa1ff689e0866b7e08ef6 (patch)
tree20a1af63071cacdf7688dac450292883b2ce3740 /src
parent60154300f9235d935e3cfd8e15c2d493fdcfb4ff (diff)
Fix CSI u parsing of some special keys
Diffstat (limited to 'src')
-rw-r--r--src/ncurses_ui.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc
index 4783b823..0f37abfd 100644
--- a/src/ncurses_ui.cc
+++ b/src/ncurses_ui.cc
@@ -605,22 +605,25 @@ Optional<Key> NCursesUI::get_next_key()
if (not c)
return {};
- auto parse_key = [](unsigned char c) -> Key {
+ static constexpr auto convert = [](Codepoint c) -> Codepoint {
if (c == control('m') or c == control('j'))
- return {Key::Return};
+ return Key::Return;
if (c == control('i'))
- return {Key::Tab};
- if (c == control('h'))
- return {Key::Backspace};
+ return Key::Tab;
+ if (c == control('h') or c == 127)
+ return Key::Backspace;
+ return c;
+ };
+ auto parse_key = [](unsigned char c) -> Key {
+ if (Codepoint cp = convert(c); cp > 255)
+ return Key{cp};
if (c == control('z'))
{
kill(0, SIGTSTP); // We suspend at this line
return {};
}
if (c < 27)
- return ctrl(Codepoint(c) - 1 + 'a');
- if (c == 127)
- return {Key::Backspace};
+ return ctrl(c - 1 + 'a');
struct Sentinel{};
struct CharIterator
@@ -735,7 +738,7 @@ Optional<Key> NCursesUI::get_next_key()
}
return {};
case 'u':
- return masked_key(static_cast<Codepoint>(params[0]));
+ return masked_key(convert(static_cast<Codepoint>(params[0])));
case 'Z': return shift(Key::Tab);
case 'I': return {Key::FocusIn};
case 'O': return {Key::FocusOut};