examples/component/renderer.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<memory>//forshared_ptr,allocator,__shared_ptr_access

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forRenderer,Button,Vertical
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//foroperator|,Element,text,bold,border,center,color
    #include"ftxui/screen/color.hpp"//forColor,Color::Red

    intmain(){
    usingnamespaceftxui;
    autoscreen=ScreenInteractive::FitComponent();

    //ARenderer()isacomponentusingalambdafunctionasaparameterto
    //renderitself.

    //1.Exampleoffocusablerenderer:
    autorenderer_focusable=Renderer([](boolfocused){
    if(focused)
    returntext("FOCUSABLERENDERER()")|center|bold|border;
    else
    returntext("Focusablerenderer()")|center|border;
    });

    //2.Examplesofanonfocusablerenderer.
    autorenderer_non_focusable=Renderer([&]{
    returntext("~~~~~NonFocusablerenderer()~~~~~");//
    });

    //3.RenderercanwrapothercomponentstoredefinetheirRender()function.
    autobutton=Button("Wrappedquitbutton",screen.ExitLoopClosure());
    autorenderer_wrap=Renderer(button,[&]{
    if(button->Focused())
    returnbutton->Render()|bold|color(Color::Red);
    else
    returnbutton->Render();
    });

    //Let'srenderereveryone:
    screen.Loop(Container::Vertical({
    renderer_focusable,
    renderer_non_focusable,
    renderer_wrap,
    }));
    }