10bool GeneratorBool(
const char*& data,
size_t&
size) {
14 auto out = bool(data[0] % 2);
20std::string GeneratorString(
const char*& data,
size_t&
size) {
22 while (index <
size && data[index])
25 auto out = std::string(data, data + index);
35 return std::move(out);
38int GeneratorInt(
const char* data,
size_t size) {
41 auto out = int(data[0]);
47Color GeneratorColor(
const char* data,
size_t size) {
49 GeneratorInt(data,
size));
58 option.
duration = std::chrono::milliseconds(GeneratorInt(data,
size));
83 std::chrono::milliseconds(GeneratorInt(data,
size));
98 option.
entries = GeneratorMenuEntryOption(data,
size);
106std::vector<std::string> g_list;
108Components GeneratorComponents(
const char*& data,
size_t&
size,
int depth);
110Component GeneratorComponent(
const char*& data,
size_t&
size,
int depth) {
112 int value = GeneratorInt(data,
size);
114 return Button(GeneratorString(data,
size), [] {});
116 constexpr int value_max = 19;
117 value = (value % value_max + value_max) % value_max;
121 GeneratorString(data,
size), [] {},
122 GeneratorButtonOption(data,
size));
126 return Input(GeneratorString(data,
size), GeneratorString(data,
size));
128 return Menu(&g_list, &g_int, GeneratorMenuOption(data,
size));
132 return Toggle(&g_list, &g_int);
134 return Slider(GeneratorString(data,
size), &g_int,
135 GeneratorInt(data,
size), GeneratorInt(data,
size),
136 GeneratorInt(data,
size));
139 GeneratorComponent(data,
size, depth - 1),
143 GeneratorComponent(data,
size, depth - 1),
147 GeneratorComponent(data,
size, depth - 1),
151 GeneratorComponent(data,
size, depth - 1),
168 return Maybe(GeneratorComponent(data,
size, depth - 1), &g_bool);
173 GeneratorComponent(data,
size, depth - 1),
174 GeneratorBool(data,
size));
180Components GeneratorComponents(
const char*& data,
size_t&
size,
int depth) {
183 while (
size && GeneratorInt(data,
size) % 2) {
184 out.push_back(GeneratorComponent(data,
size, depth - 1));
187 return std::move(out);
192 g_bool = GeneratorBool(data,
size);
193 g_int = GeneratorInt(data,
size);
195 "test_1",
"test_2",
"test_3",
"test_4",
"test_5",
199 auto component = GeneratorComponent(data,
size, depth);
201 int width = GeneratorInt(data,
size);
202 int height = GeneratorInt(data,
size);
216 for (
size_t i = 0; i <
size; ++i)
221 while (event_receiver->Receive(&event)) {
222 component->OnEvent(std::get<Event>(event));
223 auto document = component->Render();
A class representing terminal colors.
static Color RGB(uint8_t red, uint8_t green, uint8_t blue)
Build a Color from its RGB representation. https://en.wikipedia.org/wiki/RGB_color_model.
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
int LLVMFuzzerTestOneInput(const char *data, size_t size)
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Component Tab(Components children, int *selector)
A list of components, where only one is drawn and interacted with at a time. The |selector| gives the...
Component Checkbox(ConstStringRef label, bool *checked, Ref< CheckboxOption > option=CheckboxOption::Simple())
Draw checkable element.
Component Radiobox(ConstStringListRef entries, int *selected_, Ref< RadioboxOption > option={})
A list of element, where only one can be selected.
AnimatedColorOption foreground
Component Maybe(Component, const bool *show)
Decorate a component |child|. It is shown only when |show| is true. @params child the compoennt to de...
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component Input(StringRef content, ConstStringRef placeholder, Ref< InputOption > option={})
An input box for editing text.
Component Toggle(ConstStringListRef entries, int *selected)
An horizontal list of elements. The user can navigate through them.
std::vector< Component > Components
AnimatedColorOption background
std::wstring to_wstring(const std::string &s)
Convert a std::wstring into a UTF8 std::string.
Receiver< T > MakeReceiver()
Component Button(ConstStringRef label, std::function< void()> on_click, Ref< ButtonOption >=ButtonOption::Simple())
Draw a button. Execute a function when clicked.
Component Menu(ConstStringListRef entries, int *selected_, Ref< MenuOption >=MenuOption::Vertical())
A list of text. The focused element is selected.
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Component Dropdown(ConstStringListRef entries, int *selected)
std::variant< Event, Closure, AnimationTask > Task
AnimatedColorsOption animated_colors
Component ResizableSplitBottom(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component Slider(ConstStringRef label, T *value, T min, T max, T increment)
An horizontal slider.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Decorator size(Direction, Constraint, int value)
Apply a constraint on the size of an element.
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
std::shared_ptr< ComponentBase > Component
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show=false)
Option about a potentially animated color.
animation::Duration duration
animation::Duration follower_duration
animation::Duration follower_delay
animation::Duration leader_duration
animation::Duration leader_delay