Module ftxui/dom
Classes & Structs
| Class | Description |
|---|---|
ftxui::Canvas | Canvas is a drawable buffer associated with drawing operations. |
ftxui::FlexboxConfig | FlexboxConfig is a configuration structure that defines the layout properties for a flexbox container. |
ftxui::LinearGradient | A class representing the settings for linear-gradient color effect. |
ftxui::LinearGradient::Stop | A color stop at an optional normalized position (0.0 to 1.0). |
ftxui::Node | Node is the base class for all elements in the DOM tree. |
ftxui::Requirement | Requirement is a structure that defines the layout requirements for a Node in the terminal user interface. |
ftxui::Selection | Represents a selection in a terminal user interface. |
ftxui::Table | Table is a utility to draw tables. |
ftxui::TableSelection | A rectangular subset of a Table that can be decorated as a group. |
Enumerations
BorderStyle
enum BorderStyle { LIGHT, DASHED, HEAVY, DOUBLE, ROUNDED, EMPTY };BorderStyle is an enumeration that represents the different styles of borders that can be applied to elements in the terminal UI.
BorderStyle is an enumeration that represents the different styles of borders that can be applied to elements in the terminal UI. It is used to define the visual appearance of borders around elements, such as windows, frames, or separators.
Constraint
enum Constraint { LESS_THAN, EQUAL, GREATER_THAN };Direction
enum Direction { Up, Down, Left, Right };Direction is an enumeration that represents the four cardinal directions.
Examples: component/flexbox_gallery, component/resizable_split_clamp, component/scrollbar, component/slider_direction
WidthOrHeight
enum WidthOrHeight { WIDTH, HEIGHT };Type Aliases
Decorator
Examples: component/focus_cursor
Elements
Examples: component/focus, component/homescreen, component/print_key_press, component/terminal_info, 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. |
automerge | Enable character to be automatically merged with others nearby. |
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. |
borderDashed | Draw a dashed border around the element. |
borderDouble | Draw a double border around the element. |
borderEmpty | Draw an empty 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 Cell around the element. |
canvas | Produce an element from a Canvas, or a reference to a Canvas. |
center | Center an element horizontally and vertically. |
clear_under | Before drawing child, clear the cells below. This is useful in combination with dbox. |
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. |
Fit | The minimal dimension that will fit the given element. |
emptyElement | An element of size 0x0 drawing nothing. |
filler | An element that will expand proportionally to the space left in a container. |
flex | Make a child element to expand proportionally to the space left in a container. |
flex_factor | Set custom grow and shrink flex factors on both axes. |
flex_grow | Expand if possible. |
flex_grow_factor | Set a custom grow flex factor on both axes. |
flex_shrink | Minimize if needed. |
flex_shrink_factor | Set a custom shrink flex factor on both axes. |
flexbox | A container displaying elements on row/columns and capable of wrapping on the next column/row when full. |
focus | Set the child to be the one focused among its siblings. |
focusCursorBar | Same as focus, but set the cursor shape to be a still block. |
focusCursorBarBlinking | Same as focus, but set the cursor shape to be a blinking bar. |
focusCursorBlock | Same as focus, but set the cursor shape to be a still block. |
focusCursorBlockBlinking | Same as focus, but set the cursor shape to be a blinking block. |
focusCursorUnderline | Same as focus, but set the cursor shape to be a still underline. |
focusCursorUnderlineBlinking | Same as focus, but set the cursor shape to be a blinking underline. |
focusPosition | Used inside a frame, this force the view to be scrolled toward a a given position. The position is expressed in the numbers of cells. |
focusPositionRelative | Used inside a frame, this force the view to be scrolled toward a a given position. The position is expressed in proportion of the requested size. |
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. |
gaugeCharset | Draw a high definition progress bar using a custom charset. |
gaugeDirection | Draw a high definition progress bar progressing in specified direction. |
gaugeDown | Draw a high definition progress bar progressing from top to bottom. |
gaugeLeft | Draw a high definition progress bar progressing from right to left. |
gaugeRight | Draw a high definition progress bar progressing from left to right. |
gaugeUp | Draw a high definition progress bar progressing from bottom to top. |
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 in rows from left to right. When filled, it starts on a new row below. |
hscroll_indicator | Display a horizontal scrollbar at the bottom. The background follows the content, the rest follows the parent. |
hyperlink | Make the rendered area clickable using a web browser. The link will be opened when the user clicks on it. This is supported only on a limited set of terminal emulators. List: https://github.com/Alhadis/OSC8-Adoption/. |
inverted | Add a filter that will invert the foreground and the background colors. |
italic | Render text in italics. |
notflex | Make the element not flexible. |
nothing | A decoration doing absolutely nothing. |
operator| | Compose two decorator into one. |
operator|= | Apply a decorator to an element. |
paragraph | Return an element drawing the paragraph on multiple lines. |
paragraphAlignCenter | Return an element drawing the paragraph on multiple lines, aligned on the center. |
paragraphAlignJustify | Return an element drawing the paragraph on multiple lines, aligned using a justified alignment. the center. |
paragraphAlignLeft | Return an element drawing the paragraph on multiple lines, aligned on the left. |
paragraphAlignRight | Return an element drawing the paragraph on multiple lines, aligned on the right. |
reflect | Record the element's final rendered bounding Box into box. |
Render | Display an element on a ftxui::Screen. |
select | Set the child to be the one focused among its siblings. |
selectionBackgroundColor | Set the background color of an element when selected. Note that the style is applied on top of the existing style. |
selectionColor | Set the color of an element when selected. |
selectionForegroundColor | Set the foreground color of an element when selected. Note that the style is applied on top of the existing style. |
selectionStyle | Set the style of an element when selected. |
selectionStyleReset | Reset the selection style of an element. |
separator | Draw a vertical or horizontal separation in between two other elements. |
separatorCharacter | Draw a vertical or horizontal separation in between two other elements. |
separatorDashed | Draw a vertical or horizontal separation in between two other elements, using the DASHED style. |
separatorDouble | Draw a vertical or horizontal separation in between two other elements, using the DOUBLE style. |
separatorEmpty | Draw a vertical or horizontal separation in between two other elements, using the EMPTY style. |
separatorHeavy | Draw a vertical or horizontal separation in between two other elements, using the HEAVY style. |
separatorHSelector | Draw a horizontal bar, with the area in between left/right colored differently. |
separatorLight | Draw a vertical or horizontal separation in between two other elements, using the LIGHT style. |
separatorStyled | Draw a vertical or horizontal separation in between two other elements. |
separatorVSelector | Draw an vertical bar, with the area in between up/downcolored differently. |
size | Apply a constraint on the size of an element. |
spinner | Useful to represent the effect of time and/or events. This displays an ASCII art "video". |
strikethrough | Apply a strikethrough to text. |
text | Display a piece of UTF8 encoded unicode text. |
underlined | Underline the given element. |
underlinedDouble | Apply a underlinedDouble to text. |
vbox | A container displaying elements vertically one by one. |
vcenter | Center an element vertically. |
vflow | A container displaying elements in rows from top to bottom. When filled, it starts on a new columns on the right. filled, it starts on a new row. is full, it starts a new row. |
vscroll_indicator | Display a vertical scrollbar on the right. The background follows the content, the rest follows the parent. |
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_factor | Set custom grow and shrink flex factors on the X axis. |
xflex_grow | Expand if possible on the X axis. |
xflex_grow_factor | Set a custom grow flex factor on the X axis. |
xflex_shrink | Minimize if needed on the X axis. |
xflex_shrink_factor | Set a custom shrink flex factor on the X axis. |
xframe | Same as frame, but only on the x-axis. |
yflex | Expand/Minimize if possible/needed on the Y axis. |
yflex_factor | Set custom grow and shrink flex factors on the Y axis. |
yflex_grow | Expand if possible on the Y axis. |
yflex_grow_factor | Set a custom grow flex factor on the Y axis. |
yflex_shrink | Minimize if needed on the Y axis. |
yflex_shrink_factor | Set a custom shrink flex factor on the Y axis. |
yframe | Same as frame, but only 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.
Examples: dom/table
automerge
Enable character to be automatically merged with others nearby.
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/dropdown_custom, component/flexbox_gallery, component/focus, component/homescreen, component/input_style, component/linear_gradient_gallery, component/menu_entries_animated, component/menu_style, component/slider_rgb, component/terminal_info, dom/color_gallery, dom/color_info_palette256 (+5 more)
bgcolor
Decorate using a background color.
Parameters:
color: The background color to be applied.
Returns: The Decorator applying the color.
Example
Examples: component/dropdown_custom, component/flexbox_gallery, component/focus, component/homescreen, component/input_style, component/linear_gradient_gallery, component/menu_entries_animated, component/menu_style, component/slider_rgb, component/terminal_info, dom/color_gallery, dom/color_info_palette256 (+5 more)
bgcolor
Element bgcolor(const LinearGradient &, Element);Set the background color of an element with linear-gradient effect.
Parameters:
gradient: The gradient effect to be applied on the output element.child: The input element.
Returns: The output element colored.
Example
bgcolor(LinearGradient{0, {Color::Red, Color::Blue}}, text("Hello"))Examples: component/dropdown_custom, component/flexbox_gallery, component/focus, component/homescreen, component/input_style, component/linear_gradient_gallery, component/menu_entries_animated, component/menu_style, component/slider_rgb, component/terminal_info, dom/color_gallery, dom/color_info_palette256 (+5 more)
bgcolor
Decorator bgcolor(const LinearGradient &);Decorate using a linear-gradient effect on the background color.
Parameters:
gradient: The gradient effect to be applied on the output element.
Returns: The Decorator applying the color.
Example
text("Hello") | color(LinearGradient{0, {Color::Red, Color::Blue}})Examples: component/dropdown_custom, component/flexbox_gallery, component/focus, component/homescreen, component/input_style, component/linear_gradient_gallery, component/menu_entries_animated, component/menu_style, component/slider_rgb, component/terminal_info, dom/color_gallery, dom/color_info_palette256 (+5 more)
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/button, component/canvas_animated, component/dropdown_custom, component/flexbox_gallery, component/homescreen, component/menu2, component/menu_entries, component/menu_style, component/modal_dialog_custom, component/renderer, dom/hflow, dom/html_like (+7 more)
border
Draw a border around the element.
See also: border, borderLight, borderDashed, borderDouble, borderHeavy, borderEmpty, borderRounded, borderStyled, borderWith
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/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/checkbox_in_frame, component/composition, component/custom_loop, component/flexbox_gallery, component/focus, component/gallery, component/homescreen (+36 more)
borderDashed
Element borderDashed(Element);Draw a dashed border around the element.
See also: border, borderLight, borderDashed, borderDouble, borderHeavy, borderRounded, borderEmpty, borderStyled, borderWith
Add a border around an element
Example
// Use 'borderDash' as a function...
Element document = borderDash(text("The element"));
// ...Or as a 'pipe'.
Element document = text("The element") | borderDAsh;Output
┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓
╏The element ╏
┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛Examples: dom/border_style, dom/separator_style
borderDouble
Element borderDouble(Element);Draw a double border around the element.
See also: border, borderLight, borderDashed, borderDouble, borderHeavy, borderRounded, borderEmpty, 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: component/input_style, component/menu_style, dom/border_style, dom/separator_style
borderEmpty
Element borderEmpty(Element);Draw an empty border around the element.
See also: border, borderLight, borderDashed, borderDouble, borderHeavy, borderRounded, borderEmpty, 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 elementExamples: component/button, component/dropdown_custom, component/input_style, component/menu_underline_animated_gallery, component/with_restored_io
borderHeavy
Element borderHeavy(Element);Draw a heavy border around the element.
See also: border, borderLight, borderDashed, borderDouble, borderHeavy, borderRounded, borderEmpty, 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, borderDashed, borderDouble, borderHeavy, borderRounded, borderEmpty, 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, borderDashed, borderDouble, borderHeavy, borderRounded, borderEmpty, 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: component/input_style, dom/border_style
borderStyled
Same as border but with different styles.
See also: border
Examples: component/print_above, dom/border_colored
borderStyled
Decorator borderStyled(Color);Same as border but with a foreground color.
See also: border
Examples: component/print_above, dom/border_colored
borderStyled
Same as border but with a foreground color and a different style.
See also: border
Examples: component/print_above, dom/border_colored
borderWith
Decorator borderWith(const Cell &);Same as border but with a constant Cell around the element.
See also: border
canvas
Produce an element from a Canvas, or a reference to a Canvas.
Examples: component/canvas_animated, dom/canvas
canvas
Produce an element drawing a canvas of requested size.
Parameters:
width: the width of the canvas.height: the height of the canvas.fn: a function drawing the canvas.
Examples: component/canvas_animated, dom/canvas
canvas
Produce an element drawing a canvas.
Parameters:
fn: a function drawing the canvas.
Examples: component/canvas_animated, dom/canvas
center
Center an element horizontally and vertically.
Parameters:
child: The decorated element.
Returns: The centered element.
Examples: component/button, component/flexbox_gallery, component/focus, component/homescreen, component/input_style, component/linear_gradient_gallery, component/modal_dialog, component/modal_dialog_custom, component/renderer, component/resizable_split, component/resizable_split_clamp, component/with_restored_io (+5 more)
clear_under
Element clear_under(Element element);Before drawing child, clear the cells below. This is useful in combination with dbox.
See also: ftxui::dbox
Examples: component/modal_dialog_custom
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/flexbox_gallery, component/homescreen, component/input_style, component/linear_gradient_gallery, component/maybe, component/menu_entries, component/menu_style, component/renderer, component/terminal_info, dom/border_colored, dom/color_gallery, dom/color_truecolor_HSV (+6 more)
color
Decorate using a foreground color.
Parameters:
c: The foreground color to be applied.
Returns: The Decorator applying the color.
Example
Examples: component/flexbox_gallery, component/homescreen, component/input_style, component/linear_gradient_gallery, component/maybe, component/menu_entries, component/menu_style, component/renderer, component/terminal_info, dom/border_colored, dom/color_gallery, dom/color_truecolor_HSV (+6 more)
color
Element color(const LinearGradient &, Element);Set the foreground color of an element with linear-gradient effect.
Parameters:
gradient: The gradient effect to be applied on the output element.child: The input element.
Returns: The output element colored.
Example
color(LinearGradient{0, {Color::Red, Color::Blue}}, text("Hello"))Examples: component/flexbox_gallery, component/homescreen, component/input_style, component/linear_gradient_gallery, component/maybe, component/menu_entries, component/menu_style, component/renderer, component/terminal_info, dom/border_colored, dom/color_gallery, dom/color_truecolor_HSV (+6 more)
color
Decorator color(const LinearGradient &);Decorate using a linear-gradient effect on the foreground color.
Parameters:
gradient: The gradient effect to be applied on the output element.
Returns: The Decorator applying the color.
Example
text("Hello") | color(LinearGradient{0, {Color::Red, Color::Blue}})Examples: component/flexbox_gallery, component/homescreen, component/input_style, component/linear_gradient_gallery, component/maybe, component/menu_entries, component/menu_style, component/renderer, component/terminal_info, dom/border_colored, dom/color_gallery, dom/color_truecolor_HSV (+6 more)
dbox
Stack several element on top of each other.
Parameters:
children_: The input elements.
Returns: The right aligned element.
Examples: component/modal_dialog_custom, dom/dbox
dim
Use a light font, for elements with less emphasis.
Examples: component/flexbox_gallery, component/homescreen, component/input_style, component/menu_style, component/print_above, component/terminal_info, dom/hflow, dom/html_like, dom/package_manager, dom/size, dom/style_dim, dom/style_gallery (+1 more)
Fit
Dimensions Fit(Element &, bool extend_beyond_screen = false);The minimal dimension that will fit the given element.
Examples: dom/border, dom/border_colored, dom/border_style, dom/canvas, dom/color_gallery, dom/color_info_palette256, dom/color_truecolor_HSV, dom/color_truecolor_RGB, dom/dbox, dom/graph, dom/gridbox, dom/hflow (+20 more)
emptyElement
Element emptyElement();An element of size 0x0 drawing nothing.
filler
An element that will expand proportionally to the space left in a container.
Examples: component/dropdown_custom, component/flexbox_gallery, component/homescreen, component/menu_style, component/modal_dialog_custom, component/with_restored_io, dom/gauge_direction, dom/package_manager, dom/paragraph, dom/spinner, dom/style_color, dom/vbox_hbox
flex
Make a child element to expand proportionally to the space left in a container.
Examples:
Output:
┌────┐┌─────────────────────────────────────────────────────────┐┌─────┐
│left││middle ││right│
└────┘└─────────────────────────────────────────────────────────┘└─────┘Examples: component/button, component/flexbox_gallery, component/focus, component/homescreen, component/linear_gradient_gallery, component/menu_multiple, component/menu_style, component/resizable_split_clamp, component/scrollbar, component/terminal_info, component/textarea, dom/gauge (+2 more)
flex_factor
Decorator flex_factor(int grow, int shrink);Set custom grow and shrink flex factors on both axes.
flex_grow
Expand if possible.
Examples: component/homescreen
flex_grow_factor
Decorator flex_grow_factor(int grow);Set a custom grow flex factor on both axes.
flex_shrink
Element flex_shrink(Element);Minimize if needed.
flex_shrink_factor
Decorator flex_shrink_factor(int shrink);Set a custom shrink flex factor on both axes.
flexbox
Element flexbox(Elements, FlexboxConfig config = FlexboxConfig());A container displaying elements on row/columns and capable of wrapping on the next column/row when full.
Parameters:
children: The elements in the containerconfig: The option
Returns: The container.
Example
flexbox({
text("element 1"),
text("element 2"),
text("element 3"),
}, FlexboxConfig()
.Set(FlexboxConfig::Direction::Column)
.Set(FlexboxConfig::Wrap::WrapInversed)
.SetGapMainAxis(1)
.SetGapCrossAxis(1)
)Examples: component/flexbox_gallery, component/homescreen
focus
Set the child to be the one focused among its siblings.
Parameters:
child: The element to be focused.
Examples: component/focus_cursor
focusCursorBar
Element focusCursorBar(Element);Same as focus, but set the cursor shape to be a still block.
See also: focus, focusCursorBlock, focusCursorBlockBlinking, focusCursorBar, focusCursorBarBlinking, focusCursorUnderline, focusCursorUnderlineBlinking
Examples: component/focus_cursor
focusCursorBarBlinking
Same as focus, but set the cursor shape to be a blinking bar.
See also: focus, focusCursorBlock, focusCursorBlockBlinking, focusCursorBar, focusCursorBarBlinking, focusCursorUnderline, focusCursorUnderlineBlinking
Examples: component/focus_cursor
focusCursorBlock
Same as focus, but set the cursor shape to be a still block.
See also: focus, focusCursorBlock, focusCursorBlockBlinking, focusCursorBar, focusCursorBarBlinking, focusCursorUnderline, focusCursorUnderlineBlinking
Examples: component/focus_cursor
focusCursorBlockBlinking
Same as focus, but set the cursor shape to be a blinking block.
See also: focus, focusCursorBlock, focusCursorBlockBlinking, focusCursorBar, focusCursorBarBlinking, focusCursorUnderline, focusCursorUnderlineBlinking
Examples: component/focus_cursor
focusCursorUnderline
Same as focus, but set the cursor shape to be a still underline.
See also: focus, focusCursorBlock, focusCursorBlockBlinking, focusCursorBar, focusCursorBarBlinking, focusCursorUnderline, focusCursorUnderlineBlinking
Examples: component/focus_cursor
focusCursorUnderlineBlinking
Same as focus, but set the cursor shape to be a blinking underline.
See also: focus, focusCursorBlock, focusCursorBlockBlinking, focusCursorBar, focusCursorBarBlinking, focusCursorUnderline, focusCursorUnderlineBlinking
Examples: component/focus_cursor
focusPosition
Decorator focusPosition(int x, int y);Used inside a frame, this force the view to be scrolled toward a a given position. The position is expressed in the numbers of cells.
Example
Element document = huge_document()
| focusPosition(10, 10)
| frame;focusPositionRelative
Decorator focusPositionRelative(float x, float y);Used inside a frame, this force the view to be scrolled toward a a given position. The position is expressed in proportion of the requested size.
For instance:
- (0, 0) means that the view is scrolled toward the upper left.
- (1, 0) means that the view is scrolled toward the upper right.
- (0, 1) means that the view is scrolled toward the bottom left.
Example
Element document = huge_document()
| focusPositionRelative(0.f, 1.f)
| frame;Examples: component/focus, component/scrollbar
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: frame, xframe, yframe
Examples: component/button_in_frame, component/checkbox_in_frame, component/dropdown_custom, component/focus, component/homescreen, component/input_in_frame, component/menu_entries, component/menu_entries_animated, component/menu_in_frame, component/menu_in_frame_horizontal, component/radiobox_in_frame, component/scrollbar (+1 more)
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_animated, component/homescreen, component/menu2, component/terminal_info, dom/gauge, dom/package_manager
gaugeCharset
Element gaugeCharset(float progress, std::vector< std::string > charset, Direction direction = Direction::Right);Draw a high definition progress bar using a custom charset.
Parameters:
progress: The proportion of the area to be filled. Belong to [0,1].charset: Glyphs from "empty" (index 0) to "full" (last index); a 2-entry charset gives a plain unshaded bar.direction: Direction of progress bars progression. Defaults to Right.
ExampleA gauge rendered with a custom charset instead of the default block characters.
border(gaugeCharset(0.5, {".", "#"}))Output
┌──────────────────────────────────────────────────────────────────────────┐
│#####################################.....................................│
└──────────────────────────────────────────────────────────────────────────┘gaugeDirection
Element gaugeDirection(float progress, Direction direction);Draw a high definition progress bar progressing in specified direction.
Parameters:
progress: The proportion of the area to be filled. Belong to [0,1].direction: Direction of progress bars progression.
gaugeDown
Draw a high definition progress bar progressing from top to bottom.
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: dom/gauge_direction
gaugeLeft
Draw a high definition progress bar progressing from right to left.
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: dom/gauge_direction
gaugeRight
Element gaugeRight(float progress);Draw a high definition progress bar progressing from left to right.
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.
border(gaugeRight(0.5))Output
┌──────────────────────────────────────────────────────────────────────────┐
│█████████████████████████████████████ │
└──────────────────────────────────────────────────────────────────────────┘Examples: dom/gauge_direction
gaugeUp
Draw a high definition progress bar progressing from bottom to top.
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: dom/gauge_direction
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
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: component/focus, dom/gridbox
hbox
A container displaying elements horizontally one by one.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: component/button_in_frame, component/canvas_animated, component/collapsible, component/flexbox_gallery, component/focus_cursor, component/gallery, component/homescreen, component/input, component/input_style, component/menu2, component/menu_entries, component/menu_entries_animated (+36 more)
hcenter
Center an element horizontally.
Parameters:
child: The decorated element.
Returns: The centered element.
Examples: component/flexbox_gallery, component/homescreen, component/menu2, component/menu_style, dom/hflow, dom/size, dom/vflow
hflow
A container displaying elements in rows from left to right. When filled, it starts on a new row below.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: component/homescreen, dom/hflow, dom/html_like, dom/paragraph
hscroll_indicator
Display a horizontal scrollbar at the bottom. The background follows the content, the rest follows the parent.
Examples: component/menu_in_frame_horizontal
hyperlink
Make the rendered area clickable using a web browser. The link will be opened when the user clicks on it. This is supported only on a limited set of terminal emulators. List: https://github.com/Alhadis/OSC8-Adoption/.
Parameters:
link: The linkchild: The input element.
Returns: The output element with the link.
Example
Examples: dom/style_gallery, dom/style_hyperlink
hyperlink
Decorate using a hyperlink. The link will be opened when the user clicks on it. This is supported only on a limited set of terminal emulators. List: https://github.com/Alhadis/OSC8-Adoption/.
Parameters:
link: The link to redirect the users to.
Returns: The Decorator applying the hyperlink.
Example
Examples: dom/style_gallery, dom/style_hyperlink
inverted
Add a filter that will invert the foreground and the background colors.
Examples: component/dropdown_custom, component/menu_entries, component/menu_underline_animated_gallery, dom/graph, dom/style_gallery, dom/style_inverted
italic
Render text in italics.
Examples: dom/style_gallery, dom/style_italic
notflex
Make the element not flexible.
Examples: component/flexbox_gallery
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:
operator|=
Apply a decorator to an element.
Returns: the decorated element.
ExampleBoth of these are equivalent:
paragraph
Return an element drawing the paragraph on multiple lines.
See also: flexbox
Examples: component/homescreen, component/print_above, component/selection, component/with_restored_io, dom/html_like, dom/paragraph
paragraphAlignCenter
Element paragraphAlignCenter(std::string_view text);Return an element drawing the paragraph on multiple lines, aligned on the center.
See also: flexbox
Examples: component/homescreen
paragraphAlignJustify
Element paragraphAlignJustify(std::string_view text);Return an element drawing the paragraph on multiple lines, aligned using a justified alignment. the center.
See also: flexbox
Examples: component/homescreen
paragraphAlignLeft
Element paragraphAlignLeft(std::string_view text);Return an element drawing the paragraph on multiple lines, aligned on the left.
See also: flexbox
Examples: component/homescreen
paragraphAlignRight
Element paragraphAlignRight(std::string_view text);Return an element drawing the paragraph on multiple lines, aligned on the right.
See also: flexbox
Examples: component/homescreen
reflect
Record the element's final rendered bounding Box into box.
Render
Display an element on a ftxui::Screen.
Examples: component/button, component/button_animated, component/button_in_frame, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/flexbox_gallery, component/focus, component/gallery, component/homescreen, component/input (+62 more)
Render
Display an element on a ftxui::Screen.
Examples: component/button, component/button_animated, component/button_in_frame, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/flexbox_gallery, component/focus, component/gallery, component/homescreen, component/input (+62 more)
select
Set the child to be the one focused among its siblings.
This is deprecated. Use focus instead.
Parameters:
e: The element to be focused.
selectionBackgroundColor
Set the background color of an element when selected. Note that the style is applied on top of the existing style.
Examples: component/selection
selectionColor
Set the color of an element when selected.
Parameters:
foreground: The color to be applied. Note that the style is applied on top of the existing style.
Examples: component/selection
selectionForegroundColor
Set the foreground color of an element when selected. Note that the style is applied on top of the existing style.
selectionStyle
Set the style of an element when selected.
Parameters:
style: The style to be applied. Note that the style is applied on top of the existing style.
Examples: component/selection
selectionStyleReset
Reset the selection style of an element.
Parameters:
child: The input element.
Returns: The output element with the selection style reset.
Examples: component/selection
separator
Draw a vertical or horizontal separation in between two other elements.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separator(),
text("down"),
});Output
up
────
downExamples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/composition, component/custom_loop, component/focus, component/gallery, component/homescreen, component/input, component/input_style (+24 more)
separator
Draw a separator in between two element filled with a given pixel.
See also: separator, separatorLight, separatorDashed, separatorHeavy, separatorDouble, separatorStyled
Example
Output
Up
DownExamples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/canvas_animated, component/composition, component/custom_loop, component/focus, component/gallery, component/homescreen, component/input, component/input_style (+24 more)
separatorCharacter
Element separatorCharacter(std::string_view);Draw a vertical or horizontal separation in between two other elements.
Parameters:
value: the character to fill the separator area.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separator(),
text("down"),
});Output
up
────
downseparatorDashed
Element separatorDashed();Draw a vertical or horizontal separation in between two other elements, using the DASHED style.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separatorLight(),
text("down"),
});Output
up
╍╍╍╍
downExamples: dom/separator_style
separatorDouble
Element separatorDouble();Draw a vertical or horizontal separation in between two other elements, using the DOUBLE style.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separatorDouble(),
text("down"),
});Output
up
════
downExamples: dom/separator_style
separatorEmpty
Element separatorEmpty();Draw a vertical or horizontal separation in between two other elements, using the EMPTY style.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separator(),
text("down"),
});Output
up
downExamples: component/input_style
separatorHeavy
Element separatorHeavy();Draw a vertical or horizontal separation in between two other elements, using the HEAVY style.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separatorHeavy(),
text("down"),
});Output
up
━━━━
downExamples: dom/separator_style
separatorHSelector
Element separatorHSelector(float left, float right, Color unselected_color, Color selected_color);Draw a horizontal bar, with the area in between left/right colored differently.
Parameters:
left: the left limit of the active area.right: the right limit of the active area.selected_color: the color of the selected area.unselected_color: the color of the unselected area.
Example
separatorLight
Element separatorLight();Draw a vertical or horizontal separation in between two other elements, using the LIGHT style.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separatorLight(),
text("down"),
});Output
up
────
downExamples: dom/separator_style
separatorStyled
Draw a vertical or horizontal separation in between two other elements.
Parameters:
style: the style of the separator.
See also: separator, separatorLight, separatorDashed, separatorDouble, separatorHeavy, separatorEmpty, separatorRounded, separatorStyled, separatorCharacter
Add a visual separation in between two elements.
Example
// Use 'border' as a function...
Element document = vbox({
text("up"),
separatorStyled(DOUBLE),
text("down"),
});Output
up
════
downseparatorVSelector
Draw an vertical bar, with the area in between up/downcolored differently.
Parameters:
up: the left limit of the active area.down: the right limit of the active area.selected_color: the color of the selected area.unselected_color: the color of the unselected area.
Example
size
Apply a constraint on the size of an element.
Parameters:
direction: Whether the WIDTH or the HEIGHT of the element must be constrained.constraint: The type of constraint.value: The value.
Examples: component/button_in_frame, component/canvas_animated, component/checkbox_in_frame, component/dropdown_custom, component/flexbox_gallery, component/focus, component/gallery, component/homescreen, component/input, component/input_in_frame, component/menu_entries, component/menu_in_frame (+19 more)
spinner
Useful to represent the effect of time and/or events. This displays 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
strikethrough
Element strikethrough(Element);Apply a strikethrough to text.
Examples: dom/style_gallery, dom/style_strikethrough
text
Display a piece of UTF8 encoded unicode text.
See also: ftxui::to_wstring
Example
Output
Hello world!Examples: component/button, component/button_animated, component/button_in_frame, component/button_style, component/collapsible, component/composition, component/custom_loop, component/dropdown_custom, component/flexbox_gallery, component/focus, component/focus_cursor, component/gallery (+59 more)
underlined
Element underlined(Element);Underline the given element.
Examples: component/canvas_animated, dom/canvas, dom/html_like, dom/style_gallery, dom/style_underlined
underlinedDouble
Apply a underlinedDouble to text.
Examples: dom/style_gallery, dom/style_underlined_double
vbox
A container displaying elements vertically one by one.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: component/button, component/button_animated, component/button_in_frame, component/composition, component/custom_loop, component/dropdown_custom, component/flexbox_gallery, component/focus, component/gallery, component/homescreen, component/input, component/input_style (+38 more)
vcenter
Center an element vertically.
Parameters:
child: The decorated element.
Returns: The centered element.
vflow
A container displaying elements in rows from top to bottom. When filled, it starts on a new columns on the right. filled, it starts on a new row. is full, it starts a new row.
Parameters:
children: The elements in the container
Returns: The container.
Example
Examples: dom/vflow
vscroll_indicator
Display a vertical scrollbar on the right. The background follows the content, the rest follows the parent.
Examples: component/button_in_frame, component/checkbox_in_frame, component/dropdown_custom, component/homescreen, component/input_in_frame, component/menu_in_frame, component/radiobox_in_frame, component/selection
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
!Examples: dom/gauge_direction
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.border: The style of the border. Default is ROUNDED.
See also: border
Example
Element document = window(text("Title"),
text("content")
);
// With specifying border
Element document = window(text("Title"),
text("content"),
ROUNDED
);Output
┌Title──┐
│content│
└───────┘Examples: component/flexbox_gallery, component/homescreen, component/menu_multiple, component/resizable_split_clamp, component/selection, component/terminal_info, dom/color_truecolor_RGB, dom/hflow, dom/package_manager, dom/size, dom/vflow
xflex
Expand/Minimize if possible/needed on the X axis.
Examples: component/gallery, component/slider_rgb
xflex_factor
Decorator xflex_factor(int grow, int shrink);Set custom grow and shrink flex factors on the X axis.
xflex_grow
Element xflex_grow(Element);Expand if possible on the X axis.
Examples: component/flexbox_gallery
xflex_grow_factor
Decorator xflex_grow_factor(int grow);Set a custom grow flex factor on the X axis.
xflex_shrink
Element xflex_shrink(Element);Minimize if needed on the X axis.
xflex_shrink_factor
Decorator xflex_shrink_factor(int shrink);Set a custom shrink flex factor on the X axis.
xframe
Same as frame, but only on the x-axis.
See also: frame, xframe, yframe
yflex
Expand/Minimize if possible/needed on the Y axis.
yflex_factor
Decorator yflex_factor(int grow, int shrink);Set custom grow and shrink flex factors on the Y axis.
yflex_grow
Element yflex_grow(Element);Expand if possible on the Y axis.
Examples: component/flexbox_gallery
yflex_grow_factor
Decorator yflex_grow_factor(int grow);Set a custom grow flex factor on the Y axis.
yflex_shrink
Element yflex_shrink(Element);Minimize if needed on the Y axis.
yflex_shrink_factor
Decorator yflex_shrink_factor(int shrink);Set a custom shrink flex factor on the Y axis.
yframe
Same as frame, but only on the y-axis.
See also: frame, xframe, yframe
Examples: component/homescreen