From 898cd842e2b7f7e3568702d9520647e78b2d1147 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Fri, 1 May 2020 23:45:17 +0200 Subject: [PATCH] Catch SIGINT event. This was an old features, but it has been removed mistakenly when merging some patches. This allow the terminal to be restored when the user kill the application. --- src/ftxui/component/screen_interactive.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index 439dd7f4..aeea098a 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -211,6 +211,11 @@ void ScreenInteractive::Loop(Component* component) { // Handle resize. on_resize = [&] { event_sender_->Send(Event::Special({0})); }; install_signal_handler(SIGWINCH, OnResize); + + // Install a SIGINT handler and restore the old handler on exit. + auto old_sigint_handler = std::signal(SIGINT, OnExit); + on_exit_functions.push( + [old_sigint_handler]() { std::signal(SIGINT, old_sigint_handler); }); #endif // Hide the cursor and show it at exit.