From ad36585b7ad236bea7d1c02b0679ae371c3c2a9e Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 11 Mar 2023 16:19:15 +0100 Subject: [PATCH] Make TerminalUI::get_next_key() helpers static The only depend on the TerminalUI object which is a singleton, so we can make them all static. --- src/terminal_ui.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc index 311c2527..1df9480c 100644 --- a/src/terminal_ui.cc +++ b/src/terminal_ui.cc @@ -700,7 +700,7 @@ Optional TerminalUI::get_next_key() static constexpr auto control = [](char c) { return c & 037; }; - auto convert = [this](Codepoint c) -> Codepoint { + static auto convert = [this](Codepoint c) -> Codepoint { if (c == control('m') or c == control('j')) return Key::Return; if (c == control('i')) @@ -715,7 +715,7 @@ Optional TerminalUI::get_next_key() return Key::Escape; return c; }; - auto parse_key = [&convert](unsigned char c) -> Key { + static auto parse_key = [](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 @@ -743,7 +743,7 @@ Optional TerminalUI::get_next_key() return Key{utf8::codepoint(CharIterator{c}, Sentinel{})}; }; - auto parse_mask = [](int mask) { + static auto parse_mask = [](int mask) { Key::Modifiers mod = Key::Modifiers::None; if (mask & 1) mod |= Key::Modifiers::Shift; @@ -754,7 +754,7 @@ Optional TerminalUI::get_next_key() return mod; }; - auto parse_csi = [this, &convert, &parse_mask]() -> Optional { + auto parse_csi = [this]() -> Optional { auto next_char = [] { return get_char().value_or((unsigned char)0xff); }; int params[16][4] = {}; auto c = next_char(); @@ -899,7 +899,7 @@ Optional TerminalUI::get_next_key() return {}; }; - auto parse_ss3 = [&parse_mask]() -> Optional { + static auto parse_ss3 = []() -> Optional { int raw_mask = 0; char code = '0'; do {