FTXUI  2.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
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
14namespace ftxui {
15struct ButtonOption;
16struct CheckboxOption;
17struct Event;
18struct InputOption;
19struct MenuOption;
20struct RadioboxOption;
21struct ToggleOption;
22struct MenuEntryOption;
23
24template <class T, class... Args>
25std::shared_ptr<T> Make(Args&&... args) {
26 return std::make_shared<T>(args...);
27}
28
29namespace Container {
31Component Vertical(Components children, int* selector);
33Component Horizontal(Components children, int* selector);
34Component Tab(Components children, int* selector);
35
36} // namespace Container
37
39 std::function<void()> on_click,
41Component Checkbox(ConstStringRef label,
42 bool* checked,
43 Ref<CheckboxOption> option = {});
44Component Input(StringRef content,
45 ConstStringRef placeholder,
46 Ref<InputOption> option = {});
47Component Menu(ConstStringListRef entries,
48 int* selected_,
49 Ref<MenuOption> = {});
50Component MenuEntry(ConstStringRef label, Ref<MenuEntryOption> = {});
51Component Dropdown(ConstStringListRef entries, int* selected);
52Component Radiobox(ConstStringListRef entries,
53 int* selected_,
54 Ref<RadioboxOption> option = {});
55Component Toggle(ConstStringListRef entries,
56 int* selected,
57 Ref<ToggleOption> option = {});
58template <class T> // T = {int, float, long}
59Component Slider(ConstStringRef label, T* value, T min, T max, T increment);
60Component ResizableSplitLeft(Component main, Component back, int* main_size);
61Component ResizableSplitRight(Component main, Component back, int* main_size);
62Component ResizableSplitTop(Component main, Component back, int* main_size);
63Component ResizableSplitBottom(Component main, Component back, int* main_size);
64Component Renderer(Component child, std::function<Element()>);
65Component Renderer(std::function<Element()>);
66Component Renderer(std::function<Element(bool /* focused */)>);
67Component CatchEvent(Component child, std::function<bool(Event)>);
68Component Maybe(Component, const bool* show);
70 Component child,
71 Ref<bool> show = false);
72
73} // namespace ftxui
74
75// Include component using the old deprecated wstring.
77
78#endif /* end of include guard: FTXUI_COMPONENT_HPP */
79
80// Copyright 2021 Arthur Sonzogni. All rights reserved.
81// Use of this source code is governed by the MIT license that can be found in
82// the LICENSE file.
An adapter. Own or reference a constant string. For convenience, this class convert multiple immutabl...
Definition ref.hpp:76
An adapter. Own or reference an mutable object.
Definition ref.hpp:27
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={})
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:206
Component Toggle(ConstStringListRef entries, int *selected, Ref< ToggleOption > option={})
An horizontal list of elements. The user can navigate through them.
Definition toggle.cpp:134
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
std::shared_ptr< T > Make(Args &&... args)
Definition component.hpp:25
std::shared_ptr< Node > Element
Definition elements.hpp:18
Component Input(StringRef content, ConstStringRef placeholder, Ref< InputOption > option={})
An input box for editing text.
Definition input.cpp:278
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
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:189
Component Maybe(Component, const bool *show)
Definition maybe.cpp:12
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)
Definition dropdown.cpp:14
Component MenuEntry(ConstStringRef label, Ref< MenuEntryOption >={})
Definition menu.cpp:195
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.
std::shared_ptr< ComponentBase > Component
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show=false)
Component CatchEvent(Component child, std::function< bool(Event)>)
Represent an event. It can be key press event, a terminal resize, or more ...
Definition event.hpp:25