20using Charset = std::array<std::string, 2>;
21using Charsets = std::array<Charset, 6>;
32class Separator :
public Node {
34 explicit Separator(std::string value) : value_(
std::
move(value)) {}
36 void ComputeRequirement()
override {
37 requirement_.min_x = 1;
38 requirement_.min_y = 1;
42 for (
int y = box_.y_min; y <= box_.y_max; ++y) {
43 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
45 pixel.character = value_;
46 pixel.automerge =
true;
54class SeparatorAuto :
public Node {
58 void ComputeRequirement()
override {
59 requirement_.min_x = 1;
60 requirement_.min_y = 1;
64 const bool is_column = (box_.x_max == box_.x_min);
65 const bool is_line = (box_.y_min == box_.y_max);
70 for (
int y = box_.y_min; y <= box_.y_max; ++y) {
71 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
74 pixel.automerge =
true;
82class SeparatorWithPixel :
public SeparatorAuto {
84 explicit SeparatorWithPixel(Pixel
pixel)
86 pixel_.automerge =
true;
89 for (
int y = box_.y_min; y <= box_.y_max; ++y) {
90 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
91 screen.PixelAt(x, y) = pixel_;
135 return std::make_shared<SeparatorAuto>(
LIGHT);
173 return std::make_shared<SeparatorAuto>(
style);
210 return std::make_shared<SeparatorAuto>(
LIGHT);
247 return std::make_shared<SeparatorAuto>(
DASHED);
284 return std::make_shared<SeparatorAuto>(
HEAVY);
321 return std::make_shared<SeparatorAuto>(
DOUBLE);
358 return std::make_shared<SeparatorAuto>(
EMPTY);
396 return std::make_shared<Separator>(std::move(value));
427 return std::make_shared<SeparatorWithPixel>(std::move(
pixel));
453 void ComputeRequirement()
override {
454 requirement_.min_x = 1;
455 requirement_.min_y = 1;
459 if (box_.y_max < box_.y_min) {
467 const int y = box_.y_min;
468 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
471 const int a = (x - box_.x_min) * 2;
478 pixel.automerge =
true;
481 pixel.automerge =
false;
523 void ComputeRequirement()
override {
524 requirement_.min_x = 1;
525 requirement_.min_y = 1;
529 if (box_.x_max < box_.x_min) {
537 const int x = box_.x_min;
538 for (
int y = box_.y_min; y <= box_.y_max; ++y) {
541 const int a = (y - box_.y_min) * 2;
548 pixel.automerge =
true;
551 pixel.automerge =
false;
A class representing terminal colors.
A rectangular grid of Pixel.
Element separatorStyled(BorderStyle)
Draw a vertical or horizontal separation in between two other elements.
Element separatorEmpty()
Draw a vertical or horizontal separation in between two other elements, using the EMPTY style.
Element separatorVSelector(float up, float down, Color unselected_color, Color selected_color)
Draw an vertical bar, with the area in between up/downcolored differently.
std::shared_ptr< Node > Element
std::shared_ptr< T > Make(Args &&... args)
Element separatorLight()
Draw a vertical or horizontal separation in between two other elements, using the LIGHT style.
Element separatorHSelector(float left, float right, Color unselected_color, Color selected_color)
Draw an horizontal bar, with the area in between left/right colored differently.
Element separatorDashed()
Draw a vertical or horizontal separation in between two other elements, using the DASHED style.
Element separatorCharacter(std::string)
Draw a vertical or horizontal separation in between two other elements.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Element separatorDouble()
Draw a vertical or horizontal separation in between two other elements, using the DOUBLE style.
Element separatorHeavy()
Draw a vertical or horizontal separation in between two other elements, using the HEAVY style.
A Unicode character and its associated style.