Revert "Make TerminalUI::get_next_key() helpers static"

On macOS, backspace reportedly no longer works after <c-z> and fg.
The value of m_original_termios.c_cc[VERASE] seems to be wrong
in a static lambda that captures a singleton "this".
Not sure what's the problem. I thought that it is guaranteed that
"static auto convert = [this]() { ... }" is initialized lazily,
hence it should capture the correct address. Maybe the address
changes somehow or it's UB / a compiler bug.

This reverts commit ad36585b7a

Closes #5155
This commit is contained in:
Johannes Altmanninger 2024-05-17 10:39:32 +02:00 committed by Maxime Coste
parent 4e5631daf3
commit 7a90473267

View File

@ -702,7 +702,7 @@ Optional<Key> TerminalUI::get_next_key()
static constexpr auto control = [](char c) { return c & 037; }; static constexpr auto control = [](char c) { return c & 037; };
static auto convert = [this](Codepoint c) -> Codepoint { auto convert = [this](Codepoint c) -> Codepoint {
if (c == control('m') or c == control('j')) if (c == control('m') or c == control('j'))
return Key::Return; return Key::Return;
if (c == control('i')) if (c == control('i'))
@ -717,7 +717,7 @@ Optional<Key> TerminalUI::get_next_key()
return Key::Escape; return Key::Escape;
return c; return c;
}; };
static auto parse_key = [](unsigned char c) -> Key { auto parse_key = [&convert](unsigned char c) -> Key {
if (Codepoint cp = convert(c); cp > 255) if (Codepoint cp = convert(c); cp > 255)
return Key{cp}; return Key{cp};
// Special case: you can type NUL with Ctrl-2 or Ctrl-Shift-2 or // Special case: you can type NUL with Ctrl-2 or Ctrl-Shift-2 or
@ -756,7 +756,7 @@ Optional<Key> TerminalUI::get_next_key()
return mod; return mod;
}; };
auto parse_csi = [this]() -> Optional<Key> { auto parse_csi = [this, &convert]() -> Optional<Key> {
auto next_char = [] { return get_char().value_or((unsigned char)0xff); }; auto next_char = [] { return get_char().value_or((unsigned char)0xff); };
int params[16][4] = {}; int params[16][4] = {};
auto c = next_char(); auto c = next_char();