catch_event.cpp
functional
utility
ftxui/component/component.hpp
ftxui/component/component_base.hpp
ftxui/component/event.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/catch_event.cpp
chrono
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui::CatchEventBase
ftxui

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

    #include"ftxui/component/component.hpp"//forMake,CatchEvent,ComponentDecorator
    #include"ftxui/component/component_base.hpp"//forComponent,ComponentBase
    #include"ftxui/component/event.hpp"//forEvent

    namespaceftxui{

    classCatchEventBase:publicComponentBase{
    public:
    //Constructor.
    explicitCatchEventBase(std::function<bool(Event)>on_event)
    :on_event_(std::move(on_event)){}

    //Componentimplementation.
    boolOnEvent(Eventevent)override{
    if(on_event_(event)){
    returntrue;
    }else{
    returnComponentBase::OnEvent(event);
    }
    }

    protected:
    std::function<bool(Event)>on_event_;
    };

    ///@briefReturnacomponent,using|on_event|tocatchevents.Thisfunction
    ///mustreturnstruewhentheeventhasbeenhandled,falseotherwise.
    ///@paramchildThewrappedcomponent.
    ///@paramon_eventThefunctiondrawingtheinterface.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autoscreen=ScreenInteractive::TerminalOutput();
    ///autorenderer=Renderer([]{
    ///returntext("Myinterface");
    ///});
    ///autocomponent=CatchEvent(renderer,[&](Eventevent){
    ///if(event==Event::Character('q')){
    ///screen.ExitLoopClosure()();
    ///returntrue;
    ///}
    ///returnfalse;
    ///});
    ///screen.Loop(component);
    ///```
    ComponentCatchEvent(Componentchild,
    std::function<bool(Eventevent)>on_event){
    autoout=Make<CatchEventBase>(std::move(on_event));
    out->Add(std::move(child));
    returnout;
    }

    ///@briefDecorateacomponent,using|on_event|tocatchevents.Thisfunction
    ///mustreturnstruewhentheeventhasbeenhandled,falseotherwise.
    ///@paramon_eventThefunctiondrawingtheinterface.
    ///@ingroupcomponent
    ///
    ///###Example
    ///
    ///```cpp
    ///autoscreen=ScreenInteractive::TerminalOutput();
    ///autorenderer=Renderer([]{returntext("Helloworld");});
    ///renderer|=CatchEvent([&](Eventevent){
    ///if(event==Event::Character('q')){
    ///screen.ExitLoopClosure()();
    ///returntrue;
    ///}
    ///returnfalse;
    ///});
    ///screen.Loop(renderer);
    ///```
    ComponentDecoratorCatchEvent(std::function<bool(Event)>on_event){
    return[on_event=std::move(on_event)](Componentchild){
    returnCatchEvent(std::move(child),[on_event=on_event](Eventevent){
    returnon_event(std::move(event));
    });
    };
    }

    }//namespaceftxui