2018-10-10 01:06:03 +08:00
|
|
|
#include "ftxui/dom/node.hpp"
|
2018-09-20 03:52:25 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2019-01-07 00:10:35 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
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'─';
|
2019-01-05 09:03:49 +08:00
|
|
|
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>();
|
|
|
|
}
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
}; // namespace ftxui
|