renderer.cpp
functional
utility
ftxui/component/component.hpp
ftxui/component/component_base.hpp
ftxui/component/event.hpp
ftxui/component/mouse.hpp
ftxui/dom/elements.hpp
ftxui/screen/box.hpp
ftxui/component/animation.hpp
ftxui/component/captured_mouse.hpp
ftxui/component/component.hpp
ftxui/component/component_base.hpp
ftxui/component/component_options.hpp
ftxui/component/event.hpp
ftxui/component/mouse.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
src/ftxui/component/renderer.cpp
chrono
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2021ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<functional>//forfunction
    #include<utility>//formove

    #include"ftxui/component/component.hpp"//forMake,Renderer
    #include"ftxui/component/component_base.hpp"//forComponent,ComponentBase
    #include"ftxui/component/event.hpp"//forEvent
    #include"ftxui/component/mouse.hpp"//forMouse
    #include"ftxui/dom/elements.hpp"//forElement,operator|,reflect
    #include"ftxui/screen/box.hpp"//forBox

    namespaceftxui{

    ///@briefReturnacomponent,using|render|torenderitsinterface.
    ///@paramrenderThefunctiondrawingtheinterface.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autoscreen=ScreenInteractive::TerminalOutput();
    ///autorenderer=Renderer([]{
    ///returntext("Myinterface");
    ///});
    ///screen.Loop(renderer);
    ///```
    ComponentRenderer(std::function<Element()>render){
    classImpl:publicComponentBase{
    public:
    explicitImpl(std::function<Element()>render)
    :render_(std::move(render)){}
    ElementOnRender()override{returnrender_();}
    std::function<Element()>render_;
    };

    returnMake<Impl>(std::move(render));
    }

    ///@briefReturnanewComponent,similarto|child|,butusing|render|asthe
    ///Component::Render()event.
    ///@paramchildThecomponenttoforwardeventsto.
    ///@paramrenderThefunctiondrawingtheinterface.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autoscreen=ScreenInteractive::TerminalOutput();
    ///std::stringlabel="Clicktoquit";
    ///autobutton=Button(&label,screen.ExitLoopClosure());
    ///autorenderer=Renderer(button,[&]{
    ///returnhbox({
    ///text("Abutton:"),
    ///button->Render(),
    ///});
    ///});
    ///screen.Loop(renderer);
    ///```
    ComponentRenderer(Componentchild,std::function<Element()>render){
    Componentrenderer=Renderer(std::move(render));
    renderer->Add(std::move(child));
    returnrenderer;
    }

    ///@briefReturnafocusablecomponent,using|render|torenderitsinterface.
    ///@paramrenderThefunctiondrawingtheinterface,takingabooleantelling
    ///whetherthecomponentisfocusedornot.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autoscreen=ScreenInteractive::TerminalOutput();
    ///autorenderer=Renderer([](boolfocused){
    ///if(focused)
    ///returntext("Myinterface")|inverted;
    ///else
    ///returntext("Myinterface");
    ///});
    ///screen.Loop(renderer);
    ///```
    ComponentRenderer(std::function<Element(bool)>render){
    classImpl:publicComponentBase{
    public:
    explicitImpl(std::function<Element(bool)>render)
    :render_(std::move(render)){}

    private:
    ElementOnRender()override{returnrender_(Focused())|reflect(box_);}
    boolFocusable()constoverride{returntrue;}
    boolOnEvent(Eventevent)override{
    if(event.is_mouse()&&box_.Contain(event.mouse().x,event.mouse().y)){
    if(!CaptureMouse(event)){
    returnfalse;
    }

    TakeFocus();
    }

    returnfalse;
    }
    Boxbox_;

    std::function<Element(bool)>render_;
    };
    returnMake<Impl>(std::move(render));
    }

    ///@briefDecorateacomponent,bydecoratingwhatitrenders.
    ///@paramdecoratorthefunctionmodifyingtheelementitrenders.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autoscreen=ScreenInteractive::TerminalOutput();
    ///autorenderer=
    //Renderer([]{returntext("Hello");)
    ///|Renderer(bold)
    ///|Renderer(inverted);
    ///screen.Loop(renderer);
    ///```
    ComponentDecoratorRenderer(ElementDecoratordecorator){//NOLINT
    return[decorator](Componentcomponent){//NOLINT
    returnRenderer(component,[component,decorator]{
    returncomponent->Render()|decorator;
    });
    };
    }

    }//namespaceftxui