examples/dom/table.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<ftxui/dom/elements.hpp>//forcolor,Fit,LIGHT,align_right,bold,DOUBLE
    #include<ftxui/dom/table.hpp>//forTable,TableSelection
    #include<ftxui/screen/screen.hpp>//forScreen
    #include<iostream>//forendl,cout,ostream
    #include<string>//forbasic_string,allocator,string
    #include<vector>//forvector

    #include"ftxui/dom/node.hpp"//forRender
    #include"ftxui/screen/color.hpp"//forColor,Color::Blue,Color::Cyan,Color::White,ftxui

    intmain(){
    usingnamespaceftxui;

    autotable=Table({
    {"Version","Marketingname","Releasedate","APIlevel","Runtime"},
    {"2.3","Gingerbread","February92011","10","Dalvik1.4.0"},
    {"4.0","IceCreamSandwich","October192011","15","Dalvik"},
    {"4.1","JellyBean","July92012","16","Dalvik"},
    {"4.2","JellyBean","November132012","17","Dalvik"},
    {"4.3","JellyBean","July242013","18","Dalvik"},
    {"4.4","KitKat","October312013","19","DalvikandART"},
    {"5.0","Lollipop","November32014","21","ART"},
    {"5.1","Lollipop","March92015","22","ART"},
    {"6.0","Marshmallow","October52015","23","ART"},
    {"7.0","Nougat","August222016","24","ART"},
    {"7.1","Nougat","October42016","25","ART"},
    {"8.0","Oreo","August212017","26","ART"},
    {"8.1","Oreo","December52017","27","ART"},
    {"9","Pie","August62018","28","ART"},
    {"10","10","September32019","29","ART"},
    {"11","11","September82020","30","ART"},
    });

    table.SelectAll().Border(LIGHT);

    //Addborderaroundthefirstcolumn.
    table.SelectColumn(0).Border(LIGHT);

    //Makefirstrowboldwithadoubleborder.
    table.SelectRow(0).Decorate(bold);
    table.SelectRow(0).SeparatorVertical(LIGHT);
    table.SelectRow(0).Border(DOUBLE);

    //Alignrightthe"Releasedate"column.
    table.SelectColumn(2).DecorateCells(align_right);

    //Selectrowfromthesecondtothelast.
    autocontent=table.SelectRows(1,-1);
    //Alternateinbetween3colors.
    content.DecorateCellsAlternateRow(color(Color::Blue),3,0);
    content.DecorateCellsAlternateRow(color(Color::Cyan),3,1);
    content.DecorateCellsAlternateRow(color(Color::White),3,2);

    autodocument=table.Render();
    autoscreen=
    Screen::Create(Dimension::Fit(document,/*extend_beyond_screen=*/true));
    Render(screen,document);
    screen.Print();
    std::cout<<std::endl;

    return0;
    }