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)
Color 是一個在終端使用者介面中表示顏色的類別。
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)
重設元素的選取樣式。
void Render(Screen &screen, const Element &element)
std::function< void(Pixel &)> style_