mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-26 04:31:34 +08:00
Support F1-F5 from OS terminal (#687)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/685
This commit is contained in:
parent
da32a8ba0a
commit
34688fdd8c
@ -12,6 +12,7 @@ current (development)
|
|||||||
- Feature: `ResizeableSplit` now support arbitrary element as a separator.
|
- Feature: `ResizeableSplit` now support arbitrary element as a separator.
|
||||||
- Feature: `input` is now supporting multiple lines.
|
- Feature: `input` is now supporting multiple lines.
|
||||||
- Feature: `input` style is now customizeable.
|
- Feature: `input` style is now customizeable.
|
||||||
|
- Bugfix: Support F1-F5 from OS terminal.
|
||||||
|
|
||||||
### Dom
|
### Dom
|
||||||
- Feature: Add `hyperlink` decorator. For instance:
|
- Feature: Add `hyperlink` decorator. For instance:
|
||||||
|
@ -44,6 +44,13 @@ const std::map<std::string, std::string> g_uniformize = {
|
|||||||
{"\x1BOH", "\x1B[H"}, // HOME
|
{"\x1BOH", "\x1B[H"}, // HOME
|
||||||
{"\x1BOF", "\x1B[F"}, // END
|
{"\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)
|
TerminalInputParser::TerminalInputParser(Sender<Task> out)
|
||||||
@ -291,9 +298,16 @@ TerminalInputParser::Output TerminalInputParser::ParseCSI() {
|
|||||||
continue;
|
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);
|
arguments.push_back(argument);
|
||||||
argument = 0; // NOLINT
|
argument = 0; // NOLINT
|
||||||
|
|
||||||
switch (Current()) {
|
switch (Current()) {
|
||||||
case 'M':
|
case 'M':
|
||||||
return ParseMouse(altered, true, std::move(arguments));
|
return ParseMouse(altered, true, std::move(arguments));
|
||||||
|
@ -385,6 +385,13 @@ TEST(Event, Special) {
|
|||||||
{str("\x1B[23~"), Event::F11},
|
{str("\x1B[23~"), Event::F11},
|
||||||
{str("\x1B[24~"), Event::F12},
|
{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:
|
// Page up and down:
|
||||||
{str("\x1B[5~"), Event::PageUp},
|
{str("\x1B[5~"), Event::PageUp},
|
||||||
{str("\x1B[6~"), Event::PageDown},
|
{str("\x1B[6~"), Event::PageDown},
|
||||||
|
Loading…
Reference in New Issue
Block a user