examples/component/menu_multiple.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<stdlib.h>//forEXIT_SUCCESS
    #include<memory>//forallocator,__shared_ptr_access
    #include<string>//forstring,operator+,basic_string,to_string,char_traits
    #include<vector>//forvector,__alloc_traits<>::value_type

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forMenu,Renderer,Horizontal,Vertical
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/screen_interactive.hpp"//forComponent,ScreenInteractive
    #include"ftxui/dom/elements.hpp"//fortext,Element,operator|,window,flex,vbox

    usingnamespaceftxui;

    ComponentWindow(std::stringtitle,Componentcomponent){
    returnRenderer(component,[component,title]{//
    returnwindow(text(title),component->Render())|flex;
    });
    }

    intmain(){
    intmenu_selected[]={0,0,0};
    std::vector<std::vector<std::string>>menu_entries={
    {
    "Ananas",
    "Raspberry",
    "Citrus",
    },
    {
    "Potatoes",
    "Weat",
    "Rise",
    },
    {
    "Carrot",
    "Lettuce",
    "Tomato",
    },
    };

    intmenu_selected_global=0;
    automenu_global=Container::Vertical(
    {
    Window("Menu1",Menu(&menu_entries[0],&menu_selected[0])),
    Window("Menu2",Menu(&menu_entries[1],&menu_selected[1])),
    Window("Menu3",Menu(&menu_entries[2],&menu_selected[2])),
    },
    &menu_selected_global);

    autoinfo=Renderer([&]{
    intg=menu_selected_global;
    std::stringvalue=menu_entries[g][menu_selected[g]];
    returnwindow(text("Content"),//
    vbox({
    text("menu_selected_global="+std::to_string(g)),
    text("menu_selected[0]="+
    std::to_string(menu_selected[0])),
    text("menu_selected[1]="+
    std::to_string(menu_selected[1])),
    text("menu_selected[2]="+
    std::to_string(menu_selected[2])),
    text("Value="+value),
    }))|
    flex;
    });

    autoglobal=Container::Horizontal({
    menu_global,
    info,
    });

    autoscreen=ScreenInteractive::TerminalOutput();
    screen.Loop(global);
    returnEXIT_SUCCESS;
    }