display

Layout and Rendering TUI library
git clone git://git.dimitrijedobrota.com/display.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit e5755709f2019a6848d826b8d015df83391fddb8
parent f19a7bdf2f3ea69b19640adb9c03fcbbec1d6de9
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Mon, 3 Mar 2025 15:17:48 +0100

Move clear() definition from Window to Element

Diffstat:
M include/display/element.hpp | + -
M include/display/window.hpp | -
M source/element.cpp | ++++++++++
M source/window.cpp | ----------

4 files changed, 11 insertions(+), 12 deletions(-)


diff --git a/ include/display/element.hpp b/ include/display/element.hpp

@@ -22,7 +22,7 @@ public:


virtual void resize(plc_t aplc) { m_aplc = aplc; }
virtual void render() const = 0;
virtual void clear() const = 0;
virtual void clear() const;
virtual void input(event& evnt) = 0;

static std::ostream& set_cursor(xpos_t xapos, ypos_t yapos);

diff --git a/ include/display/window.hpp b/ include/display/window.hpp

@@ -16,7 +16,6 @@ public:

}

void render() const override;
void clear() const override;
void input(event& /* unused */) override {}

protected:

diff --git a/ source/element.cpp b/ source/element.cpp

@@ -16,6 +16,16 @@ std::ostream& Element::set_cursor(pos_t apos)

return set_cursor(apos.x, apos.y);
}

void Element::clear() const
{
std::cout << alec::background_v<alec::Color::DEFAULT>;
std::cout << alec::foreground_v<alec::Color::DEFAULT>;

for (auto j = ypos_t(0); j < aypos() + ahgt(); j++) {
Element::set_cursor(axpos(), j) << std::string(awth().value(), ' ');
}
}

void Element::render_border() const
{
set_cursor(axpos(), aypos());

diff --git a/ source/window.cpp b/ source/window.cpp

@@ -30,16 +30,6 @@ void Window::render() const

}
}

void Window::clear() const
{
std::cout << alec::background_v<alec::Color::DEFAULT>;
std::cout << alec::foreground_v<alec::Color::DEFAULT>;

for (auto j = ypos_t(0); j < aypos() + ahgt(); j++) {
Element::set_cursor(axpos(), j) << std::string(awth().value(), ' ');
}
}

void Window::line_reset() const
{
m_ypos = ypos();