examples/component/menu_entries.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<functional>//forfunction
    #include<iostream>//forbasic_ostream::operator<<,operator<<,endl,basic_ostream,basic_ostream<>::__ostream_type,cout,ostream
    #include<memory>//forallocator,shared_ptr,__shared_ptr_access
    #include<string>//forchar_traits,to_string,operator+,string,basic_string

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forMenuEntry,Renderer,Vertical
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/component_options.hpp"//forMenuEntryOption
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//foroperator|,Element,separator,text,hbox,size,frame,color,vbox,HEIGHT,LESS_THAN,bold,border,inverted
    #include"ftxui/screen/color.hpp"//forColor,Color::Blue,Color::Cyan,Color::Green,Color::Red,Color::Yellow

    usingnamespaceftxui;

    //Defineaspecialstyleforsomemenuentry.
    MenuEntryOptionColored(ftxui::Colorc){
    MenuEntryOptionoption;
    option.transform=[c](EntryStatestate){
    state.label=(state.active?">":"")+state.label;
    Elemente=text(state.label)|color(c);
    if(state.focused)
    e=e|inverted;
    if(state.active)
    e=e|bold;
    returne;
    };
    returnoption;
    }

    intmain(){
    autoscreen=ScreenInteractive::TerminalOutput();

    intselected=0;
    automenu=Container::Vertical(
    {
    MenuEntry("1.improve"),
    MenuEntry("2.tolerant"),
    MenuEntry("3.career"),
    MenuEntry("4.cast"),
    MenuEntry("5.question"),

    Renderer([]{returnseparator();}),

    MenuEntry("6.rear",Colored(Color::Red)),
    MenuEntry("7.drown",Colored(Color::Yellow)),
    MenuEntry("8.nail",Colored(Color::Green)),
    MenuEntry("9.quit",Colored(Color::Cyan)),
    MenuEntry("10.decorative",Colored(Color::Blue)),

    Renderer([]{returnseparator();}),

    MenuEntry("11.costume"),
    MenuEntry("12.pick"),
    MenuEntry("13.oral"),
    MenuEntry("14.minister"),
    MenuEntry("15.football"),
    MenuEntry("16.welcome"),
    MenuEntry("17.copper"),
    MenuEntry("18.inhabitant"),
    MenuEntry("19.fortune"),
    },
    &selected);

    //Displaytogetherthemenuwithaborder
    autorenderer=Renderer(menu,[&]{
    returnvbox({
    hbox(text("selected="),text(std::to_string(selected))),
    separator(),
    menu->Render()|frame|size(HEIGHT,LESS_THAN,10),
    })|
    border;
    });

    screen.Loop(renderer);

    std::cout<<"Selectedelement="<<selected<<std::endl;
    }