examples/component/collapsible.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<memory>//forallocator,make_shared,__shared_ptr_access
    #include<utility>//formove
    #include<vector>//forvector

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forCollapsible,Renderer,Vertical
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/screen_interactive.hpp"//forComponent,ScreenInteractive
    #include"ftxui/dom/elements.hpp"//fortext,hbox,Element

    usingnamespaceftxui;

    //Takealistofcomponent,displaythemvertically,onecolumnshiftedtothe
    //right.
    ComponentInner(std::vector<Component>children){
    Componentvlist=Container::Vertical(std::move(children));
    returnRenderer(vlist,[vlist]{
    returnhbox({
    text(""),
    vlist->Render(),
    });
    });
    }

    ComponentEmpty(){
    returnstd::make_shared<ComponentBase>();
    }

    intmain(){
    autocomponent=
    Collapsible("Collapsible1",
    Inner({
    Collapsible("Collapsible1.1",
    Inner({
    Collapsible("Collapsible1.1.1",Empty()),
    Collapsible("Collapsible1.1.2",Empty()),
    Collapsible("Collapsible1.1.3",Empty()),
    })),
    Collapsible("Collapsible1.2",
    Inner({
    Collapsible("Collapsible1.2.1",Empty()),
    Collapsible("Collapsible1.2.2",Empty()),
    Collapsible("Collapsible1.2.3",Empty()),
    })),
    Collapsible("Collapsible1.3",
    Inner({
    Collapsible("Collapsible1.3.1",Empty()),
    Collapsible("Collapsible1.3.2",Empty()),
    Collapsible("Collapsible1.3.3",Empty()),
    })),
    }));

    ScreenInteractive::FitComponent().Loop(component);
    }