From 2c5681ee2061fdcea3958425795dfc0a6b601787 Mon Sep 17 00:00:00 2001 From: "Arthur Sonzogni (slow/sick)" Date: Thu, 17 Nov 2022 22:16:25 +0100 Subject: [PATCH] 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 --- src/ftxui/component/terminal_input_parser.cpp | 2 ++ src/ftxui/component/terminal_input_parser_test.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ftxui/component/terminal_input_parser.cpp b/src/ftxui/component/terminal_input_parser.cpp index d3f2d6a..f19d6ad 100644 --- a/src/ftxui/component/terminal_input_parser.cpp +++ b/src/ftxui/component/terminal_input_parser.cpp @@ -19,6 +19,8 @@ const std::map 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 out) diff --git a/src/ftxui/component/terminal_input_parser_test.cpp b/src/ftxui/component/terminal_input_parser_test.cpp index 922ee19..f0f8163 100644 --- a/src/ftxui/component/terminal_input_parser_test.cpp +++ b/src/ftxui/component/terminal_input_parser_test.cpp @@ -302,7 +302,7 @@ TEST(Event, Control) { }; std::vector 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},