17class SelectionStyleReset :
public NodeDecorator {
19 explicit SelectionStyleReset(
Element child)
20 : NodeDecorator(std::move(child)) {}
22 void Render(Screen& screen)
final {
23 auto old_style = screen.GetSelectionStyle();
24 screen.SetSelectionStyle([](Pixel&) {});
26 screen.SetSelectionStyle(old_style);
30class SelectionStyle :
public NodeDecorator {
32 SelectionStyle(
Element child,
const std::function<
void(Pixel&)>& style)
33 : NodeDecorator(std::move(child)),
style_(style) {}
35 void Render(Screen& screen)
final {
36 auto old_style = screen.GetSelectionStyle();
37 auto new_style = [&, old_style](Pixel& pixel) {
41 screen.SetSelectionStyle(new_style);
43 screen.SetSelectionStyle(old_style);
55 return std::make_shared<SelectionStyleReset>(std::move(child));
87 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)
在 ftxui::Screen 上显示元素。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::function< Element(Element)> Decorator
std::shared_ptr< Node > Element
Decorator selectionStyle(std::function< void(Pixel &)> style)
设置元素选中时的样式。
Decorator selectionForegroundColor(Color foreground)
设置元素选中时的前景色。 请注意,此样式是在现有样式之上应用的。
Decorator selectionBackgroundColor(Color foreground)
设置元素选中时的背景颜色。 请注意,此样式是在现有样式之上应用的。
Decorator selectionColor(Color foreground)
设置元素选中时的颜色。
Element selectionStyleReset(Element)
重置元素的选中样式。
std::function< void(Pixel &)> style_