♻ cleanup (exit loops closure carefully)

This commit is contained in:
Vladislav Nepogodin 2021-12-24 03:02:57 +04:00
parent fa2dd4e0f0
commit 04d3dd2b96
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9

View File

@ -3,7 +3,6 @@
#include "utils.hpp" #include "utils.hpp"
/* clang-format off */ /* clang-format off */
#include <csignal> // for raise
#include <algorithm> // for transform #include <algorithm> // for transform
#include <string> // for basic_string #include <string> // for basic_string
#include <ftxui/component/component.hpp> // for Renderer, Button #include <ftxui/component/component.hpp> // for Renderer, Button
@ -148,7 +147,7 @@ bool inputbox_widget(std::string& value, const std::string_view& content, Decora
bool success{}; bool success{};
auto ok_callback = [&] { auto ok_callback = [&] {
success = true; success = true;
std::raise(SIGINT); screen.ExitLoopClosure()();
}; };
InputOption input_option{.on_enter = ok_callback, .password = password}; InputOption input_option{.on_enter = ok_callback, .password = password};
auto input_value = Input(&value, "", input_option); auto input_value = Input(&value, "", input_option);
@ -196,7 +195,7 @@ bool yesno_widget(const std::string_view& content, Decorator boxsize) noexcept {
bool success{}; bool success{};
auto ok_callback = [&] { auto ok_callback = [&] {
success = true; success = true;
std::raise(SIGINT); screen.ExitLoopClosure()();
}; };
ButtonOption button_option{.border = false}; ButtonOption button_option{.border = false};
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option); auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option);
@ -227,7 +226,7 @@ bool yesno_widget(ftxui::Component& container, Decorator boxsize) noexcept {
bool success{}; bool success{};
auto ok_callback = [&] { auto ok_callback = [&] {
success = true; success = true;
std::raise(SIGINT); screen.ExitLoopClosure()();
}; };
ButtonOption button_option{.border = false}; ButtonOption button_option{.border = false};
auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option); auto controls_container = controls_widget({"OK", "Cancel"}, {ok_callback, screen.ExitLoopClosure()}, &button_option);