examples/component/input_style.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<ftxui/dom/linear_gradient.hpp>//forLinearGradient
    #include<ftxui/screen/color.hpp>//forColor,Color::White,Color::Red,Color::Blue,Color::Black,Color::GrayDark,ftxui
    #include<functional>//forfunction
    #include<string>//forallocator,string
    #include<utility>//formove

    #include"ftxui/component/component.hpp"//forInput,Horizontal,Vertical,operator|
    #include"ftxui/component/component_base.hpp"//forComponent
    #include"ftxui/component/component_options.hpp"//forInputState,InputOption
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//foroperator|=,Element,bgcolor,operator|,separatorEmpty,color,borderEmpty,separator,text,center,dim,hbox,vbox,border,borderDouble,borderRounded

    intmain(){
    usingnamespaceftxui;

    InputOptionstyle_1=InputOption::Default();

    InputOptionstyle_2=InputOption::Spacious();

    InputOptionstyle_3=InputOption::Spacious();
    style_3.transform=[](InputStatestate){
    state.element|=borderEmpty;

    if(state.is_placeholder){
    state.element|=dim;
    }

    if(state.focused){
    state.element|=borderDouble;
    state.element|=bgcolor(Color::White);
    state.element|=color(Color::Black);
    }elseif(state.hovered){
    state.element|=borderRounded;
    state.element|=bgcolor(LinearGradient(90,Color::Blue,Color::Red));
    state.element|=color(Color::White);
    }else{
    state.element|=border;
    state.element|=bgcolor(LinearGradient(0,Color::Blue,Color::Red));
    state.element|=color(Color::White);
    }

    returnstate.element;
    };

    InputOptionstyle_4=InputOption::Spacious();
    style_4.transform=[](InputStatestate){
    state.element=hbox({
    text("Theorem")|center|borderEmpty|bgcolor(Color::Red),
    separatorEmpty(),
    separator()|color(Color::White),
    separatorEmpty(),
    std::move(state.element),
    });

    state.element|=borderEmpty;
    if(state.is_placeholder){
    state.element|=dim;
    }

    if(state.focused){
    state.element|=bgcolor(Color::Black);
    }else{
    state.element|=bgcolor(Color::Blue);
    }

    if(state.hovered){
    state.element|=bgcolor(Color::GrayDark);
    }

    returnvbox({state.element,separatorEmpty()});
    };

    autogenerateUiFromStyle=[&](InputOptionstyle){
    autofirst_name=newstd::string();//Leaked
    automiddle_name=newstd::string();//Leaked
    autolast_name=newstd::string();//Leaked
    returnContainer::Vertical({
    Input(first_name,"firstname",style),
    Input(middle_name,"middlename",style),
    Input(last_name,"lastname",style),
    })|
    borderEmpty;
    };

    autoui=Container::Horizontal({
    generateUiFromStyle(style_1),
    generateUiFromStyle(style_2),
    generateUiFromStyle(style_3),
    generateUiFromStyle(style_4),
    });

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