Fix parsing of keys that are prefix of others. (#58)

The ESC key generates sequences that are prefix of others. For instance:
- ESC => [27]
- F1 =>  [27, 79, 8]

As a result, we can't generate the ESC event when receiving [27],
because it might be the start of the [27, 79, 8] sequence (or not).

Application usually applies a timeout to help detecting the ESC key.
This patch introduce a timeout. It is set to 50ms.

Bug: https://github.com/ArthurSonzogni/FTXUI/issues/55
This commit is contained in:
Arthur Sonzogni
2020-10-25 01:57:56 +02:00
committed by GitHub
parent c13621d1f9
commit 406355df8c
10 changed files with 311 additions and 209 deletions

View File

@@ -91,6 +91,8 @@ add_library(component
src/ftxui/component/radiobox.cpp
src/ftxui/component/screen_interactive.cpp
src/ftxui/component/toggle.cpp
src/ftxui/component/terminal_input_parser.cpp
src/ftxui/component/terminal_input_parser.hpp
)
add_library(ftxui::screen ALIAS screen)
@@ -199,7 +201,7 @@ if (FTXUI_BUILD_TESTS AND ${CMAKE_VERSION} VERSION_GREATER "3.11.4")
add_executable(tests
src/ftxui/component/container_test.cpp
src/ftxui/component/event_test.cpp
src/ftxui/component/terminal_input_parser_test.cpp
src/ftxui/component/radiobox_test.cpp
src/ftxui/component/receiver_test.cpp
src/ftxui/component/toggle_test.cpp
@@ -215,6 +217,9 @@ if (FTXUI_BUILD_TESTS AND ${CMAKE_VERSION} VERSION_GREATER "3.11.4")
PRIVATE gmock
PRIVATE gtest_main
)
target_include_directories(tests
PRIVATE src
)
set_property(TARGET tests PROPERTY CXX_STANDARD 17)
endif()