diff --git a/src/input_handler.cc b/src/input_handler.cc index d91f30d9..33f8d947 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -627,7 +627,9 @@ void InputHandler::on_next_key(KeyCallback callback) void InputHandler::handle_next_input(Context& context) { - m_mode->on_key(context.ui().get_key(), context); + Key key = context.ui().get_key(); + if (key != Key::Invalid) + m_mode->on_key(key, context); context.draw_ifn(); } diff --git a/src/keys.hh b/src/keys.hh index 76063eb6..19a83575 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -29,6 +29,7 @@ struct Key PageUp, PageDown, BackTab, + Invalid, }; Modifiers modifiers; @@ -42,6 +43,9 @@ struct Key constexpr bool operator==(const Key& other) const { return modifiers == other.modifiers and key == other.key; } + + constexpr bool operator!=(const Key& other) const + { return modifiers != other.modifiers or key != other.key; } }; typedef std::vector KeyList; diff --git a/src/ncurses.cc b/src/ncurses.cc index 6418c26b..57eabd4e 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -216,8 +216,12 @@ Key NCursesUI::get_key() case KEY_BTAB: return Key::BackTab; } - ungetch(c); - return utf8::codepoint(getch_iterator{}); + if (c < 256) + { + ungetch(c); + return utf8::codepoint(getch_iterator{}); + } + return Key::Invalid; } void NCursesUI::print_status(const String& status, CharCount cursor_pos)