Interpret 8 as 127 (#510)

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/508

Apparently, this is a common issue:
https://www.cs.colostate.edu/~mcrob/toolbox/unix/keyboard.html
This commit is contained in:
Arthur Sonzogni (slow/sick) 2022-11-17 22:16:25 +01:00 committed by GitHub
parent 1689802349
commit 2c5681ee20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -19,6 +19,8 @@ const std::map<std::string, std::string> g_uniformize = {{
// See https://github.com/ArthurSonzogni/FTXUI/issues/337
// Here, we uniformize the new line character to `\n`.
{"\r", "\n"},
// See: https://github.com/ArthurSonzogni/FTXUI/issues/508
{std::string({8}), std::string({127})},
}};
TerminalInputParser::TerminalInputParser(Sender<Task> out)

View File

@ -302,7 +302,7 @@ TEST(Event, Control) {
};
std::vector<TestCase> cases;
for (int i = 0; i < 32; ++i) {
if (i == 13 || i == 24 || i == 26 || i == 27)
if (i == 8 || i == 13 || i == 24 || i == 26 || i == 27)
continue;
cases.push_back({char(i), false});
}
@ -342,6 +342,8 @@ TEST(Event, Special) {
{str("\x1B[A"), Event::ArrowUp},
{str("\x1B[B"), Event::ArrowDown},
{{127}, Event::Backspace},
// Quirk for: https://github.com/ArthurSonzogni/FTXUI/issues/508
{{8}, Event::Backspace},
{str("\x1B[3~"), Event::Delete},
//{str("\x1B"), Event::Escape},
{{10}, Event::Return},