FTXUI  0.9.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 Radiobox(ConstStringListRef entries,
43 int* selected_,
44 Ref<RadioboxOption> option = {});
45Component Toggle(ConstStringListRef entries,
46 int* selected,
47 Ref<ToggleOption> option = {});
48template <class T> // T = {int, float, long}
49Component Slider(ConstStringRef label, T* value, T min, T max, T increment);
50Component ResizableSplitLeft(Component main, Component back, int* main_size);
51Component ResizableSplitRight(Component main, Component back, int* main_size);
52Component ResizableSplitTop(Component main, Component back, int* main_size);
53Component ResizableSplitBottom(Component main, Component back, int* main_size);
54Component Renderer(Component child, std::function<Element()>);
55Component Renderer(std::function<Element()>);
56Component Renderer(std::function<Element(bool /* focused */)>);
57Component CatchEvent(Component child, std::function<bool(Event)>);
58
59namespace Container {
61Component Vertical(Components children, int* selector);
63Component Horizontal(Components children, int* selector);
64Component Tab(Components children, int* selector);
65
66} // namespace Container
67
68} // namespace ftxui
69
70// Include component using the old deprecated wstring.
72
73#endif /* end of include guard: FTXUI_COMPONENT_HPP */
74
75// Copyright 2021 Arthur Sonzogni. All rights reserved.
76// Use of this source code is governed by the MIT license that can be found in
77// 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 MenuEntry(ConstStringRef label, Ref< MenuEntryOption >={})
Definition menu.cpp:179
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