FTXUI  0.8.1
C++ functional terminal UI.
component.hpp
Go to the documentation of this file.
1 #ifndef FTXUI_COMPONENT_HPP
2 #define FTXUI_COMPONENT_HPP
3 
4 #include <functional> // for function
5 #include <memory> // for make_shared, shared_ptr
6 #include <string> // for wstring
7 #include <vector> // for vector
8 
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
13 
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 
23 template <class T, class... Args>
24 std::shared_ptr<T> Make(Args&&... args) {
25  return std::make_shared<T>(args...);
26 }
27 
28 Component Button(ConstStringRef label,
29  std::function<void()> on_click,
30  Ref<ButtonOption> = {});
31 Component Checkbox(ConstStringRef label,
32  bool* checked,
33  Ref<CheckboxOption> option = {});
34 Component Input(StringRef content,
35  ConstStringRef placeholder,
36  Ref<InputOption> option = {});
37 Component Menu(ConstStringListRef entries,
38  int* selected_,
39  Ref<MenuOption> = {});
40 Component MenuEntry(ConstStringRef label, Ref<MenuEntryOption> = {});
41 Component Radiobox(ConstStringListRef entries,
42  int* selected_,
43  Ref<RadioboxOption> option = {});
44 Component Toggle(ConstStringListRef entries,
45  int* selected,
46  Ref<ToggleOption> option = {});
47 template <class T> // T = {int, float, long}
48 Component Slider(ConstStringRef label, T* value, T min, T max, T increment);
49 Component ResizableSplitLeft(Component main, Component back, int* main_size);
50 Component ResizableSplitRight(Component main, Component back, int* main_size);
51 Component ResizableSplitTop(Component main, Component back, int* main_size);
52 Component ResizableSplitBottom(Component main, Component back, int* main_size);
53 Component Renderer(Component child, std::function<Element()>);
54 Component Renderer(std::function<Element()>);
55 Component Renderer(std::function<Element(bool /* focused */)>);
56 Component CatchEvent(Component child, std::function<bool(Event)>);
57 
58 namespace Container {
59 Component Vertical(Components children);
60 Component Vertical(Components children, int* selector);
62 Component Horizontal(Components children, int* selector);
63 Component Tab(Components children, int* selector);
64 
65 } // namespace Container
66 
67 } // namespace ftxui
68 
69 // Include component using the old deprecated wstring.
71 
72 #endif /* end of include guard: FTXUI_COMPONENT_HPP */
73 
74 // Copyright 2021 Arthur Sonzogni. All rights reserved.
75 // Use of this source code is governed by the MIT license that can be found in
76 // the LICENSE file.
ftxui::Container::Horizontal
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Definition: container.cpp:239
ftxui::ResizableSplitRight
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Definition: resizable_split.cpp:296
ftxui
Definition: captured_mouse.hpp:6
ftxui::Component
std::shared_ptr< ComponentBase > Component
Definition: component_base.hpp:17
ftxui::ResizableSplitLeft
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Definition: resizable_split.cpp:266
ref.hpp
ftxui::Renderer
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
elements.hpp
ftxui::MenuEntry
Component MenuEntry(ConstStringRef label, Ref< MenuEntryOption >={})
Definition: menu.cpp:179
ftxui::Make
std::shared_ptr< T > Make(Args &&... args)
Definition: component.hpp:24
ftxui::Checkbox
Component Checkbox(ConstStringRef label, bool *checked, Ref< CheckboxOption > option={})
Draw checkable element.
Definition: checkbox.cpp:112
ftxui::Slider
Component Slider(ConstStringRef label, T *value, T min, T max, T increment)
An horizontal slider.
Definition: slider.cpp:123
component_base.hpp
ftxui::Element
std::shared_ptr< Node > Element
Definition: elements.hpp:15
ftxui::Container::Tab
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:284
ftxui::Container::Vertical
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:196
ftxui::Toggle
Component Toggle(ConstStringListRef entries, int *selected, Ref< ToggleOption > option={})
An horizontal list of elements. The user can navigate through them.
Definition: toggle.cpp:126
ftxui::ResizableSplitTop
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Definition: resizable_split.cpp:326
ftxui::Button
Component Button(ConstStringRef label, std::function< void()> on_click, Ref< ButtonOption >={})
Draw a button. Execute a function when clicked.
Definition: button.cpp:90
ftxui::Components
std::vector< Component > Components
Definition: component_base.hpp:18
ftxui::CatchEvent
Component CatchEvent(Component child, std::function< bool(Event)>)
ftxui::Radiobox
Component Radiobox(ConstStringListRef entries, int *selected_, Ref< RadioboxOption > option={})
A list of element, where only one can be selected.
Definition: radiobox.cpp:193
ftxui::Menu
Component Menu(ConstStringListRef entries, int *selected_, Ref< MenuOption >={})
A list of text. The focused element is selected.
Definition: menu.cpp:173
component_options.hpp
ftxui::ResizableSplitBottom
Component ResizableSplitBottom(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Definition: resizable_split.cpp:356
deprecated.hpp
ftxui::Input
Component Input(StringRef content, ConstStringRef placeholder, Ref< InputOption > option={})
An input box for editing text.
Definition: input.cpp:241