NCursesUI: Handle CSI in 8-bit mode as well

This commit is contained in:
Maxime Coste 2018-12-09 11:20:03 +11:00
parent e90e77e5fc
commit 1670a7514a

View File

@ -656,12 +656,7 @@ Optional<Key> NCursesUI::get_next_key()
return {}; return {};
}; };
if (c == 27) auto parse_csi = [this]() -> Optional<Key> {
{
wtimeout(m_window, 0);
const int new_c = wgetch(m_window);
if (new_c == '[') // potential CSI
{
const Codepoint c1 = wgetch(m_window); const Codepoint c1 = wgetch(m_window);
switch (c1) switch (c1)
{ {
@ -712,6 +707,17 @@ Optional<Key> NCursesUI::get_next_key()
ungetch(c1); ungetch(c1);
break; break;
} }
return {};
};
if (c == 27)
{
wtimeout(m_window, 0);
const int new_c = wgetch(m_window);
if (new_c == '[') // potential CSI
{
if (auto key = parse_csi())
return key;
} }
wtimeout(m_window, -1); wtimeout(m_window, -1);
@ -720,6 +726,9 @@ Optional<Key> NCursesUI::get_next_key()
else else
return {Key::Escape}; return {Key::Escape};
} }
else if (c == 0x9b)
return parse_csi();
return parse_key(c); return parse_key(c);
} }