FTXUI/ftxui/src/ftxui/dom/separator.cpp

39 lines
751 B
C++
Raw Normal View History

#include "ftxui/dom/node.hpp"
2018-09-20 03:52:25 +08:00
namespace ftxui {
using ftxui::Screen;
2018-09-20 03:52:25 +08:00
class Separator : public Node {
public:
Separator() {}
~Separator() override {}
void ComputeRequirement() override {
requirement_.min.x = 1;
requirement_.min.y = 1;
}
void Render(Screen& screen) override {
bool is_column = (box_.right == box_.left);
bool is_line = (box_.top == box_.bottom);
wchar_t c = U'+';
if (is_line && !is_column)
c = U'';
else
2018-09-20 03:52:25 +08:00
c = U'';
for (int y = box_.top; y <= box_.bottom; ++y) {
for (int x = box_.left; x <= box_.right; ++x) {
screen.at(x, y) = c;
}
}
}
};
std::unique_ptr<Node> separator() {
return std::make_unique<Separator>();
}
}; // namespace ftxui