maybe.cpp
functional
memory
utility
ftxui/component/component.hpp
ftxui/component/component_base.hpp
ftxui/component/event.hpp
ftxui/dom/elements.hpp
ftxui/dom/node.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/maybe.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<memory>//formake_unique,__shared_ptr_access,__shared_ptr_access<>::element_type,shared_ptr
    #include<utility>//formove

    #include"ftxui/component/component.hpp"//forComponentDecorator,Maybe,Make
    #include"ftxui/component/component_base.hpp"//forComponent,ComponentBase
    #include"ftxui/component/event.hpp"//forEvent
    #include"ftxui/dom/elements.hpp"//forElement
    #include"ftxui/dom/node.hpp"//forNode

    namespaceftxui{

    ///@briefDecorateacomponent|child|.Itisshownonlywhen|show|returns
    ///true.
    ///@paramchildthecompoenenttodecorate.
    ///@paramshowafunctionreturningwhether|child|shouldshown.
    ///@ingroupcomponent
    ComponentMaybe(Componentchild,std::function<bool()>show){
    classImpl:publicComponentBase{
    public:
    explicitImpl(std::function<bool()>show):show_(std::move(show)){}

    private:
    ElementOnRender()override{
    returnshow_()?ComponentBase::OnRender():std::make_unique<Node>();
    }
    boolFocusable()constoverride{
    returnshow_()&&ComponentBase::Focusable();
    }
    boolOnEvent(Eventevent)override{
    returnshow_()&&ComponentBase::OnEvent(event);
    }

    std::function<bool()>show_;
    };

    automaybe=Make<Impl>(std::move(show));
    maybe->Add(std::move(child));
    returnmaybe;
    }

    ///@briefDecorateacomponent.Itisshownonlywhenthe|show|function
    ///returnstrue.
    ///@paramshowafunctionreturningwhetherthedecoratedcomponentshould
    ///beshown.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autocomponent=Renderer([]{returntext("HelloWorld!");});
    ///automaybe_component=component|Maybe([&]{returncounter==42;});
    ///```
    ComponentDecoratorMaybe(std::function<bool()>show){
    return[show=std::move(show)](Componentchild)mutable{
    returnMaybe(std::move(child),std::move(show));
    };
    }

    ///@briefDecorateacomponent|child|.Itisshownonlywhen|show|istrue.
    ///@paramchildthecompoennttodecorate.
    ///@paramshowaboolean.|child|isshownwhen|show|istrue.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autocomponent=Renderer([]{returntext("HelloWorld!");});
    ///automaybe_component=Maybe(component,&show);
    ///```
    ComponentMaybe(Componentchild,constbool*show){
    returnMaybe(std::move(child),[show]{return*show;});
    }

    ///@briefDecorateacomponent.Itisshownonlywhen|show|istrue.
    ///@paramshowaboolean.|child|isshownwhen|show|istrue.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autocomponent=Renderer([]{returntext("HelloWorld!");});
    ///automaybe_component=component|Maybe(&show);
    ///```
    ComponentDecoratorMaybe(constbool*show){
    return[show](Componentchild){returnMaybe(std::move(child),show);};
    }

    }//namespaceftxui