diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2024-05-17 10:39:32 +0200 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-05-18 11:35:48 +1000 |
| commit | 7a90473267f7f2fd8df5ae933c7b287c31ce3c97 (patch) | |
| tree | 287532836cd8056481beb8d26964a451034f49ac | |
| parent | 4e5631daf3a62bff1d7c4d2e697535ed4ebffcba (diff) | |
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 ad36585b7ad236bea7d1c02b0679ae371c3c2a9e
Closes #5155
| -rw-r--r-- | src/terminal_ui.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index 3ad95e40..52a25e26 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -702,7 +702,7 @@ Optional<Key> TerminalUI::get_next_key() 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')) return Key::Return; if (c == control('i')) @@ -717,7 +717,7 @@ Optional<Key> TerminalUI::get_next_key() return Key::Escape; 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) return Key{cp}; // 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; }; - 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][4] = {}; auto c = next_char(); |
