FTXUI  0.10.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
29Component Button(ConstStringRef label,
30 std::function<void()> on_click,
31 Ref<ButtonOption> = {});
32Component Checkbox(ConstStringRef label,
33 bool* checked,
34 Ref<CheckboxOption> option = {});
35Component Input(StringRef content,
36 ConstStringRef placeholder,
37 Ref<InputOption> option = {});
38Component Menu(ConstStringListRef entries,
39 int* selected_,
40 Ref<MenuOption> = {});
41Component MenuEntry(ConstStringRef label, Ref<MenuEntryOption> = {});
42Component Dropdown(ConstStringListRef entries, int* selected);
43Component Radiobox(ConstStringListRef entries,
44 int* selected_,
45 Ref<RadioboxOption> option = {});
46Component Toggle(ConstStringListRef entries,
47 int* selected,
48 Ref<ToggleOption> option = {});
49template <class T> // T = {int, float, long}
50Component Slider(ConstStringRef label, T* value, T min, T max, T increment);
51Component ResizableSplitLeft(Component main, Component back, int* main_size);
52Component ResizableSplitRight(Component main, Component back, int* main_size);
53Component ResizableSplitTop(Component main, Component back, int* main_size);
54Component ResizableSplitBottom(Component main, Component back, int* main_size);
55Component Renderer(Component child, std::function<Element()>);
56Component Renderer(std::function<Element()>);
57Component Renderer(std::function<Element(bool /* focused */)>);
58Component CatchEvent(Component child, std::function<bool(Event)>);
59Component Maybe(Component, bool* show);
60
61namespace Container {
63Component Vertical(Components children, int* selector);
65Component Horizontal(Components children, int* selector);
66Component Tab(Components children, int* selector);
67
68} // namespace Container
69
70} // namespace ftxui
71
72// Include component using the old deprecated wstring.
74
75#endif /* end of include guard: FTXUI_COMPONENT_HPP */
76
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...
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:190
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< T > Make(Args &&... args)
Definition component.hpp:25
std::shared_ptr< Node > Element
Definition elements.hpp:15
Component Input(StringRef content, ConstStringRef placeholder, Ref< InputOption > option={})
An input box for editing text.
Definition input.cpp:241
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:173
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:7
Component MenuEntry(ConstStringRef label, Ref< MenuEntryOption >={})
Definition menu.cpp:179
Component Maybe(Component, bool *show)
Definition maybe.cpp:7
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 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