avoid utf8 errors with invalid keys, like ncurse KEY_RESIZE
This commit is contained in:
parent
132c31042e
commit
abf514f305
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Key> KeyList;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user