component_fuzzer.cpp
cassert
vector
ftxui/component/component.hpp
ftxui/component/terminal_input_parser.hpp
ftxui/component/animation.hpp
ftxui/component/captured_mouse.hpp
ftxui/component/component.hpp
ftxui/component/component_base.hpp
ftxui/component/component_options.hpp
ftxui/component/event.hpp
ftxui/component/mouse.hpp
ftxui/component/receiver.hpp
ftxui/component/task.hpp
ftxui/dom/canvas.hpp
ftxui/dom/deprecated.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/dom/flexbox_config.hpp
ftxui/dom/linear_gradient.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/image.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/screen/string.hpp
ftxui/screen/terminal.hpp
ftxui/util/autoreset.hpp
ftxui/util/ref.hpp
src/ftxui/component/component_fuzzer.cpp
ftxui/component/terminal_input_parser.hpp
algorithm
atomic
cassert
chrono
condition_variable
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
mutex
optional
queue
sstream
string
unordered_map
utility
variant
vector
int int LLVMFuzzerTestOneInput (const char *data, size_t size) LLVMFuzzerTestOneInput const char * data size_t size

    //Copyright2021ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<cassert>
    #include<vector>
    #include"ftxui/component/component.hpp"
    #include"ftxui/component/terminal_input_parser.hpp"

    usingnamespaceftxui;
    namespace{

    boolGeneratorBool(constchar*&data,size_t&size){
    if(size==0){
    returnfalse;
    }

    autoout=bool(data[0]%2);
    data++;
    size--;
    returnout;
    }

    std::stringGeneratorString(constchar*&data,size_t&size){
    intindex=0;
    while(index<size&&data[index])
    ++index;

    autoout=std::string(data,data+index);
    data+=index;
    size-=index;

    //TheinputcomponentdonotsupportinvalidUTF8yet.
    try{
    to_wstring(out);
    }catch(...){
    return"0";
    }
    returnstd::move(out);
    }

    intGeneratorInt(constchar*data,size_tsize){
    if(size==0)
    return0;
    autoout=int(data[0]);
    data++;
    size--;
    returnout;
    }

    ColorGeneratorColor(constchar*data,size_tsize){
    returnColor::RGB(GeneratorInt(data,size),GeneratorInt(data,size),
    GeneratorInt(data,size));
    }

    AnimatedColorOptionGeneratorAnimatedColorOption(constchar*data,
    size_tsize){
    AnimatedColorOptionoption;
    option.enabled=GeneratorBool(data,size);
    option.inactive=GeneratorColor(data,size);
    option.active=GeneratorColor(data,size);
    option.duration=std::chrono::milliseconds(GeneratorInt(data,size));
    returnoption;
    }

    AnimatedColorsOptionGeneratorAnimatedColorsOptions(constchar*data,
    size_tsize){
    AnimatedColorsOptionoption;
    option.background=GeneratorAnimatedColorOption(data,size);
    option.foreground=GeneratorAnimatedColorOption(data,size);
    returnoption;
    }

    ButtonOptionGeneratorButtonOption(constchar*data,size_tsize){
    ButtonOptionoption;
    option.animated_colors=GeneratorAnimatedColorsOptions(data,size);
    returnoption;
    }

    UnderlineOptionGeneratorUnderlineOption(constchar*data,size_tsize){
    UnderlineOptionoption;
    option.enabled=GeneratorBool(data,size);
    option.color_active=GeneratorColor(data,size);
    option.color_inactive=GeneratorColor(data,size);
    option.leader_duration=std::chrono::milliseconds(GeneratorInt(data,size));
    option.follower_duration=
    std::chrono::milliseconds(GeneratorInt(data,size));
    option.leader_delay=std::chrono::milliseconds(GeneratorInt(data,size));
    option.follower_delay=std::chrono::milliseconds(GeneratorInt(data,size));
    returnoption;
    }

    MenuEntryOptionGeneratorMenuEntryOption(constchar*data,size_tsize){
    MenuEntryOptionoption;
    option.animated_colors=GeneratorAnimatedColorsOptions(data,size);
    returnoption;
    }

    MenuOptionGeneratorMenuOption(constchar*data,size_tsize){
    MenuOptionoption;
    option.underline=GeneratorUnderlineOption(data,size);
    option.entries_option=GeneratorMenuEntryOption(data,size);
    option.direction=static_cast<Direction>(GeneratorInt(data,size)%4);
    returnoption;
    }

    boolg_bool;
    intg_int;
    std::vector<std::string>g_list;

    ComponentsGeneratorComponents(constchar*&data,size_t&size,intdepth);

    ComponentGeneratorComponent(constchar*&data,size_t&size,intdepth){
    depth--;
    intvalue=GeneratorInt(data,size);
    if(depth<=0)
    returnButton(GeneratorString(data,size),[]{});

    constexprintvalue_max=19;
    value=(value%value_max+value_max)%value_max;
    switch(value){
    case0:
    returnButton(
    GeneratorString(data,size),[]{},
    GeneratorButtonOption(data,size));
    case1:
    returnCheckbox(GeneratorString(data,size),&g_bool);
    case2:
    returnInput(GeneratorString(data,size),GeneratorString(data,size));
    case3:
    returnMenu(&g_list,&g_int,GeneratorMenuOption(data,size));
    case4:
    returnRadiobox(&g_list,&g_int);
    case5:
    returnToggle(&g_list,&g_int);
    case6:
    returnSlider(GeneratorString(data,size),&g_int,
    GeneratorInt(data,size),GeneratorInt(data,size),
    GeneratorInt(data,size));
    case7:
    returnResizableSplitLeft(GeneratorComponent(data,size,depth-1),
    GeneratorComponent(data,size,depth-1),
    &g_int);
    case8:
    returnResizableSplitRight(GeneratorComponent(data,size,depth-1),
    GeneratorComponent(data,size,depth-1),
    &g_int);
    case9:
    returnResizableSplitTop(GeneratorComponent(data,size,depth-1),
    GeneratorComponent(data,size,depth-1),
    &g_int);
    case10:
    returnResizableSplitBottom(GeneratorComponent(data,size,depth-1),
    GeneratorComponent(data,size,depth-1),
    &g_int);
    case11:
    returnContainer::Vertical(GeneratorComponents(data,size,depth-1));

    case12:
    returnContainer::Vertical(GeneratorComponents(data,size,depth-1),
    &g_int);

    case13:
    returnContainer::Horizontal(GeneratorComponents(data,size,depth-1));
    case14:
    returnContainer::Horizontal(GeneratorComponents(data,size,depth-1),
    &g_int);
    case15:
    returnContainer::Tab(GeneratorComponents(data,size,depth-1),&g_int);
    case16:
    returnMaybe(GeneratorComponent(data,size,depth-1),&g_bool);
    case17:
    returnDropdown(&g_list,&g_int);
    case18:
    returnCollapsible(GeneratorString(data,size),
    GeneratorComponent(data,size,depth-1),
    GeneratorBool(data,size));
    default:
    assert(false);
    }
    }

    ComponentsGeneratorComponents(constchar*&data,size_t&size,intdepth){
    Componentsout;
    if(depth>0){
    while(size&&GeneratorInt(data,size)%2){
    out.push_back(GeneratorComponent(data,size,depth-1));
    }
    }
    returnstd::move(out);
    }

    }//namespace
    extern"C"intLLVMFuzzerTestOneInput(constchar*data,size_tsize){
    g_bool=GeneratorBool(data,size);
    g_int=GeneratorInt(data,size);
    g_list={
    "test_1","test_2","test_3","test_4","test_5",
    };

    intdepth=10;
    autocomponent=GeneratorComponent(data,size,depth);

    intwidth=GeneratorInt(data,size);
    intheight=GeneratorInt(data,size);

    width%=500;
    width+=500;

    height%=500;
    height+=500;

    autoscreen=
    Screen::Create(Dimension::Fixed(width),Dimension::Fixed(height));

    autoevent_receiver=MakeReceiver<Task>();
    {
    autoparser=TerminalInputParser(event_receiver->MakeSender());
    for(size_ti=0;i<size;++i)
    parser.Add(data[i]);
    }

    Taskevent;
    while(event_receiver->Receive(&event)){
    component->OnEvent(std::get<Event>(event));
    autodocument=component->Render();
    Render(screen,document);
    }
    return0;//Non-zeroreturnvaluesarereservedforfutureuse.
    }