selection_style.cpp
functional
memory
utility
ftxui/dom/elements.hpp
ftxui/dom/node_decorator.hpp
ftxui/screen/color.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/dom/canvas.hpp
ftxui/dom/deprecated.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/dom/flexbox_config.hpp
ftxui/dom/linear_gradient.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/image.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/screen/string.hpp
ftxui/screen/terminal.hpp
ftxui/util/autoreset.hpp
ftxui/util/ref.hpp
ftxui/dom/node_decorator.hpp
src/ftxui/dom/selection_style.cpp
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2024ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<functional>//forfunction
    #include<memory>//formake_shared
    #include<utility>//formove

    #include"ftxui/dom/elements.hpp"//forElement,Decorator,bgcolor,color
    #include"ftxui/dom/node_decorator.hpp"//forNodeDecorator
    #include"ftxui/screen/color.hpp"//forColor
    #include"ftxui/screen/pixel.hpp"//forPixel
    #include"ftxui/screen/screen.hpp"//forScreen

    namespaceftxui{

    namespace{

    classSelectionStyleReset:publicNodeDecorator{
    public:
    explicitSelectionStyleReset(Elementchild)
    :NodeDecorator(std::move(child)){}

    voidRender(Screen&screen)final{
    autoold_style=screen.GetSelectionStyle();
    screen.SetSelectionStyle([](Pixel&){});
    NodeDecorator::Render(screen);
    screen.SetSelectionStyle(old_style);
    }
    };

    classSelectionStyle:publicNodeDecorator{
    public:
    SelectionStyle(Elementchild,conststd::function<void(Pixel&)>&style)
    :NodeDecorator(std::move(child)),style_(style){}

    voidRender(Screen&screen)final{
    autoold_style=screen.GetSelectionStyle();
    autonew_style=[&,old_style](Pixel&pixel){
    old_style(pixel);
    style_(pixel);
    };
    screen.SetSelectionStyle(new_style);
    NodeDecorator::Render(screen);
    screen.SetSelectionStyle(old_style);
    }

    std::function<void(Pixel&)>style_;
    };

    }//namespace

    ///@briefResettheselectionstyleofanelement.
    ///@paramchildTheinputelement.
    ///@returnTheoutputelementwiththeselectionstylereset.
    ElementselectionStyleReset(Elementchild){
    returnstd::make_shared<SelectionStyleReset>(std::move(child));
    }

    ///@briefSetthebackgroundcolorofanelementwhenselected.
    ///Notethatthestyleisappliedontopoftheexistingstyle.
    DecoratorselectionBackgroundColor(Colorforeground){
    returnselectionStyle([foreground](Pixel&pixel){//
    pixel.background_color=foreground;
    });
    }

    ///@briefSettheforegroundcolorofanelementwhenselected.
    ///Notethatthestyleisappliedontopoftheexistingstyle.
    DecoratorselectionForegroundColor(Colorforeground){
    returnselectionStyle([foreground](Pixel&pixel){//
    pixel.foreground_color=foreground;
    });
    }

    ///@briefSetthecolorofanelementwhenselected.
    ///@paramforegroundThecolortobeapplied.
    ///Notethatthestyleisappliedontopoftheexistingstyle.
    DecoratorselectionColor(Colorforeground){
    returnselectionForegroundColor(foreground);
    }

    ///@briefSetthestyleofanelementwhenselected.
    ///@paramstyleThestyletobeapplied.
    ///Notethatthestyleisappliedontopoftheexistingstyle.
    //NOLINTNEXTLINE
    DecoratorselectionStyle(std::function<void(Pixel&)>style){
    return[style](Elementchild)->Element{
    returnstd::make_shared<SelectionStyle>(std::move(child),style);
    };
    }

    }//namespaceftxui