13bool GeneratorBool(
const char*& data,
size_t&
size) {
17 auto out = bool(data[0] % 2);
23std::string GeneratorString(
const char*& data,
size_t&
size) {
25 while (index <
size && data[index])
28 auto out = std::string(data, data + index);
38 return std::move(out);
41int GeneratorInt(
const char* data,
size_t size) {
44 auto out = int(data[0]);
50Color GeneratorColor(
const char* data,
size_t size) {
51 return Color::RGB(GeneratorInt(data,
size), GeneratorInt(data,
size),
52 GeneratorInt(data,
size));
61 option.
duration = std::chrono::milliseconds(GeneratorInt(data,
size));
86 std::chrono::milliseconds(GeneratorInt(data,
size));
108std::vector<std::string> g_list;
110Components GeneratorComponents(
const char*& data,
size_t&
size,
int depth);
112Component GeneratorComponent(
const char*& data,
size_t&
size,
int depth) {
114 int value = GeneratorInt(data,
size);
116 return Button(GeneratorString(data,
size), [] {});
118 constexpr int value_max = 19;
119 value = (value % value_max + value_max) % value_max;
123 GeneratorString(data,
size), [] {},
124 GeneratorButtonOption(data,
size));
128 return Input(GeneratorString(data,
size), GeneratorString(data,
size));
130 return Menu(&g_list, &g_int, GeneratorMenuOption(data,
size));
134 return Toggle(&g_list, &g_int);
136 return Slider(GeneratorString(data,
size), &g_int,
137 GeneratorInt(data,
size), GeneratorInt(data,
size),
138 GeneratorInt(data,
size));
141 GeneratorComponent(data,
size, depth - 1),
145 GeneratorComponent(data,
size, depth - 1),
149 GeneratorComponent(data,
size, depth - 1),
153 GeneratorComponent(data,
size, depth - 1),
170 return Maybe(GeneratorComponent(data,
size, depth - 1), &g_bool);
175 GeneratorComponent(data,
size, depth - 1),
176 GeneratorBool(data,
size));
182Components GeneratorComponents(
const char*& data,
size_t&
size,
int depth) {
185 while (
size && GeneratorInt(data,
size) % 2) {
186 out.push_back(GeneratorComponent(data,
size, depth - 1));
189 return std::move(out);
194 g_bool = GeneratorBool(data,
size);
195 g_int = GeneratorInt(data,
size);
197 "test_1",
"test_2",
"test_3",
"test_4",
"test_5",
201 auto component = GeneratorComponent(data,
size, depth);
203 int width = GeneratorInt(data,
size);
204 int height = GeneratorInt(data,
size);
215 auto event_receiver = MakeReceiver<Task>();
218 for (
size_t i = 0; i <
size; ++i)
223 while (event_receiver->Receive(&event)) {
224 component->OnEvent(std::get<Event>(event));
225 auto document = component->Render();
A class representing terminal colors.
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...
AnimatedColorOption foreground
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Component Maybe(Component, const bool *show)
Decorate a component |child|. It is shown only when |show| is true.
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component Checkbox(CheckboxOption options)
Component Menu(MenuOption options)
A list of text. The focused element is selected.
std::shared_ptr< ComponentBase > Component
Component Toggle(ConstStringListRef entries, int *selected)
An horizontal list of elements. The user can navigate through them.
std::vector< Component > Components
Component Radiobox(RadioboxOption options)
A list of element, where only one can be selected.
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
AnimatedColorOption background
std::wstring to_wstring(const std::string &s)
Convert a std::wstring into a UTF8 std::string.
Component Input(InputOption options={})
An input box for editing text.
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)
A dropdown menu.
Component Slider(SliderOption< T > options)
A slider in any direction.
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.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
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