mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 10:40:00 +08:00
Support F1-F5 from OS terminal (#687)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/685
This commit is contained in:
parent
46042ce74a
commit
2ed61a9d31
@ -5,6 +5,7 @@ Changelog
|
||||
---
|
||||
|
||||
### Component
|
||||
- Bugfix: Support F1-F5 from OS terminal.
|
||||
|
||||
### Dom
|
||||
- Feature: Add `hyperlink` decorator. For instance:
|
||||
|
@ -44,6 +44,13 @@ const std::map<std::string, std::string> g_uniformize = {
|
||||
{"\x1BOH", "\x1B[H"}, // HOME
|
||||
{"\x1BOF", "\x1B[F"}, // END
|
||||
|
||||
// Variations around the FN keys.
|
||||
// See: https://github.com/ArthurSonzogni/FTXUI/issues/685
|
||||
{"\x1B[[A", "\x1BOP"}, // F1
|
||||
{"\x1B[[B", "\x1BOQ"}, // F2
|
||||
{"\x1B[[C", "\x1BOR"}, // F3
|
||||
{"\x1B[[D", "\x1BOS"}, // F4
|
||||
{"\x1B[[E", "\x1B[15~"}, // F5
|
||||
};
|
||||
|
||||
TerminalInputParser::TerminalInputParser(Sender<Task> out)
|
||||
@ -291,9 +298,16 @@ TerminalInputParser::Output TerminalInputParser::ParseCSI() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Current() >= ' ' && Current() <= '~' && Current() != '<') {
|
||||
// CSI is terminated by a character in the range 0x40–0x7E
|
||||
// (ASCII @A–Z[\]^_`a–z{|}~),
|
||||
if (Current() >= '@' && Current() <= '~' &&
|
||||
// Note: I don't remember why we exclude '<'
|
||||
Current() != '<' &&
|
||||
// To handle F1-F4, we exclude '['.
|
||||
Current() != '[') {
|
||||
arguments.push_back(argument);
|
||||
argument = 0; // NOLINT
|
||||
|
||||
switch (Current()) {
|
||||
case 'M':
|
||||
return ParseMouse(altered, true, std::move(arguments));
|
||||
|
@ -384,6 +384,13 @@ TEST(Event, Special) {
|
||||
{str("\x1B[23~"), Event::F11},
|
||||
{str("\x1B[24~"), Event::F12},
|
||||
|
||||
// Function keys for virtual terminal:
|
||||
{str("\x1B[[A"), Event::F1},
|
||||
{str("\x1B[[B"), Event::F2},
|
||||
{str("\x1B[[C"), Event::F3},
|
||||
{str("\x1B[[D"), Event::F4},
|
||||
{str("\x1B[[E"), Event::F5},
|
||||
|
||||
// Page up and down:
|
||||
{str("\x1B[5~"), Event::PageUp},
|
||||
{str("\x1B[6~"), Event::PageDown},
|
||||
|
Loading…
Reference in New Issue
Block a user