From 4ac28b56758915563db10d295000640106d0eb37 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Wed, 2 Jul 2025 20:17:51 +0200 Subject: [PATCH] Add unique_ptr --- include/ftxui/component/screen_interactive.hpp | 9 +++++++++ include/ftxui/screen/image.hpp | 3 +++ include/ftxui/screen/screen.hpp | 4 +++- src/ftxui/component/screen_interactive.cpp | 13 ++++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/ftxui/component/screen_interactive.hpp b/include/ftxui/component/screen_interactive.hpp index f9220ff8e..63c8d9684 100644 --- a/include/ftxui/component/screen_interactive.hpp +++ b/include/ftxui/component/screen_interactive.hpp @@ -26,6 +26,10 @@ struct Event; using Component = std::shared_ptr; class ScreenInteractivePrivate; +namespace task { + class TaskRunner; +} + /// @brief ScreenInteractive is a `Screen` that can handle events, run a main /// loop, and manage components. /// @@ -40,6 +44,9 @@ class ScreenInteractive : public Screen { static ScreenInteractive FitComponent(); static ScreenInteractive TerminalOutput(); + // Destructor. + ~ScreenInteractive(); + // Options. Must be called before Loop(). void TrackMouse(bool enable = true); @@ -156,6 +163,8 @@ class ScreenInteractive : public Screen { std::unique_ptr selection_; std::function selection_on_change_; + std::unique_ptr task_runner_; + friend class Loop; public: diff --git a/include/ftxui/screen/image.hpp b/include/ftxui/screen/image.hpp index 77e471992..4ec335713 100644 --- a/include/ftxui/screen/image.hpp +++ b/include/ftxui/screen/image.hpp @@ -20,6 +20,9 @@ class Image { Image() = delete; Image(int dimx, int dimy); + // Destructor: + virtual ~Image() = default; + // Access a character in the grid at a given position. std::string& at(int x, int y); const std::string& at(int x, int y) const; diff --git a/include/ftxui/screen/screen.hpp b/include/ftxui/screen/screen.hpp index aa2f4f8cc..efde98e42 100644 --- a/include/ftxui/screen/screen.hpp +++ b/include/ftxui/screen/screen.hpp @@ -11,7 +11,6 @@ #include "ftxui/screen/image.hpp" // for Pixel, Image #include "ftxui/screen/terminal.hpp" // for Dimensions -#include "ftxui/util/autoreset.hpp" // for AutoReset namespace ftxui { @@ -31,6 +30,9 @@ class Screen : public Image { static Screen Create(Dimensions dimension); static Screen Create(Dimensions width, Dimensions height); + // Destructor: + ~Screen() override = default; + std::string ToString() const; // Print the Screen on to the terminal. diff --git a/src/ftxui/component/screen_interactive.cpp b/src/ftxui/component/screen_interactive.cpp index e9f3f0d93..54c8d091a 100644 --- a/src/ftxui/component/screen_interactive.cpp +++ b/src/ftxui/component/screen_interactive.cpp @@ -30,11 +30,12 @@ #include "ftxui/component/loop.hpp" // for Loop #include "ftxui/component/receiver.hpp" // for ReceiverImpl, Sender, MakeReceiver, SenderImpl, Receiver #include "ftxui/component/terminal_input_parser.hpp" // for TerminalInputParser -#include "ftxui/dom/node.hpp" // for Node, Render -#include "ftxui/dom/requirement.hpp" // for Requirement -#include "ftxui/screen/pixel.hpp" // for Pixel -#include "ftxui/screen/terminal.hpp" // for Dimensions, Size -#include "ftxui/screen/util.hpp" // for util::clamp +#include "ftxui/core/task_runner.hpp" +#include "ftxui/dom/node.hpp" // for Node, Render +#include "ftxui/dom/requirement.hpp" // for Requirement +#include "ftxui/screen/pixel.hpp" // for Pixel +#include "ftxui/screen/terminal.hpp" // for Dimensions, Size +#include "ftxui/screen/util.hpp" // for util::clamp #if defined(_WIN32) #define DEFINE_CONSOLEV2_PROPERTIES @@ -417,6 +418,8 @@ ScreenInteractive ScreenInteractive::TerminalOutput() { }; } +ScreenInteractive::~ScreenInteractive() = default; + /// Create a ScreenInteractive whose width and height match the component being /// drawn. // static