FTXUI  0.9.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
component_options.hpp
Go to the documentation of this file.
1#ifndef FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
2#define FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP
3
5#include <ftxui/util/ref.hpp>
6
7namespace ftxui {
8
9/// @brief Option for the Menu component.
10/// @ingroup component
11struct MenuOption {
13 Decorator style_focused = inverted; ///< Style when focused.
14 Decorator style_selected = bold; ///< Style when selected.
16 Decorator(inverted) | bold; ///< Style when selected and focused.
17
18 /// Called when the selected entry changes.
19 std::function<void()> on_change = [] {};
20 /// Called when the user presses enter.
21 std::function<void()> on_enter = [] {};
22
24};
25
26/// @brief Option for the MenuEntry component.
27/// @ingroup component
30 Decorator style_focused = inverted; ///< Style when focused.
31 Decorator style_selected = bold; ///< Style when selected.
33 Decorator(inverted) | bold; ///< Style when selected and focused.
34};
35
36/// @brief Option for the Button component.
37/// @ingroup component
39 /// Whether to show a border around the button.
40 bool border = true;
41};
42
43/// @brief Option for the Checkbox component.
44/// @ingroup component
46 std::string style_checked = "▣ "; ///< Prefix for a "checked" state.
47 std::string style_unchecked = "☐ "; ///< Prefix for a "unchecked" state.
49 Decorator style_focused = inverted; ///< Style when focused.
50 Decorator style_selected = bold; ///< Style when selected.
52 Decorator(inverted) | bold; ///< Style when selected and focused.
53
54 /// Called when the user change the state.
55 std::function<void()> on_change = []() {};
56};
57
58/// @brief Option for the Input component.
59/// @ingroup component
61 /// Called when the content changes.
62 std::function<void()> on_change = [] {};
63 /// Called when the user presses enter.
64 std::function<void()> on_enter = [] {};
65
66 /// Obscure the input content using '*'.
68
69 /// When set different from -1, this attributes is used to store the cursor
70 /// position.
72};
73
74/// @brief Option for the Radiobox component.
75/// @ingroup component
77 std::string style_checked = "◉ "; ///< Prefix for a "checked" state.
78 std::string style_unchecked = "○ "; ///< Prefix for a "unchecked" state.
80 Decorator style_focused = inverted; ///< Style when focused.
81 Decorator style_selected = bold; ///< Style when selected.
83 Decorator(inverted) | bold; ///< Style when selected and focused.
84
85 /// Called when the selected entry changes.
86 std::function<void()> on_change = []() {};
87
89};
90
91/// @brief Option for the Toggle component.
92/// @ingroup component
95 Decorator style_focused = inverted; ///< Style when focused.
96 Decorator style_selected = bold; ///< Style when selected.
98 Decorator(inverted) | bold; ///< Style when selected and focused.
99
100 /// Called when the selected entry changes.
101 std::function<void()> on_change = [] {};
102 /// Called when the user presses enter.
103 std::function<void()> on_enter = [] {};
104
106};
107
108} // namespace ftxui
109
110#endif /* end of include guard: FTXUI_COMPONENT_COMPONENT_OPTIONS_HPP */
111
112// Copyright 2021 Arthur Sonzogni. All rights reserved.
113// Use of this source code is governed by the MIT license that can be found in
114// the LICENSE file.
An adapter. Own or reference an mutable object.
Definition ref.hpp:27
std::string style_unchecked
Prefix for a "unchecked" state.
std::function< Element(Element)> Decorator
Definition elements.hpp:17
Element nothing(Element element)
A decoration doing absolutely nothing.
Definition util.cpp:25
Decorator style_focused
Style when focused.
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition bold.cpp:28
std::string style_checked
Prefix for a "checked" state.
std::function< void()> on_enter
Called when the user presses enter.
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Definition inverted.cpp:29
Decorator style_selected_focused
Style when selected and focused.
Decorator style_selected
Style when selected.
Ref< bool > password
Obscure the input content using '*'.
std::function< void()> on_change
Called when the selected entry changes.
bool border
Whether to show a border around the button.
Decorator style_normal
style.
Option for the Button component.
Option for the Checkbox component.
Option for the Input component.
Option for the MenuEntry component.
Option for the Menu component.
Option for the Radiobox component.
Option for the Toggle component.