mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 03:10:01 +08:00
Make catching SIGNAL SIGINT to work also on windows.
This commit is contained in:
parent
898cd842e2
commit
2d292b5382
@ -176,6 +176,11 @@ void ScreenInteractive::PostEvent(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScreenInteractive::Loop(Component* component) {
|
void ScreenInteractive::Loop(Component* component) {
|
||||||
|
// 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); });
|
||||||
|
|
||||||
// Save the old terminal configuration and restore it on exit.
|
// Save the old terminal configuration and restore it on exit.
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// Enable VT processing on stdout and stdin
|
// Enable VT processing on stdout and stdin
|
||||||
@ -211,11 +216,6 @@ void ScreenInteractive::Loop(Component* component) {
|
|||||||
// Handle resize.
|
// Handle resize.
|
||||||
on_resize = [&] { event_sender_->Send(Event::Special({0})); };
|
on_resize = [&] { event_sender_->Send(Event::Special({0})); };
|
||||||
install_signal_handler(SIGWINCH, OnResize);
|
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
|
#endif
|
||||||
|
|
||||||
// Hide the cursor and show it at exit.
|
// Hide the cursor and show it at exit.
|
||||||
|
Loading…
Reference in New Issue
Block a user