18class SelectionStyleReset :
public NodeDecorator {
20 explicit SelectionStyleReset(
Element child)
21 : NodeDecorator(std::move(child)) {}
23 void Render(Screen& screen)
final {
24 auto old_style = screen.GetSelectionStyle();
25 screen.SetSelectionStyle([](Pixel&) {});
27 screen.SetSelectionStyle(old_style);
31class SelectionStyle :
public NodeDecorator {
33 SelectionStyle(
Element child,
const std::function<
void(Pixel&)>& style)
34 : NodeDecorator(std::move(child)),
style_(style) {}
36 void Render(Screen& screen)
final {
37 auto old_style = screen.GetSelectionStyle();
38 auto new_style = [&, old_style](Pixel& pixel) {
42 screen.SetSelectionStyle(new_style);
44 screen.SetSelectionStyle(old_style);
56 return std::make_shared<SelectionStyleReset>(std::move(child));
88 return std::make_shared<SelectionStyle>(std::move(child), style);
friend void Render(Screen &screen, Node *node, Selection &selection)
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Color is a class that represents a color in the terminal user interface.
A Unicode character and its associated style.
The FTXUI ftxui:: namespace.
std::function< Element(Element)> Decorator
std::shared_ptr< Node > Element
Decorator selectionStyle(std::function< void(Pixel &)> style)
Set the style of an element when selected.
Decorator selectionForegroundColor(Color foreground)
Set the foreground color of an element when selected. Note that the style is applied on top of the ex...
Decorator selectionBackgroundColor(Color foreground)
Set the background color of an element when selected. Note that the style is applied on top of the ex...
Decorator selectionColor(Color foreground)
Set the color of an element when selected.
Element selectionStyleReset(Element)
Reset the selection style of an element.
std::function< void(Pixel &)> style_