Module ftxui/dom
Classes & Structs
| Class | Description |
|---|---|
ftxui::Node | |
ftxui::Requirement |
Enumerations
BorderStyle
enum BorderStyle { LIGHT, HEAVY, DOUBLE, ROUNDED };Constraint
enum Constraint { LESS_THAN, EQUAL, GREATER_THAN };Direction
enum Direction { WIDTH, HEIGHT };Type Aliases
Decorator
Examples: component/menu_entries
Element
Examples: component/modal_dialog, component/slider_rgb, dom/package_manager, dom/spinner, dom/window
Elements
Examples: component/homescreen, component/print_key_press, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/size
GraphFunction
using GraphFunction = std::function< std::vector< int >(int, int)>;Functions
| Symbol | Description |
|---|---|
align_right | Align an element on the right side. |
bgcolor | Set the background color of an element. |
blink | The text drawn alternates in between visible and hidden. |
bold | Use a bold font, for elements with more emphasis. |
border | Draw a border around the element. |
borderDouble | Draw a double border around the element. |
borderHeavy | Draw a heavy border around the element. |
borderLight | Draw a light border around the element. |
borderRounded | Draw a rounded border around the element. |
borderStyled | Same as border but with different styles. |
borderWith | Same as border but with a constant Pixel around the element. |
center | Center an element horizontally and vertically. |
clear_under | Before drawing child, clear the pixels below. This is useful in. |
color | Set the foreground color of an element. |
dbox | Stack several element on top of each other. |
dim | Use a light font, for elements with less emphasis. |
filler | An element that will take expand proportionnally to the space left in a container. |
flex | Make a child element to expand proportionnally to the space left in a container. |
flex_grow | Expand if possible. |
flex_shrink | Minimize if needed. |
frame | Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container. In this case only a smaller portion is displayed. The view is scrollable to make the focused element visible. |
gauge | Draw a high definition progress bar. |
graph | Draw a graph using a GraphFunction. |
gridbox | A container displaying a grid of elements. |
hbox | A container displaying elements horizontally one by one. |
hcenter | Center an element horizontally. |
hflow | A container displaying elements horizontally one by one. |
inverted | Add a filter that will invert the foreground and the background colors. |
ComputeRequirement | Compute how much space an elements needs. |
Render | Display an element on a ftxui::Screen. |
SetBox | Assign a position and a dimension to an element for drawing. |
notflex | Make the element not flexible. |
nothing | A decoration doing absolutely nothing. |
operator| | Compose two decorator into one. |
paragraph | Return a vector of ftxui::text for every word of the string. This is useful combined with ftxui::hflow. |
size | Apply a constraint on the size of an element. |
spinner | Useful to represent the effect of time and/or events. This display an ASCII art "video". |
text | Display a piece of UTF8 encoded unicode text. |
underlined | Make the underlined element to be underlined. |
vbox | A container displaying elements vertically one by one. |
vcenter | Center an element vertically. |
vscroll_indicator | Add a filter that will invert the foreground and the background colors. |
vtext | Display a piece of unicode text vertically. |
window | Draw window with a title and a border around the element. |
xflex | Expand/Minimize if possible/needed on the X axis. |
xflex_grow | Expand if possible on the X axis. |
xflex_shrink | Minimize if needed on the X axis. |
yflex | Expand/Minimize if possible/needed on the Y axis. |
yflex_grow | Expand if possible on the Y axis. |
yflex_shrink | Minimize if needed on the Y axis. |
align_right
Element align_right(Element);Align an element on the right side.
Parameters:
child: The decorated element.
Returns: The right aligned element.
bgcolor
Set the background color of an element.
Parameters:
color: The color of the output element.child: The input element.
Returns: The output element colored.
Example
Examples: component/homescreen, component/menu_style, component/slider_rgb, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/style_color, dom/style_gallery, dom/window
bgcolor
Decorate using a background color.
Parameters:
color: The background color to be applied.
Returns: The Decorator applying the color.
Example
Examples: component/homescreen, component/menu_style, component/slider_rgb, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/style_color, dom/style_gallery, dom/window
blink
The text drawn alternates in between visible and hidden.
Examples: dom/style_blink, dom/style_gallery
bold
Use a bold font, for elements with more emphasis.
Examples: component/homescreen, component/menu2, component/menu_entries, component/menu_style, component/modal_dialog, component/renderer, dom/hflow, dom/html_like, dom/package_manager, dom/size, dom/spinner, dom/style_bold (+1 more)
border
Draw a border around the element.
See also: border, borderLight, borderDouble, borderHeavy, borderRounded
Add a border around an element
Example
// Use 'border' as a function...
Element document = border(text("The element"));
// ...Or as a 'pipe'.
Element document = text("The element") | border;Output
┌───────────┐
│The element│
└───────────┘Examples: component/button, component/checkbox_in_frame, component/composition, component/gallery, component/homescreen, component/input, component/maybe, component/menu2, component/menu_entries, component/menu_in_frame, component/menu_style, component/modal_dialog (+18 more)
borderDouble
Element borderDouble(Element);Draw a double border around the element.
See also: border, borderLight, borderDouble, borderHeavy, borderRounded, borderStyled, borderWith
Add a border around an element
Example
// Use 'borderDouble' as a function...
Element document = borderDouble(text("The element"));
// ...Or as a 'pipe'.
Element document = text("The element") | borderDouble;Output
╔══════════════╗
║The element ║
╚══════════════╝Examples: dom/border_style, dom/separator_style
borderHeavy
Element borderHeavy(Element);Draw a heavy border around the element.
See also: border, borderLight, borderDouble, borderHeavy, borderRounded, borderStyled, borderWith
Add a border around an element
Example
// Use 'borderHeavy' as a function...
Element document = borderHeavy(text("The element"));
// ...Or as a 'pipe'.
Element document = text("The element") | borderHeavy;Output
┏━━━━━━━━━━━━━━┓
┃The element ┃
┗━━━━━━━━━━━━━━┛Examples: dom/border_style, dom/separator_style
borderLight
Element borderLight(Element);Draw a light border around the element.
See also: border, borderLight, borderDouble, borderHeavy, borderRounded, borderStyled, borderWith
Add a border around an element
Example
// Use 'borderLight' as a function...
Element document = borderLight(text("The element"));
// ...Or as a 'pipe'.
Element document = text("The element") | borderLight;Output
┌──────────────┐
│The element │
└──────────────┘Examples: dom/border_style, dom/separator_style
borderRounded
Element borderRounded(Element);Draw a rounded border around the element.
See also: border, borderLight, borderDouble, borderHeavy, borderRounded, borderStyled, borderWith
Add a border around an element
Example
// Use 'borderRounded' as a function...
Element document = borderRounded(text("The element"));
// ...Or as a 'pipe'.
Element document = text("The element") | borderRounded;Output
╭──────────────╮
│The element │
╰──────────────╯Examples: dom/border_style
borderStyled
Decorator borderStyled(BorderStyle);Same as border but with different styles.
See also: border
borderWith
Decorator borderWith(Pixel);Same as border but with a constant Pixel around the element.
See also: border
center
Center an element horizontally and vertically.
Parameters:
child: The decorated element.
Returns: The centered element.
Examples: component/modal_dialog, component/renderer, component/resizable_split, dom/dbox, dom/separator
clear_under
Element clear_under(Element element);Before drawing child, clear the pixels below. This is useful in.
See also: ftxui::dbox
Examples: component/modal_dialog
color
Set the foreground color of an element.
Parameters:
color: The color of the output element.child: The input element.
Returns: The output element colored.
Example
Examples: component/homescreen, component/menu_entries, component/menu_style, component/renderer, dom/color_gallery, dom/color_truecolor_HSV, dom/graph, dom/html_like, dom/package_manager, dom/style_color, dom/style_gallery, dom/window
color
Decorate using a foreground color.
Parameters:
c: The foreground color to be applied.
Returns: The Decorator applying the color.
Example
Examples: component/homescreen, component/menu_entries, component/menu_style, component/renderer, dom/color_gallery, dom/color_truecolor_HSV, dom/graph, dom/html_like, dom/package_manager, dom/style_color, dom/style_gallery, dom/window
dbox
Stack several element on top of each other.
Parameters:
children_: The input element.
Returns: The right aligned element.
Examples: component/modal_dialog, dom/dbox
dim
Use a light font, for elements with less emphasis.
Examples: component/homescreen, component/menu_style, dom/hflow, dom/html_like, dom/package_manager, dom/size, dom/style_dim, dom/style_gallery
filler
An element that will take expand proportionnally to the space left in a container.
Examples: component/homescreen, component/modal_dialog, dom/package_manager, dom/spinner, dom/style_color, dom/vbox_hbox
flex
Make a child element to expand proportionnally to the space left in a container.
Examples:
Output:
┌────┐┌─────────────────────────────────────────────────────────┐┌─────┐
│left││middle ││right│
└────┘└─────────────────────────────────────────────────────────┘└─────┘Examples: component/homescreen, component/menu_multiple, component/menu_style, dom/gauge, dom/graph, dom/paragraph, dom/separator
flex_grow
Expand if possible.
Examples: component/homescreen
flex_shrink
Element flex_shrink(Element);Minimize if needed.
frame
Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container. In this case only a smaller portion is displayed. The view is scrollable to make the focused element visible.
See also: focus
Examples: component/checkbox_in_frame, component/homescreen, component/menu_entries, component/menu_in_frame, component/radiobox_in_frame
gauge
Draw a high definition progress bar.
Parameters:
progress: The proportion of the area to be filled. Belong to [0,1].
ExampleA gauge. It can be used to represent a progress bar.
Output
┌──────────────────────────────────────────────────────────────────────────┐
│█████████████████████████████████████ │
└──────────────────────────────────────────────────────────────────────────┘Examples: component/button, component/homescreen, component/menu2, dom/gauge, dom/package_manager
graph
Element graph(GraphFunction);Draw a graph using a GraphFunction.
Parameters:
graph_function: the function to be called to get the data.
Examples: component/homescreen, dom/graph, dom/window
gridbox
A container displaying a grid of elements.
Parameters:
lines: A list of lines, each line being a list of elements.
Returns: The container.
Example
auto cell = [](const char* t) { return text(t) | border; };
auto document = gridbox({
{cell("north-west") , cell("north") , cell("north-east")} ,
{cell("west") , cell("center") , cell("east")} ,
{cell("south-west") , cell("south") , cell("south-east")} ,
});Output:
╭──────────╮╭──────╮╭──────────╮
│north-west││north ││north-east│
╰──────────╯╰──────╯╰──────────╯
╭──────────╮╭──────╮╭──────────╮
│west ││center││east │
╰──────────╯╰──────╯╰──────────╯
╭──────────╮╭──────╮╭──────────╮
│south-west││south ││south-east│
╰──────────╯╰──────╯╰──────────╯Examples: dom/gridbox
hbox
A container displaying elements horizontally one by one.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: component/gallery, component/homescreen, component/input, component/menu2, component/menu_entries, component/menu_style, component/modal_dialog, component/slider_rgb, component/tab_vertical, component/toggle, dom/border, dom/color_gallery (+19 more)
hcenter
Center an element horizontally.
Parameters:
child: The decorated element.
Returns: The centered element.
Examples: component/homescreen, component/menu2, dom/hflow, dom/size
hflow
A container displaying elements horizontally one by one.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: component/homescreen, dom/hflow, dom/html_like, dom/paragraph
inverted
Add a filter that will invert the foreground and the background colors.
Examples: component/menu_entries, dom/graph, dom/style_gallery, dom/style_inverted
ComputeRequirement
virtual void ComputeRequirement();Compute how much space an elements needs.
Render
Display an element on a ftxui::Screen.
Examples: component/button, component/checkbox_in_frame, component/composition, component/gallery, component/homescreen, component/input, component/maybe, component/menu2, component/menu_entries, component/menu_in_frame, component/menu_multiple, component/menu_style (+36 more)
SetBox
Assign a position and a dimension to an element for drawing.
notflex
Make the element not flexible.
nothing
A decoration doing absolutely nothing.
operator|
Compose two decorator into one.
Example
operator|
From a set of element, apply a decorator to every elements.
Returns: the set of decorated element.
operator|
From an element, apply a decorator.
Returns: the decorated element.
ExampleBoth of these are equivalent:
paragraph
Return a vector of ftxui::text for every word of the string. This is useful combined with ftxui::hflow.
Parameters:
the_text: The string to be splitted.
See also: hflow.
Examples: dom/html_like, dom/paragraph
Render
Display an element on a ftxui::Screen.
Examples: component/button, component/checkbox_in_frame, component/composition, component/gallery, component/homescreen, component/input, component/maybe, component/menu2, component/menu_entries, component/menu_in_frame, component/menu_multiple, component/menu_style (+36 more)
Render
Display an element on a ftxui::Screen.
Examples: component/button, component/checkbox_in_frame, component/composition, component/gallery, component/homescreen, component/input, component/maybe, component/menu2, component/menu_entries, component/menu_in_frame, component/menu_multiple, component/menu_style (+36 more)
size
Apply a constraint on the size of an element.
Parameters:
direction: Whether the WIDTH of the HEIGHT of the element must be constrained.constraint: The type of constaint.value: The value.
Examples: component/checkbox_in_frame, component/gallery, component/homescreen, component/menu_entries, component/menu_in_frame, component/modal_dialog, component/print_key_press, component/radiobox_in_frame, component/slider_rgb, dom/graph, dom/hflow, dom/package_manager (+2 more)
spinner
Useful to represent the effect of time and/or events. This display an ASCII art "video".
Parameters:
charset_index: The type of "video".image_index: The "frame" of the video. You need to increase this for every "step".
Examples: component/homescreen, dom/html_like, dom/spinner
text
Display a piece of UTF8 encoded unicode text.
See also: ftxui::to_wstring
Example
Output
Hello world!Examples: component/button, component/composition, component/gallery, component/homescreen, component/input, component/menu2, component/menu_entries, component/menu_multiple, component/modal_dialog, component/nested_screen, component/print_key_press, component/renderer (+27 more)
underlined
Element underlined(Element);Make the underlined element to be underlined.
Examples: dom/html_like, dom/style_gallery, dom/style_underlined
vbox
A container displaying elements vertically one by one.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: component/button, component/composition, component/gallery, component/homescreen, component/input, component/menu2, component/menu_entries, component/menu_multiple, component/modal_dialog, component/nested_screen, component/print_key_press, component/slider_rgb (+18 more)
vcenter
Center an element vertically.
Parameters:
child: The decorated element.
Returns: The centered element.
vscroll_indicator
Add a filter that will invert the foreground and the background colors.
Examples: component/checkbox_in_frame, component/homescreen, component/menu_in_frame, component/radiobox_in_frame
vtext
Display a piece of unicode text vertically.
See also: ftxui::to_wstring
Example
Output
H
e
l
l
o
w
o
r
l
d
!window
Draw window with a title and a border around the element.
Parameters:
title: The title of the window.content: The element to be wrapped.
See also: border
Example
Output
┌Title──┐
│content│
└───────┘Examples: component/homescreen, component/menu_multiple, component/print_key_press, dom/color_truecolor_RGB, dom/hflow, dom/package_manager, dom/size
xflex
Expand/Minimize if possible/needed on the X axis.
Examples: component/gallery, component/slider_rgb
xflex_grow
Element xflex_grow(Element);Expand if possible on the X axis.
xflex_shrink
Element xflex_shrink(Element);Minimize if needed on the X axis.
yflex
Expand/Minimize if possible/needed on the Y axis.
yflex_grow
Element yflex_grow(Element);Expand if possible on the Y axis.
yflex_shrink
Element yflex_shrink(Element);Minimize if needed on the Y axis.