FTXUI  0.8.1
C++ functional terminal UI.
elements.hpp
Go to the documentation of this file.
1 #ifndef FTXUI_DOM_ELEMENTS_HPP
2 #define FTXUI_DOM_ELEMENTS_HPP
3 
4 #include <functional>
5 #include <memory>
6 
7 #include "ftxui/dom/node.hpp"
8 #include "ftxui/screen/box.hpp"
9 #include "ftxui/screen/color.hpp"
10 #include "ftxui/screen/screen.hpp"
12 
13 namespace ftxui {
14 class Node;
15 using Element = std::shared_ptr<Node>;
16 using Elements = std::vector<Element>;
17 using Decorator = std::function<Element(Element)>;
18 using GraphFunction = std::function<std::vector<int>(int, int)>;
19 
20 // Pipe elements into decorator togethers.
21 // For instance the next lines are equivalents:
22 // -> text("ftxui") | bold | underlined
23 // -> underlined(bold(text("FTXUI")))
27 
28 // --- Widget ---
29 Element text(std::string text);
30 Element vtext(std::string text);
31 Element separator(void);
33 Element gauge(float ratio);
36 Element window(Element title, Element content);
37 Element spinner(int charset_index, size_t image_index);
38 Elements paragraph(std::string text); // Use inside hflow(). Split by space.
40 
41 // -- Decorator ---
51 
52 // --- Layout is
53 // Horizontal, Vertical or stacked set of elements.
57 Element gridbox(std::vector<Elements> lines);
59 
60 // -- Flexibility ---
61 // Define how to share the remaining space when not all of it is used inside a
62 // container.
63 Element flex(Element); // Expand/Minimize if possible/needed.
64 Element flex_grow(Element); // Expand element if possible.
65 Element flex_shrink(Element); // Minimize element if needed.
66 
67 Element xflex(Element); // Expand/Minimize if possible/needed on X axis.
68 Element xflex_grow(Element); // Expand element if possible on X axis.
69 Element xflex_shrink(Element); // Minimize element if needed on X axis.
70 
71 Element yflex(Element); // Expand/Minimize if possible/needed on Y axis.
72 Element yflex_grow(Element); // Expand element if possible on Y axis.
73 Element yflex_shrink(Element); // Minimize element if needed on Y axis.
74 
75 Element notflex(Element); // Reset the flex attribute.
76 Element filler(); // A blank expandable element.
77 
78 // -- Size override;
81 Decorator size(Direction, Constraint, int value);
82 
83 // --
84 Decorator reflect(Box& box);
85 
86 // --- Frame ---
87 // A frame is a scrollable area. The internal area is potentially larger than
88 // the external one. The internal area is scrolled in order to make visible the
89 // focused element.
95 
96 // --- Util --------------------------------------------------------------------
101 Element nothing(Element element);
102 
103 // Before drawing the |element| clear the pixel below. This is useful in
104 // combinaison with dbox.
105 Element clear_under(Element element);
106 
107 namespace Dimension {
109 } // namespace Dimension
110 
111 } // namespace ftxui
112 
113 // Make container able to take any number of children as input.
114 #include "ftxui/dom/take_any_args.hpp"
115 
116 // Include old definitions using wstring.
117 #include "ftxui/dom/deprecated.hpp"
118 #endif /* end of include guard: FTXUI_DOM_ELEMENTS_HPP */
119 
120 // Copyright 2020 Arthur Sonzogni. All rights reserved.
121 // Use of this source code is governed by the MIT license that can be found in
122 // the LICENSE file.
ftxui::clear_under
Element clear_under(Element element)
Before drawing |child|, clear the pixels below. This is useful in.
Definition: clear_under.cpp:32
ftxui::paragraph
Elements paragraph(std::wstring text)
Return a vector of ftxui::text for every word of the string. This is useful combined with ftxui::hflo...
Definition: paragraph.cpp:14
ftxui::border
Element border(Element)
Draw a border around the element.
Definition: border.cpp:138
ftxui::flex_grow
Element flex_grow(Element)
Expand if possible.
Definition: flex.cpp:137
ftxui::xflex
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Definition: flex.cpp:125
ftxui::center
Element center(Element)
Center an element horizontally and vertically.
Definition: composite_decorator.cpp:28
ftxui::yflex_shrink
Element yflex_shrink(Element)
Minimize if needed on the Y axis.
Definition: flex.cpp:167
deprecated.hpp
ftxui::window
Element window(Element title, Element content)
Draw window with a title and a border around the element.
Definition: border.cpp:163
ftxui::focus
Element focus(Element)
Definition: frame.cpp:79
ftxui::align_right
Element align_right(Element)
Align an element on the right side.
Definition: composite_decorator.cpp:36
ftxui
Definition: captured_mouse.hpp:6
ftxui::frame
Element frame(Element)
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container....
Definition: frame.cpp:138
ftxui::Dimensions
Definition: terminal.hpp:5
ftxui::yframe
Element yframe(Element)
Definition: frame.cpp:146
node.hpp
ftxui::yflex
Element yflex(Element)
Expand/Minimize if possible/needed on the Y axis.
Definition: flex.cpp:131
ftxui::WIDTH
@ WIDTH
Definition: elements.hpp:79
ftxui::vtext
Element vtext(std::wstring text)
Display a piece unicode text vertically.
Definition: text.cpp:166
ftxui::GREATER_THAN
@ GREATER_THAN
Definition: elements.hpp:80
ftxui::nothing
Element nothing(Element element)
A decoration doing absolutely nothing.
Definition: util.cpp:25
ftxui::inverted
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Definition: inverted.cpp:29
ftxui::vcenter
Element vcenter(Element)
Center an element vertically.
Definition: composite_decorator.cpp:20
ftxui::Constraint
Constraint
Definition: elements.hpp:80
ftxui::color
Decorator color(Color)
Decorate using a foreground color.
Definition: color.cpp:86
ftxui::reflect
Decorator reflect(Box &box)
Definition: reflect.cpp:38
ftxui::bold
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition: bold.cpp:28
box.hpp
ftxui::HEIGHT
@ HEIGHT
Definition: elements.hpp:79
ftxui::GraphFunction
std::function< std::vector< int >(int, int)> GraphFunction
Definition: elements.hpp:18
ftxui::filler
Element filler()
An element that will take expand proportionnally to the space left in a container.
Definition: flex.cpp:94
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition: hbox.cpp:75
ftxui::flex_shrink
Element flex_shrink(Element)
Minimize if needed.
Definition: flex.cpp:155
terminal.hpp
ftxui::flex
Element flex(Element)
Make a child element to expand proportionnally to the space left in a container.
Definition: flex.cpp:119
ftxui::Direction
Direction
Definition: elements.hpp:79
ftxui::separator
Element separator(void)
Definition: separator.cpp:54
ftxui::Elements
std::vector< Element > Elements
Definition: elements.hpp:16
ftxui::select
Element select(Element)
Definition: frame.cpp:38
ftxui::underlined
Element underlined(Element)
Make the underlined element to be underlined.
Definition: underlined.cpp:28
ftxui::gauge
Element gauge(float ratio)
Draw a high definition progress bar.
Definition: gauge.cpp:75
ftxui::operator|
Element operator|(Element, Decorator)
From an element, apply a decorator.
Definition: util.cpp:64
ftxui::xframe
Element xframe(Element)
Definition: frame.cpp:142
ftxui::xflex_shrink
Element xflex_shrink(Element)
Minimize if needed on the X axis.
Definition: flex.cpp:161
ftxui::graph
Element graph(GraphFunction)
Draw a graph using a GraphFunction.
Definition: graph.cpp:59
ftxui::Dimension::Fit
Dimensions Fit(Element &)
Definition: util.cpp:71
ftxui::Element
std::shared_ptr< Node > Element
Definition: elements.hpp:15
ftxui::xflex_grow
Element xflex_grow(Element)
Expand if possible on the X axis.
Definition: flex.cpp:143
ftxui::bgcolor
Decorator bgcolor(Color)
Decorate using a background color.
Definition: color.cpp:100
ftxui::blink
Element blink(Element)
The text drawn alternates in between visible and hidden.
Definition: blink.cpp:28
ftxui::vbox
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition: vbox.cpp:76
ftxui::size
Decorator size(Direction, Constraint, int value)
Apply a constraint on the size of an element.
Definition: size.cpp:86
ftxui::borderWith
Decorator borderWith(Pixel)
Same as border but with a constant Pixel around the element.
Definition: border.cpp:170
ftxui::dbox
Element dbox(Elements)
Stack several element on top of each other.
Definition: dbox.cpp:50
color.hpp
ftxui::notflex
Element notflex(Element)
Make the element not flexible.
Definition: flex.cpp:173
ftxui::hcenter
Element hcenter(Element)
Center an element horizontally.
Definition: composite_decorator.cpp:12
ftxui::dim
Element dim(Element)
Use a light font, for elements with less emphasis.
Definition: dim.cpp:28
ftxui::Decorator
std::function< Element(Element)> Decorator
Definition: elements.hpp:17
ftxui::EQUAL
@ EQUAL
Definition: elements.hpp:80
ftxui::gridbox
Element gridbox(std::vector< Elements > lines)
A container displaying a grid of elements.
Definition: gridbox.cpp:153
ftxui::hflow
Element hflow(Elements)
A container displaying elements horizontally one by one.
Definition: hflow.cpp:75
ftxui::spinner
Element spinner(int charset_index, size_t image_index)
Useful to represent the effect of time and/or events. This display an ASCII art "video".
Definition: spinner.cpp:255
ftxui::Pixel
A unicode character and its associated style.
Definition: screen.hpp:16
ftxui::LESS_THAN
@ LESS_THAN
Definition: elements.hpp:80
screen.hpp
ftxui::Color
A class representing terminal colors.
Definition: color.hpp:17
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition: text.cpp:106
ftxui::yflex_grow
Element yflex_grow(Element)
Expand if possible on the Y axis.
Definition: flex.cpp:149