16 class BgColor :
public NodeDecorator {
19 : NodeDecorator(std::move(child)), color_(
color) {}
21 void Render(Screen& screen)
override {
22 for (
int y = box_.y_min; y <= box_.y_max; ++y) {
23 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
24 screen.PixelAt(x, y).background_color = color_;
33 class FgColor :
public NodeDecorator {
36 : NodeDecorator(std::move(child)), color_(
color) {}
38 void Render(Screen& screen)
override {
39 for (
int y = box_.y_min; y <= box_.y_max; ++y) {
40 for (
int x = box_.x_min; x <= box_.x_max; ++x) {
41 screen.PixelAt(x, y).foreground_color = color_;
63 return std::make_shared<FgColor>(std::move(child),
color);
78 return std::make_shared<BgColor>(std::move(child),
color);
92 return [c](
Element child) {
return color(c, std::move(child)); };
A class representing terminal colors.
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Decorator bgcolor(Color)
Decorate using a background color.
std::function< Element(Element)> Decorator
std::shared_ptr< Node > Element
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Decorator color(Color)
Decorate using a foreground color.