summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2021-01-19 20:54:11 +1100
committerMaxime Coste <mawww@kakoune.org>2021-01-19 20:54:11 +1100
commitbcaceec3ff41f3a8530c7bfd0122f886df1ae11c (patch)
tree3a55745027e1786c27a194d8a38b718e76e2690e
parent033b55c3ac9f220a6ed2837dc5a2b8bc140fd517 (diff)
parenta7ed1f03fbe8a65a5ab33fbbb5f8a4e5a475a7a2 (diff)
Merge remote-tracking branch 'Screwtapello/distinguish-backspace'
-rw-r--r--src/ncurses_ui.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc
index e52748c9..812e1612 100644
--- a/src/ncurses_ui.cc
+++ b/src/ncurses_ui.cc
@@ -610,16 +610,19 @@ Optional<Key> NCursesUI::get_next_key()
if (not c)
return {};
- static constexpr auto convert = [](Codepoint c) -> Codepoint {
+ const cc_t erase = m_original_termios.c_cc[VERASE];
+ auto convert = [erase](Codepoint c) -> Codepoint {
if (c == control('m') or c == control('j'))
return Key::Return;
if (c == control('i'))
return Key::Tab;
- if (c == control('h') or c == 127)
+ if (c == erase)
return Key::Backspace;
+ if (c == 127) // when it's not backspace
+ return Key::Delete;
return c;
};
- auto parse_key = [](unsigned char c) -> Key {
+ auto parse_key = [&convert](unsigned char c) -> Key {
if (Codepoint cp = convert(c); cp > 255)
return Key{cp};
if (c == control('z'))
@@ -652,7 +655,7 @@ Optional<Key> NCursesUI::get_next_key()
return Key{utf8::codepoint(CharIterator{c}, Sentinel{})};
};
- auto parse_csi = [this]() -> Optional<Key> {
+ auto parse_csi = [this, &convert]() -> Optional<Key> {
auto next_char = [] { return get_char().value_or((unsigned char)0xff); };
int params[16] = {};
auto c = next_char();