FTXUI  0.11.1
C++ functional terminal UI.
Go to the documentation of this file.
4 #include <functional> // for function
5 #include <memory> // for make_shared, shared_ptr
6 #include <string> // for wstring
7 #include <vector> // for vector
9 #include "ftxui/component/component_base.hpp" // for Component, Components
10 #include "ftxui/component/component_options.hpp" // for ButtonOption, CheckboxOption, InputOption, MenuOption, RadioboxOption, ToggleOption
11 #include "ftxui/dom/elements.hpp" // for Element
12 #include "ftxui/util/ref.hpp" // for Ref, ConstStringRef, ConstStringListRef, StringRef
14 namespace ftxui {
15 struct ButtonOption;
16 struct CheckboxOption;
17 struct Event;
18 struct InputOption;
19 struct MenuOption;
20 struct RadioboxOption;
21 struct ToggleOption;
22 struct MenuEntryOption;
24 template <class T, class... Args>
25 std::shared_ptr<T> Make(Args&&... args) {
26  return std::make_shared<T>(args...);
27 }
29 Component Button(ConstStringRef label,
30  std::function<void()> on_click,
31  Ref<ButtonOption> = {});
32 Component Checkbox(ConstStringRef label,
33  bool* checked,
34  Ref<CheckboxOption> option = {});
35 Component Input(StringRef content,
36  ConstStringRef placeholder,
37  Ref<InputOption> option = {});
38 Component Menu(ConstStringListRef entries,
39  int* selected_,
40  Ref<MenuOption> = {});
41 Component MenuEntry(ConstStringRef label, Ref<MenuEntryOption> = {});
42 Component Dropdown(ConstStringListRef entries, int* selected);
43 Component Radiobox(ConstStringListRef entries,
44  int* selected_,
45  Ref<RadioboxOption> option = {});
46 Component Toggle(ConstStringListRef entries,
47  int* selected,
48  Ref<ToggleOption> option = {});
49 template <class T> // T = {int, float, long}
50 Component Slider(ConstStringRef label, T* value, T min, T max, T increment);
51 Component ResizableSplitLeft(Component main, Component back, int* main_size);
52 Component ResizableSplitRight(Component main, Component back, int* main_size);
53 Component ResizableSplitTop(Component main, Component back, int* main_size);
54 Component ResizableSplitBottom(Component main, Component back, int* main_size);
55 Component Renderer(Component child, std::function<Element()>);
56 Component Renderer(std::function<Element()>);
57 Component Renderer(std::function<Element(bool /* focused */)>);
58 Component CatchEvent(Component child, std::function<bool(Event)>);
59 Component Maybe(Component, bool* show);
61 namespace Container {
62 Component Vertical(Components children);
63 Component Vertical(Components children, int* selector);
65 Component Horizontal(Components children, int* selector);
66 Component Tab(Components children, int* selector);
68 } // namespace Container
70 } // namespace ftxui
72 // Include component using the old deprecated wstring.
75 #endif /* end of include guard: FTXUI_COMPONENT_HPP */
77 // Copyright 2021 Arthur Sonzogni. All rights reserved.
78 // Use of this source code is governed by the MIT license that can be found in
79 // the LICENSE file.
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Definition: container.cpp:259
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Definition: container.cpp:216
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...
Definition: container.cpp:304
Component Checkbox(ConstStringRef label, bool *checked, Ref< CheckboxOption > option={})
Draw checkable element.
Definition: checkbox.cpp:117
Component Radiobox(ConstStringListRef entries, int *selected_, Ref< RadioboxOption > option={})
A list of element, where only one can be selected.
Definition: radiobox.cpp:198
Component Toggle(ConstStringListRef entries, int *selected, Ref< ToggleOption > option={})
An horizontal list of elements. The user can navigate through them.
Definition: toggle.cpp:126
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
std::shared_ptr< Node > Element
Definition: elements.hpp:16
Component Input(StringRef content, ConstStringRef placeholder, Ref< InputOption > option={})
An input box for editing text.
Definition: input.cpp:277
std::shared_ptr< ComponentBase > Component
std::vector< Component > Components
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Definition: renderer.cpp:59
std::shared_ptr< T > Make(Args &&... args)
Definition: component.hpp:25
Component Button(ConstStringRef label, std::function< void()> on_click, Ref< ButtonOption >={})
Draw a button. Execute a function when clicked.
Definition: button.cpp:90
Component Menu(ConstStringListRef entries, int *selected_, Ref< MenuOption >={})
A list of text. The focused element is selected.
Definition: menu.cpp:181
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Component CatchEvent(Component child, std::function< bool(Event)>)
Component Dropdown(ConstStringListRef entries, int *selected)
Definition: dropdown.cpp:14
Component MenuEntry(ConstStringRef label, Ref< MenuEntryOption >={})
Definition: menu.cpp:187
Component Maybe(Component, bool *show)
Definition: maybe.cpp:12
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.
Definition: slider.cpp:123
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Represent an event. It can be key press event, a terminal resize, or more ...
Definition: event.hpp:25