displayLayout and Rendering TUI library | 
          
| git clone git://git.dimitrijedobrota.com/display.git | 
| Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | 
| commit | fae1cade3835e915157b194f62f128dd12ad1bd3 | 
| parent | 0a2055e0d50fb99f07a402275c0bab779453f22c | 
| author | Dimitrije Dobrota < mail@dimitrijedobrota.com > | 
| date | Tue, 18 Feb 2025 03:18:14 +0100 | 
Add clean method instead of relying on destructor
* Move semantics now make more sense
* Get rid of unnecessary ElementPlace
| M | CMakeLists.txt | | | + - | 
| M | example/navig/navig.cpp | | | ------------------ | 
| M | include/display/element.hpp | | | +++ --------------------- | 
| M | include/display/layout.hpp | | | +++++++++++++++++ | 
| M | include/display/window.hpp | | | + | 
| M | source/window.cpp | | | ++++++++++++ | 
6 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/ CMakeLists.txt b/ CMakeLists.txt
          @@ -4,7 +4,7 @@ 
          include(cmake/prelude.cmake)
        
        
          project(
              display
              VERSION 0.1.26
              VERSION 0.1.27
              DESCRIPTION "TUI library"
              HOMEPAGE_URL "git://git.dimitrijedobrota.com/display.git"
              LANGUAGES CXX
        
        diff --git a/ example/navig/navig.cpp b/ example/navig/navig.cpp
          @@ -25,24 +25,6 @@ 
          public:
        
        
            {
            }
            WindowCustom(const WindowCustom&) = delete;
            WindowCustom& operator=(const WindowCustom&) = delete;
            WindowCustom(WindowCustom&&) = default;
            WindowCustom& operator=(WindowCustom&&) = default;
            ~WindowCustom() override
            {
              std::cout << alec::background_v<alec::Color::DEFAULT>;
              std::cout << alec::foreground_v<alec::Color::DEFAULT>;
              line_empty(/* reset = */ true);
              for (std::size_t i = 1; i < ahgt(); i++) {
                line_empty();
              }
              std::cout << std::flush;
            }
            void render() const override
            {
              std::cout << alec::background_v<alec::Color::BLUE>;
        
        diff --git a/ include/display/element.hpp b/ include/display/element.hpp
@@ -3,7 +3,8 @@
#include "display/types.hpp"
          namespace display
          { class Element
          {
          class Element
          {
          public:
            explicit Element(aplace_t aplc)
        
        
          @@ -21,6 +22,7 @@ 
          public:
        
        
            virtual void resize(aplace_t aplc) { m_aplc = aplc; }
            virtual void render() const = 0;
            virtual void clear() const = 0;
            virtual void input(event& evnt) = 0;
            const auto& aplc() const { return m_aplc; }
        
        
          @@ -35,24 +37,4 @@ 
          private:
        
        
            aplace_t m_aplc;
          };
          class ElementPlace : public Element
          {
          public:
            ElementPlace(aplace_t aplc, place_t plc)
                : Element(aplc)
                , m_plc(plc)
            {
            }
            const auto& plc() const { return m_plc; }
            const auto& pos() const { return plc().pos; }
            const auto& dim() const { return plc().dim; }
            const auto& xpos() const { return pos().x; }
            const auto& ypos() const { return pos().y; }
            const auto& wth() const { return dim().width; }
          private:
            place_t m_plc;
          };
          }  // namespace display
        
        diff --git a/ include/display/layout.hpp b/ include/display/layout.hpp
          @@ -37,6 +37,13 @@ 
          public:
        
        
              }
            }
            void clear() const override
            {
              if (has_child()) {
                m_child->clear();
              }
            }
            void input(event& evnt) override
            {
              if (has_child()) {
        
        
          @@ -48,6 +55,9 @@ 
          public:
        
        
              requires(std::is_base_of_v<T, M>)
            M& set_child(Args&&... args)
            {
              if (has_child()) {
                m_child->clear();
              }
              m_child = std::make_unique<M>(aplc(), std::forward<Args>(args)...);
              return get_child<M>();
            }
        
        
          @@ -100,6 +110,13 @@ 
          public:
        
        
              }
            }
            void clear() const override
            {
              for (const auto& child : m_children) {
                child->clear();
              }
            }
            void input(event& evnt) override
            {
              for (auto& child : m_children) {
        
        diff --git a/ include/display/window.hpp b/ include/display/window.hpp
          @@ -14,6 +14,7 @@ 
          public:
        
        
            {
            }
            void clear() const override;
            void input(event& /* unused */) override {}
          protected:
        
        diff --git a/ source/window.cpp b/ source/window.cpp
@@ -6,6 +6,18 @@
namespace display
          {
          void Window::clear() const
          {
            std::cout << alec::background_v<alec::Color::DEFAULT>;
            std::cout << alec::foreground_v<alec::Color::DEFAULT>;
            line_empty(/* reset = */ true);
            for (std::size_t i = 1; i < ahgt(); i++) {
              line_empty();
            }
            std::cout << std::flush;
          }
          std::ostream& Window::next_line(bool reset) const
          {
            if (reset) {