Add support for parsing SS3 key sequences
As discussed on #3087, fixes part of that issue.
This commit is contained in:
parent
271b1d4f2f
commit
df6d0355d6
|
@ -772,16 +772,32 @@ Optional<Key> NCursesUI::get_next_key()
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto parse_ss3 = [this]() -> Optional<Key> {
|
||||||
|
switch (get_char().value_or((unsigned char)0xff))
|
||||||
|
{
|
||||||
|
case 'A': return Key{Key::Up};
|
||||||
|
case 'B': return Key{Key::Down};
|
||||||
|
case 'C': return Key{Key::Right};
|
||||||
|
case 'D': return Key{Key::Left};
|
||||||
|
case 'F': return Key{Key::End};
|
||||||
|
case 'H': return Key{Key::Home};
|
||||||
|
case 'P': return Key{Key::F1};
|
||||||
|
case 'Q': return Key{Key::F2};
|
||||||
|
case 'R': return Key{Key::F3};
|
||||||
|
case 'S': return Key{Key::F4};
|
||||||
|
default: return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (*c != 27)
|
if (*c != 27)
|
||||||
return parse_key(*c);
|
return parse_key(*c);
|
||||||
|
|
||||||
if (auto next = get_char())
|
if (auto next = get_char())
|
||||||
{
|
{
|
||||||
if (*next == '[') // potential CSI
|
if (*next == '[') // potential CSI
|
||||||
{
|
return parse_csi().value_or(alt('['));
|
||||||
if (auto key = parse_csi())
|
if (*next == 'O') // potential SS3
|
||||||
return key;
|
return parse_ss3().value_or(alt('O'));
|
||||||
}
|
|
||||||
return alt(parse_key(*next));
|
return alt(parse_key(*next));
|
||||||
}
|
}
|
||||||
return Key{Key::Escape};
|
return Key{Key::Escape};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user