examples/dom/gauge.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<chrono>//foroperator""s,chrono_literals
    #include<ftxui/dom/elements.hpp>//fortext,gauge,operator|,flex,hbox,Element
    #include<ftxui/screen/screen.hpp>//forScreen
    #include<iostream>//forcout,endl,ostream
    #include<string>//forallocator,char_traits,operator+,operator<<,string,to_string,basic_string
    #include<thread>//forsleep_for

    #include"ftxui/dom/node.hpp"//forRender
    #include"ftxui/screen/color.hpp"//forftxui

    intmain(){
    usingnamespaceftxui;
    usingnamespacestd::chrono_literals;

    std::stringreset_position;
    for(floatpercentage=0.0f;percentage<=1.0f;percentage+=0.002f){
    std::stringdata_downloaded=
    std::to_string(int(percentage*5000))+"/5000";
    autodocument=hbox({
    text("downloading:"),
    gauge(percentage)|flex,
    text(""+data_downloaded),
    });
    autoscreen=Screen(100,1);
    Render(screen,document);
    std::cout<<reset_position;
    screen.Print();
    reset_position=screen.ResetPosition();

    std::this_thread::sleep_for(0.01s);
    }
    std::cout<<std::endl;
    }