13bool GeneratorBool(
const char*& data,
size_t& size) {
18 auto out = bool(data[0] % 2);
24std::string GeneratorString(
const char*& data,
size_t& size) {
26 while (index < size && data[index])
29 auto out = std::string(data, data + index);
39 return std::move(out);
42int GeneratorInt(
const char* data,
size_t size) {
45 auto out = int(data[0]);
51Color GeneratorColor(
const char* data,
size_t size) {
52 return Color::RGB(GeneratorInt(data, size), GeneratorInt(data, size),
53 GeneratorInt(data, size));
59 option.
enabled = GeneratorBool(data, size);
60 option.
inactive = GeneratorColor(data, size);
61 option.
active = GeneratorColor(data, size);
62 option.
duration = std::chrono::milliseconds(GeneratorInt(data, size));
69 option.
background = GeneratorAnimatedColorOption(data, size);
70 option.
foreground = GeneratorAnimatedColorOption(data, size);
74ButtonOption GeneratorButtonOption(
const char* data,
size_t size) {
80UnderlineOption GeneratorUnderlineOption(
const char* data,
size_t size) {
82 option.
enabled = GeneratorBool(data, size);
85 option.
leader_duration = std::chrono::milliseconds(GeneratorInt(data, size));
87 std::chrono::milliseconds(GeneratorInt(data, size));
88 option.
leader_delay = std::chrono::milliseconds(GeneratorInt(data, size));
89 option.
follower_delay = std::chrono::milliseconds(GeneratorInt(data, size));
93MenuEntryOption GeneratorMenuEntryOption(
const char* data,
size_t size) {
99MenuOption GeneratorMenuOption(
const char* data,
size_t size) {
101 option.
underline = GeneratorUnderlineOption(data, size);
109std::vector<std::string> g_list;
111Components GeneratorComponents(
const char*& data,
size_t& size,
int depth);
113Component GeneratorComponent(
const char*& data,
size_t& size,
int depth) {
115 int value = GeneratorInt(data, size);
117 return Button(GeneratorString(data, size), [] {});
119 constexpr int value_max = 19;
120 value = (value % value_max + value_max) % value_max;
124 GeneratorString(data, size), [] {},
125 GeneratorButtonOption(data, size));
127 return Checkbox(GeneratorString(data, size), &g_bool);
129 return Input(GeneratorString(data, size), GeneratorString(data, size));
131 return Menu(&g_list, &g_int, GeneratorMenuOption(data, size));
135 return Toggle(&g_list, &g_int);
137 return Slider(GeneratorString(data, size), &g_int,
138 GeneratorInt(data, size), GeneratorInt(data, size),
139 GeneratorInt(data, size));
142 GeneratorComponent(data, size, depth - 1),
146 GeneratorComponent(data, size, depth - 1),
150 GeneratorComponent(data, size, depth - 1),
154 GeneratorComponent(data, size, depth - 1),
169 return Container::Tab(GeneratorComponents(data, size, depth - 1), &g_int);
171 return Maybe(GeneratorComponent(data, size, depth - 1), &g_bool);
176 GeneratorComponent(data, size, depth - 1),
177 GeneratorBool(data, size));
183Components GeneratorComponents(
const char*& data,
size_t& size,
int depth) {
186 while (size && GeneratorInt(data, size) % 2) {
187 out.push_back(GeneratorComponent(data, size, depth - 1));
190 return std::move(out);
195 g_bool = GeneratorBool(data, size);
196 g_int = GeneratorInt(data, size);
198 "test_1",
"test_2",
"test_3",
"test_4",
"test_5",
202 auto component = GeneratorComponent(data, size, depth);
204 int width = GeneratorInt(data, size);
205 int height = GeneratorInt(data, size);
214 Screen::Create(Dimension::Fixed(width), Dimension::Fixed(height));
217 std::vector<Event> events;
221 for (
size_t i = 0; i <
size; ++i) {
225 for (
const auto& event : events) {
226 component->OnEvent(event);
227 auto document = component->Render();
int LLVMFuzzerTestOneInput(const char *data, size_t size)
animation::Duration follower_duration
MenuEntryOption entries_option
animation::Duration follower_delay
UnderlineOption underline
animation::Duration leader_duration
animation::Duration duration
AnimatedColorsOption animated_colors
animation::Duration leader_delay
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
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 Menu(MenuOption options)
A list of text. The focused element is selected.
Component Toggle(ConstStringListRef entries, int *selected)
An horizontal list of elements. The user can navigate through them.
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.
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
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 ResizableSplitBottom(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component Checkbox(CheckboxOption options)
Draw checkable element.
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
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...
Option about a potentially animated color.
Represent an event. It can be key press event, a terminal resize, or more ...
Option for the underline effect.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Direction
Direction is an enumeration that represents the four cardinal directions.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
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.
Color is a class that represents a color in the terminal user interface.
The FTXUI ftxui:: namespace.
std::vector< Component > Components
std::wstring to_wstring(const std::string &s)
Convert a UTF8 std::string into a std::wstring.
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show=false)
A collapsible component. It displays a checkbox with an arrow. Once activated, the child is displayed...
Component Slider(SliderOption< T > options)
A slider in any direction.
std::shared_ptr< ComponentBase > Component
AnimatedColorOption foreground
AnimatedColorOption background