FTXUI  0.11.1
C++ functional terminal UI.
ftxui Namespace Reference

Functions

template<class T , class... Args>
std::shared_ptr< T > Make (Args &&... args)
 
Component Button (ConstStringRef label, std::function< void()> on_click, Ref< ButtonOption > option)
 Draw a button. Execute a function when clicked. More...
 
Component Checkbox (ConstStringRef label, bool *checked, Ref< CheckboxOption > option)
 Draw checkable element. More...
 
Component Input (StringRef content, ConstStringRef placeholder, Ref< InputOption > option)
 An input box for editing text. More...
 
Component Menu (ConstStringListRef entries, int *selected, Ref< MenuOption > option)
 A list of text. The focused element is selected. More...
 
Component MenuEntry (ConstStringRef label, Ref< MenuEntryOption >={})
 
Component Dropdown (ConstStringListRef entries, int *selected)
 
Component Radiobox (ConstStringListRef entries, int *selected, Ref< RadioboxOption > option)
 A list of element, where only one can be selected. More...
 
Component Toggle (ConstStringListRef entries, int *selected, Ref< ToggleOption > option)
 An horizontal list of elements. The user can navigate through them. More...
 
template<class T >
Component Slider (ConstStringRef label, T *value, T min, T max, T increment)
 An horizontal slider. More...
 
Component ResizableSplitLeft (Component main, Component back, int *main_size)
 An horizontal split in between two components, configurable using the mouse. More...
 
Component ResizableSplitRight (Component main, Component back, int *main_size)
 An horizontal split in between two components, configurable using the mouse. More...
 
Component ResizableSplitTop (Component main, Component back, int *main_size)
 An vertical split in between two components, configurable using the mouse. More...
 
Component ResizableSplitBottom (Component main, Component back, int *main_size)
 An vertical split in between two components, configurable using the mouse. More...
 
Component Renderer (Component child, std::function< Element()> render)
 Return a new Component, similar to |child|, but using |render| as the Component::Render() event. More...
 
Component Renderer (std::function< Element()> render)
 Return a component, using |render| to render its interface. More...
 
Component Renderer (std::function< Element(bool)> render)
 Return a focusable component, using |render| to render its interface. More...
 
Component CatchEvent (Component child, std::function< bool(Event)>)
 
Component Maybe (Component, bool *show)
 
Component Input (WideStringRef content, ConstStringRef placeholder, Ref< InputOption > option)
 . An input box for editing text. More...
 
template<class T >
Receiver< T > MakeReceiver ()
 
Element text (std::wstring text)
 Display a piece of unicode text. More...
 
Element vtext (std::wstring text)
 Display a piece unicode text vertically. More...
 
Elements paragraph (std::wstring text)
 
Element operator| (Element element, Decorator decorator)
 From an element, apply a decorator. More...
 
Elements operator| (Elements elements, Decorator decorator)
 From a set of element, apply a decorator to every elements. More...
 
Decorator operator| (Decorator a, Decorator b)
 Compose two decorator into one. More...
 
Element text (std::string text)
 Display a piece of UTF8 encoded unicode text. More...
 
Element vtext (std::string text)
 Display a piece of unicode text vertically. More...
 
Element separator ()
 Draw a vertical or horizontal separation in between two other elements. More...
 
Element separatorLight ()
 Draw a vertical or horizontal separation in between two other elements, using the LIGHT style. More...
 
Element separatorHeavy ()
 Draw a vertical or horizontal separation in between two other elements, using the HEAVY style. More...
 
Element separatorDouble ()
 Draw a vertical or horizontal separation in between two other elements, using the DOUBLE style. More...
 
Element separatorEmpty ()
 Draw a vertical or horizontal separation in between two other elements, using the EMPTY style. More...
 
Element separatorStyled (BorderStyle style)
 Draw a vertical or horizontal separation in between two other elements. More...
 
Element separator (Pixel pixel)
 Draw a separator in between two element filled with a given pixel. More...
 
Element separatorCharacter (std::string value)
 Draw a vertical or horizontal separation in between two other elements. More...
 
Element gauge (float progress)
 Draw a high definition progress bar. More...
 
Element border (Element child)
 Draw a border around the element. More...
 
Element borderLight (Element child)
 Draw a light border around the element. More...
 
Element borderHeavy (Element child)
 Draw a heavy border around the element. More...
 
Element borderDouble (Element child)
 Draw a double border around the element. More...
 
Element borderRounded (Element child)
 Draw a rounded border around the element. More...
 
Element borderEmpty (Element child)
 Draw an empty border around the element. More...
 
Decorator borderStyled (BorderStyle style)
 Same as border but with different styles. More...
 
Decorator borderWith (Pixel pixel)
 Same as border but with a constant Pixel around the element. More...
 
Element window (Element title, Element content)
 Draw window with a title and a border around the element. More...
 
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". More...
 
Element paragraph (std::string the_text)
 Return an element drawing the paragraph on multiple lines. More...
 
Element paragraphAlignLeft (std::string the_text)
 Return an element drawing the paragraph on multiple lines, aligned on the left. More...
 
Element paragraphAlignRight (std::string the_text)
 Return an element drawing the paragraph on multiple lines, aligned on the right. More...
 
Element paragraphAlignCenter (std::string the_text)
 Return an element drawing the paragraph on multiple lines, aligned on the center. More...
 
Element paragraphAlignJustify (std::string the_text)
 Return an element drawing the paragraph on multiple lines, aligned using a justified alignment. the center. More...
 
Element graph (GraphFunction graph_function)
 Draw a graph using a GraphFunction. More...
 
Element emptyElement ()
 
Element bold (Element child)
 Use a bold font, for elements with more emphasis. More...
 
Element dim (Element child)
 Use a light font, for elements with less emphasis. More...
 
Element inverted (Element child)
 Add a filter that will invert the foreground and the background colors. More...
 
Element underlined (Element child)
 Make the underlined element to be underlined. More...
 
Element blink (Element child)
 The text drawn alternates in between visible and hidden. More...
 
Decorator color (Color c)
 Decorate using a foreground color. More...
 
Decorator bgcolor (Color color)
 Decorate using a background color. More...
 
Element color (Color color, Element child)
 Set the foreground color of an element. More...
 
Element bgcolor (Color color, Element child)
 Set the background color of an element. More...
 
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. More...
 
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. More...
 
Element hbox (Elements children)
 A container displaying elements horizontally one by one. More...
 
Element vbox (Elements children)
 A container displaying elements vertically one by one. More...
 
Element dbox (Elements children_)
 Stack several element on top of each other. More...
 
Element flexbox (Elements, FlexboxConfig config=FlexboxConfig())
 
Element gridbox (std::vector< Elements > lines)
 A container displaying a grid of elements. More...
 
Element hflow (Elements)
 
Element vflow (Elements)
 
Element flex (Element child)
 Make a child element to expand proportionnally to the space left in a container. More...
 
Element flex_grow (Element child)
 Expand if possible. More...
 
Element flex_shrink (Element child)
 Minimize if needed. More...
 
Element xflex (Element child)
 Expand/Minimize if possible/needed on the X axis. More...
 
Element xflex_grow (Element child)
 Expand if possible on the X axis. More...
 
Element xflex_shrink (Element child)
 Minimize if needed on the X axis. More...
 
Element yflex (Element child)
 Expand/Minimize if possible/needed on the Y axis. More...
 
Element yflex_grow (Element child)
 Expand if possible on the Y axis. More...
 
Element yflex_shrink (Element child)
 Minimize if needed on the Y axis. More...
 
Element notflex (Element child)
 Make the element not flexible. More...
 
Element filler ()
 An element that will take expand proportionnally to the space left in a container. More...
 
Decorator size (Direction direction, Constraint constraint, int value)
 Apply a constraint on the size of an element. More...
 
Decorator reflect (Box &box)
 
Element frame (Element child)
 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. More...
 
Element xframe (Element)
 
Element yframe (Element)
 
Element focus (Element)
 
Element select (Element)
 
Element vscroll_indicator (Element child)
 Add a filter that will invert the foreground and the background colors. More...
 
Element hcenter (Element child)
 Center an element horizontally. More...
 
Element vcenter (Element child)
 Center an element vertically. More...
 
Element center (Element child)
 Center an element horizontally and vertically. More...
 
Element align_right (Element child)
 Align an element on the right side. More...
 
Element nothing (Element element)
 A decoration doing absolutely nothing. More...
 
Element clear_under (Element child)
 Before drawing |child|, clear the pixels below. This is useful in. More...
 
void Render (Screen &screen, const Element &element)
 Display an element on a ftxui::Screen. More...
 
void Render (Screen &screen, Node *node)
 Display an element on a ftxui::Screen. More...
 
Color operator""_rgb (unsigned long long int combined)
 Creates a color from a combined hex RGB representation, e.g. 0x808000_rgb. More...
 
ColorInfo GetColorInfo (Color::Palette256 index)
 
ColorInfo GetColorInfo (Color::Palette16 index)
 
int wchar_width (wchar_t)
 
int wstring_width (const std::wstring &)
 
std::string to_string (const std::wstring &s)
 Convert a UTF8 std::string into a std::wstring. More...
 
std::wstring to_wstring (const std::string &s)
 Convert a std::wstring into a UTF8 std::string. More...
 
template<typename T >
std::wstring to_wstring (T s)
 
int string_width (const std::string &)
 
std::vector< std::string > Utf8ToGlyphs (const std::string &input)
 
int GlyphPosition (const std::string &input, size_t glyph_index, size_t start=0)
 
int GlyphCount (const std::string &input)
 
std::vector< int > CellToGlyphIndex (const std::string &input)
 
Component CatchEvent (Component child, std::function< bool(Event event)> on_event)
 Return a component, using |on_event| to catch events. This function must returns true when the event has been handled, false otherwise. More...
 
template Component Slider (ConstStringRef label, int *value, int min, int max, int increment)
 
template Component Slider (ConstStringRef label, float *value, float min, float max, float increment)
 
template Component Slider (ConstStringRef label, long *value, long min, long max, long increment)
 

Enumerations

enum  BorderStyle {
  LIGHT , HEAVY , DOUBLE , ROUNDED ,
  EMPTY
}
 
enum  Direction { WIDTH , HEIGHT }
 
enum  Constraint { LESS_THAN , EQUAL , GREATER_THAN }
 

Typedefs

using CapturedMouse = std::unique_ptr< CapturedMouseInterface >
 
using Component = std::shared_ptr< ComponentBase >
 
using Components = std::vector< Component >
 
template<class T >
using Sender = std::unique_ptr< SenderImpl< T > >
 
template<class T >
using Receiver = std::unique_ptr< ReceiverImpl< T > >
 
using Element = std::shared_ptr< Node >
 
using Elements = std::vector< Element >
 
using Decorator = std::function< Element(Element)>
 
using GraphFunction = std::function< std::vector< int >(int, int)>
 

Data Structures

class  CapturedMouseInterface
 
class  ComponentBase
 It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event. More...
 
struct  MenuOption
 Option for the Menu component. More...
 
struct  MenuEntryOption
 Option for the MenuEntry component. More...
 
struct  ButtonOption
 Option for the Button component. More...
 
struct  CheckboxOption
 Option for the Checkbox component. More...
 
struct  InputOption
 Option for the Input component. More...
 
struct  RadioboxOption
 Option for the Radiobox component. More...
 
struct  ToggleOption
 Option for the Toggle component. More...
 
struct  Event
 Represent an event. It can be key press event, a terminal resize, or more ... More...
 
struct  Mouse
 A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift, ctrl, meta). More...
 
class  SenderImpl
 
class  ReceiverImpl
 
class  ScreenInteractive
 
struct  FlexboxConfig
 
class  Node
 
struct  Requirement
 
class  Table
 
class  TableSelection
 
struct  Box
 
class  Color
 A class representing terminal colors. More...
 
struct  ColorInfo
 
struct  Pixel
 A unicode character and its associated style. More...
 
class  Screen
 A rectangular grid of Pixel. More...
 
struct  Dimensions
 
class  AutoReset
 Assign a value to a variable, reset its old value when going out of scope. More...
 
class  ConstRef
 An adapter. Own or reference an immutable object. More...
 
class  Ref
 An adapter. Own or reference an mutable object. More...
 
class  StringRef
 An adapter. Own or reference a constant string. For convenience, this class convert multiple mutable string toward a shared representation. More...
 
class  WideStringRef
 An adapter. Own or reference a constant string. For convenience, this class convert multiple mutable string toward a shared representation. More...
 
class  ConstStringRef
 An adapter. Own or reference a constant string. For convenience, this class convert multiple immutable string toward a shared representation. More...
 
class  ConstStringListRef
 An adapter. Reference a list of strings. More...
 
class  TerminalInputParser
 
class  NodeDecorator
 

Namespaces

 box_helper
 
 Container
 
 Dimension
 Define how the Screen's dimensions should look like.
 
 flexbox_helper
 
 literals
 
 Terminal
 

Variables

const ColorInfo palette256 []
 

Data Structure Documentation

◆ ftxui::MenuOption

struct ftxui::MenuOption

Option for the Menu component.

Definition at line 11 of file component_options.hpp.

Data Fields
Decorator style_normal style.
Decorator style_focused Style when focused.
Decorator style_selected Style when selected.
Decorator style_selected_focused Style when selected and focused.
function< void()> on_change Called when the selected entry changes.
function< void()> on_enter Called when the user presses enter.
Ref< int > focused_entry

◆ ftxui::MenuEntryOption

struct ftxui::MenuEntryOption

Option for the MenuEntry component.

Definition at line 28 of file component_options.hpp.

Data Fields
Decorator style_normal style.
Decorator style_focused Style when focused.
Decorator style_selected Style when selected.
Decorator style_selected_focused Style when selected and focused.

◆ ftxui::ButtonOption

struct ftxui::ButtonOption

Option for the Button component.

Definition at line 38 of file component_options.hpp.

Data Fields
bool border Whether to show a border around the button.

◆ ftxui::CheckboxOption

struct ftxui::CheckboxOption

Option for the Checkbox component.

Definition at line 45 of file component_options.hpp.

Data Fields
string style_checked Prefix for a "checked" state.
string style_unchecked Prefix for a "unchecked" state.
Decorator style_normal style.
Decorator style_focused Style when focused.
Decorator style_selected Style when selected.
Decorator style_selected_focused Style when selected and focused.
function< void()> on_change Called when the user change the state.

◆ ftxui::InputOption

struct ftxui::InputOption

Option for the Input component.

Definition at line 60 of file component_options.hpp.

Data Fields
function< void()> on_change Called when the content changes.
function< void()> on_enter Called when the user presses enter.
Ref< bool > password Obscure the input content using '*'.
Ref< int > cursor_position

When set different from -1, this attributes is used to store the cursor position.

◆ ftxui::RadioboxOption

struct ftxui::RadioboxOption

Option for the Radiobox component.

Definition at line 76 of file component_options.hpp.

Data Fields
string style_checked Prefix for a "checked" state.
string style_unchecked Prefix for a "unchecked" state.
Decorator style_normal style.
Decorator style_focused Style when focused.
Decorator style_selected Style when selected.
Decorator style_selected_focused Style when selected and focused.
function< void()> on_change Called when the selected entry changes.
Ref< int > focused_entry

◆ ftxui::ToggleOption

struct ftxui::ToggleOption

Option for the Toggle component.

Definition at line 93 of file component_options.hpp.

Data Fields
Decorator style_normal style.
Decorator style_focused Style when focused.
Decorator style_selected Style when selected.
Decorator style_selected_focused Style when selected and focused.
function< void()> on_change Called when the selected entry changes.
function< void()> on_enter Called when the user presses enter.
Ref< int > focused_entry

◆ ftxui::ColorInfo

struct ftxui::ColorInfo

Definition at line 9 of file color_info.hpp.

Data Fields
const char * name
uint8_t index_256
uint8_t index_16
uint8_t red
uint8_t green
uint8_t blue
uint8_t hue
uint8_t saturation
uint8_t value

◆ ftxui::Dimensions

struct ftxui::Dimensions

Definition at line 5 of file terminal.hpp.

Data Fields
int dimx
int dimy

Typedef Documentation

◆ CapturedMouse

using CapturedMouse = std::unique_ptr<CapturedMouseInterface>

Definition at line 11 of file captured_mouse.hpp.

◆ Component

◆ Components

using Components = std::vector<Component>

Definition at line 18 of file component_base.hpp.

◆ Sender

using Sender = std::unique_ptr<SenderImpl<T> >

Definition at line 44 of file receiver.hpp.

◆ Receiver

using Receiver = std::unique_ptr<ReceiverImpl<T> >

Definition at line 45 of file receiver.hpp.

◆ Element

◆ Elements

◆ Decorator

using Decorator = std::function<Element(Element)>
Examples
examples/component/menu_entries.cpp.

Definition at line 18 of file elements.hpp.

◆ GraphFunction

using GraphFunction = std::function<std::vector<int>(int, int)>

Definition at line 19 of file elements.hpp.

Enumeration Type Documentation

◆ BorderStyle

Enumerator
LIGHT 
HEAVY 
DOUBLE 
ROUNDED 
EMPTY 

Definition at line 21 of file elements.hpp.

◆ Direction

enum Direction
Enumerator
WIDTH 
HEIGHT 

Definition at line 104 of file elements.hpp.

◆ Constraint

enum Constraint
Enumerator
LESS_THAN 
EQUAL 
GREATER_THAN 

Definition at line 105 of file elements.hpp.

Function Documentation

◆ Make()

std::shared_ptr<T> ftxui::Make ( Args &&...  args)

Definition at line 25 of file component.hpp.

◆ Button()

Component Button ( ConstStringRef  label,
std::function< void()>  on_click,
Ref< ButtonOption option 
)

Draw a button. Execute a function when clicked.

Parameters
labelThe label of the button.
on_clickThe action to execute when clicked.
optionAdditional optional parameters.
See also
ButtonBase

Example

std::string label = "Click to quit";
Component button = Button(&label, screen.ExitLoopClosure());
screen.Loop(button)
static ScreenInteractive FitComponent()
std::shared_ptr< ComponentBase > Component
Component Button(ConstStringRef label, std::function< void()> on_click, Ref< ButtonOption >={})
Draw a button. Execute a function when clicked.
Definition: button.cpp:90

Output

┌─────────────┐
│Click to quit│
└─────────────┘
Examples
examples/component/button.cpp, examples/component/composition.cpp, examples/component/gallery.cpp, examples/component/modal_dialog.cpp, examples/component/nested_screen.cpp, and examples/component/renderer.cpp.

Definition at line 90 of file button.cpp.

◆ Checkbox()

Component Checkbox ( ConstStringRef  label,
bool *  checked,
Ref< CheckboxOption option 
)

Draw checkable element.

Parameters
labelThe label of the checkbox.
checkedWhether the checkbox is checked or not.
optionAdditional optional parameters.
See also
CheckboxBase

Example

std::string label = "Make a sandwidth";
bool checked = false;
Component checkbox = Checkbox(&label, &checked);
screen.Loop(checkbox)
Component Checkbox(ConstStringRef label, bool *checked, Ref< CheckboxOption > option={})
Draw checkable element.
Definition: checkbox.cpp:117

Output

☐ Make a sandwitch
Examples
examples/component/checkbox_in_frame.cpp, examples/component/flexbox.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, and examples/component/maybe.cpp.

Definition at line 117 of file checkbox.cpp.

◆ Input() [1/2]

Component Input ( StringRef  content,
ConstStringRef  placeholder,
Ref< InputOption option 
)

An input box for editing text.

Parameters
contentThe editable content.
placeholderThe text displayed when content is still empty.
optionAdditional optional parameters.
See also
InputBase

Example

std::string content= "";
std::string placeholder = "placeholder";
Component input = Input(&content, &placeholder);
screen.Loop(input);
Component Input(StringRef content, ConstStringRef placeholder, Ref< InputOption > option={})
An input box for editing text.
Definition: input.cpp:277

Output

placeholder
Examples
examples/component/checkbox.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, and examples/component/input.cpp.

Definition at line 277 of file input.cpp.

◆ Menu()

Component Menu ( ConstStringListRef  entries,
int *  selected,
Ref< MenuOption option 
)

A list of text. The focused element is selected.

Parameters
entriesThe list of entries in the menu.
selectedThe index of the currently selected element.
optionAdditional optional parameters.
See also
MenuBase

Example

std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Menu(&entries, &selected);
screen.Loop(menu);
static ScreenInteractive TerminalOutput()
Component Menu(ConstStringListRef entries, int *selected_, Ref< MenuOption >={})
A list of text. The focused element is selected.
Definition: menu.cpp:181

Output

> entry 1
entry 2
entry 3
Examples
examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/menu.cpp, examples/component/menu2.cpp, examples/component/menu_in_frame.cpp, examples/component/menu_multiple.cpp, examples/component/menu_style.cpp, and examples/component/tab_vertical.cpp.

Definition at line 181 of file menu.cpp.

◆ MenuEntry()

Component MenuEntry ( ConstStringRef  label,
Ref< MenuEntryOption option = {} 
)
Examples
examples/component/menu_entries.cpp.

Definition at line 187 of file menu.cpp.

◆ Dropdown()

Component Dropdown ( ConstStringListRef  entries,
int *  selected 
)
Examples
examples/component/dropdown.cpp.

Definition at line 14 of file dropdown.cpp.

◆ Radiobox()

Component Radiobox ( ConstStringListRef  entries,
int *  selected,
Ref< RadioboxOption option 
)

A list of element, where only one can be selected.

Parameters
entriesThe list of entries in the list.
selectedThe index of the currently selected element.
optionAdditional optional parameters.
See also
RadioboxBase

Example

std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Radiobox(&entries, &selected);
screen.Loop(menu);
Component Radiobox(ConstStringListRef entries, int *selected_, Ref< RadioboxOption > option={})
A list of element, where only one can be selected.
Definition: radiobox.cpp:198

Output

◉ entry 1
○ entry 2
○ entry 3
Examples
examples/component/flexbox.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/maybe.cpp, examples/component/radiobox.cpp, examples/component/radiobox_in_frame.cpp, examples/component/tab_horizontal.cpp, and examples/component/tab_vertical.cpp.

Definition at line 198 of file radiobox.cpp.

◆ Toggle()

Component Toggle ( ConstStringListRef  entries,
int *  selected,
Ref< ToggleOption option 
)

An horizontal list of elements. The user can navigate through them.

Parameters
entriesThe list of selectable entries to display.
selectedReference the selected entry.
optionAdditional optional parameters.
Examples
examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/tab_horizontal.cpp, and examples/component/toggle.cpp.

Definition at line 126 of file toggle.cpp.

◆ Slider() [1/4]

Component Slider ( ConstStringRef  label,
T *  value,
min,
max,
increment 
)

An horizontal slider.

Parameters
labelThe name of the slider.
valueThe current value of the slider.
minThe minimum value.
maxThe maximum value.
incrementThe increment when used by the cursor.

Example

int value = 50;
auto slider = Slider("Value:", &value, 0, 100, 1);
screen.Loop(slider);
Component Slider(ConstStringRef label, T *value, T min, T max, T increment)
An horizontal slider.
Definition: slider.cpp:123

Output

Value:[██████████████████████████ ]
Examples
examples/component/focus.cpp, examples/component/gallery.cpp, examples/component/slider.cpp, and examples/component/slider_rgb.cpp.

Definition at line 123 of file slider.cpp.

◆ ResizableSplitLeft()

Component ResizableSplitLeft ( Component  main,
Component  back,
int *  main_size 
)

An horizontal split in between two components, configurable using the mouse.

Parameters
mainThe main component of size |main_size|, on the left.
backThe back component taking the remaining size, on the right.
main_sizeThe size of the |main| component.

Example

int left_size = 10;
auto left = Renderer([] { return text("Left") | center;});
auto right = Renderer([] { return text("right") | center;});
auto split = ResizableSplitLeft(left, right, &left_size);
screen.Loop(split);
static ScreenInteractive Fullscreen()
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
Element center(Element)
Center an element horizontally and vertically.
Element text(std::wstring text)
Display a piece of unicode text.
Definition: text.cpp:106
Component ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.

Output

left │ right
Examples
examples/component/homescreen.cpp, and examples/component/resizable_split.cpp.

Definition at line 266 of file resizable_split.cpp.

◆ ResizableSplitRight()

Component ResizableSplitRight ( Component  main,
Component  back,
int *  main_size 
)

An horizontal split in between two components, configurable using the mouse.

Parameters
mainThe main component of size |main_size|, on the right.
backThe back component taking the remaining size, on the left.
main_sizeThe size of the |main| component.

Example

int right_size = 10;
auto left = Renderer([] { return text("Left") | center;});
auto right = Renderer([] { return text("right") | center;});
auto split = ResizableSplitRight(right, left, &right_size);
screen.Loop(split);
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.

Output

left │ right
Examples
examples/component/flexbox.cpp, and examples/component/resizable_split.cpp.

Definition at line 296 of file resizable_split.cpp.

◆ ResizableSplitTop()

Component ResizableSplitTop ( Component  main,
Component  back,
int *  main_size 
)

An vertical split in between two components, configurable using the mouse.

Parameters
mainThe main component of size |main_size|, on the top.
backThe back component taking the remaining size, on the bottom.
main_sizeThe size of the |main| component.

Example

int top_size = 1;
auto top = Renderer([] { return text("Top") | center;});
auto bottom = Renderer([] { return text("Bottom") | center;});
auto split = ResizableSplitTop(top, bottom, &top_size);
screen.Loop(split);
Component ResizableSplitTop(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.

Output

top
────────────
bottom
Examples
examples/component/resizable_split.cpp.

Definition at line 326 of file resizable_split.cpp.

◆ ResizableSplitBottom()

Component ResizableSplitBottom ( Component  main,
Component  back,
int *  main_size 
)

An vertical split in between two components, configurable using the mouse.

Parameters
mainThe main component of size |main_size|, on the bottom.
backThe back component taking the remaining size, on the top.
main_sizeThe size of the |main| component.

Example

int bottom_size = 1;
auto top = Renderer([] { return text("Top") | center;});
auto bottom = Renderer([] { return text("Bottom") | center;});
auto split = ResizableSplit::Bottom(bottom, top, &bottom_size);
screen.Loop(split);

Output

top
────────────
bottom
Examples
examples/component/flexbox.cpp, and examples/component/resizable_split.cpp.

Definition at line 356 of file resizable_split.cpp.

◆ Renderer() [1/3]

Component Renderer ( Component  child,
std::function< Element()>  render 
)

Return a new Component, similar to |child|, but using |render| as the Component::Render() event.

Parameters
childThe component to forward events to.
renderThe function drawing the interface.

Example

std::string label = "Click to quit";
auto button = Button(&label, screen.ExitLoopClosure());
auto renderer = Renderer(button, [&] {
return hbox({
text("A button:"),
button->Render(),
});
});
screen.Loop(renderer);
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition: hbox.cpp:76
Examples
examples/component/button.cpp, examples/component/checkbox.cpp, examples/component/checkbox_in_frame.cpp, examples/component/composition.cpp, examples/component/flexbox.cpp, examples/component/focus.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/input.cpp, examples/component/maybe.cpp, examples/component/menu2.cpp, examples/component/menu_entries.cpp, examples/component/menu_in_frame.cpp, examples/component/menu_multiple.cpp, examples/component/menu_style.cpp, examples/component/modal_dialog.cpp, examples/component/nested_screen.cpp, examples/component/print_key_press.cpp, examples/component/radiobox_in_frame.cpp, examples/component/renderer.cpp, examples/component/resizable_split.cpp, examples/component/slider_rgb.cpp, examples/component/tab_horizontal.cpp, examples/component/tab_vertical.cpp, and examples/component/toggle.cpp.

Definition at line 59 of file renderer.cpp.

◆ Renderer() [2/3]

Component Renderer ( std::function< Element()>  render)

Return a component, using |render| to render its interface.

Parameters
renderThe function drawing the interface.

Example

auto renderer = Renderer([] {
return text("My interface");
});
screen.Loop(renderer);

Definition at line 28 of file renderer.cpp.

◆ Renderer() [3/3]

Component Renderer ( std::function< Element(bool)>  render)

Return a focusable component, using |render| to render its interface.

Parameters
renderThe function drawing the interface, taking a boolean telling whether the component is focused or not.

Example

auto renderer = Renderer([] (bool focused) {
if (focused)
return text("My interface") | inverted;
else
return text("My interface");
});
screen.Loop(renderer);
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Definition: inverted.cpp:29

Definition at line 82 of file renderer.cpp.

◆ CatchEvent() [1/2]

Component ftxui::CatchEvent ( Component  child,
std::function< bool(Event)>   
)

◆ Maybe()

Component Maybe ( Component  child,
bool *  show 
)
Examples
examples/component/maybe.cpp.

Definition at line 12 of file maybe.cpp.

◆ Input() [2/2]

Component Input ( WideStringRef  content,
ConstStringRef  placeholder,
Ref< InputOption option 
)

. An input box for editing text.

Parameters
contentThe editable content.
placeholderThe text displayed when content is still empty.
optionAdditional optional parameters.
See also
InputBase

Example

std::string content= "";
std::string placeholder = "placeholder";
Component input = Input(&content, &placeholder);
screen.Loop(input);

Output

placeholder

Definition at line 305 of file input.cpp.

◆ MakeReceiver()

Receiver< T > MakeReceiver ( )

Definition at line 117 of file receiver.hpp.

◆ text() [1/2]

Element text ( std::wstring  text)

Display a piece of unicode text.

See also
ftxui::to_wstring

Example

Element document = text(L"Hello world!");
std::shared_ptr< Node > Element
Definition: elements.hpp:16

Output

Hello world!
Examples
examples/component/button.cpp, examples/component/composition.cpp, examples/component/flexbox.cpp, examples/component/focus.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/input.cpp, examples/component/menu2.cpp, examples/component/menu_entries.cpp, examples/component/menu_multiple.cpp, examples/component/modal_dialog.cpp, examples/component/nested_screen.cpp, examples/component/print_key_press.cpp, examples/component/renderer.cpp, examples/component/resizable_split.cpp, examples/component/slider_rgb.cpp, examples/component/toggle.cpp, examples/dom/border.cpp, examples/dom/border_style.cpp, examples/dom/color_gallery.cpp, examples/dom/color_info_palette256.cpp, examples/dom/color_truecolor_HSV.cpp, examples/dom/color_truecolor_RGB.cpp, examples/dom/dbox.cpp, examples/dom/gauge.cpp, examples/dom/gridbox.cpp, examples/dom/hflow.cpp, examples/dom/html_like.cpp, examples/dom/package_manager.cpp, examples/dom/separator.cpp, examples/dom/separator_style.cpp, examples/dom/size.cpp, examples/dom/spinner.cpp, examples/dom/style_blink.cpp, examples/dom/style_bold.cpp, examples/dom/style_color.cpp, examples/dom/style_dim.cpp, examples/dom/style_gallery.cpp, examples/dom/style_inverted.cpp, examples/dom/style_underlined.cpp, examples/dom/vbox_hbox.cpp, and examples/dom/vflow.cpp.

Definition at line 106 of file text.cpp.

◆ vtext() [1/2]

Element vtext ( std::wstring  text)

Display a piece unicode text vertically.

See also
ftxui::to_wstring

Example

Element document = vtext(L"Hello world!");
Element vtext(std::wstring text)
Display a piece unicode text vertically.
Definition: text.cpp:166

Output

H
e
l
l
o
w
o
r
l
d
!

Definition at line 166 of file text.cpp.

◆ paragraph() [1/2]

◆ operator|() [1/3]

Element operator| ( Element  element,
Decorator  decorator 
)

From an element, apply a decorator.

Returns
the decorated element.

Example

Both of these are equivalent:

bold(text("Hello"));
Element bold(Element)
Use a bold font, for elements with more emphasis.
Definition: bold.cpp:28
text("Hello") | bold;

Definition at line 65 of file util.cpp.

◆ operator|() [2/3]

Elements operator| ( Elements  elements,
Decorator  decorator 
)

From a set of element, apply a decorator to every elements.

Returns
the set of decorated element.

Definition at line 45 of file util.cpp.

◆ operator|() [3/3]

Decorator operator| ( Decorator  a,
Decorator  b 
)

Compose two decorator into one.

Example

auto decorator = bold | blink;
Element blink(Element)
The text drawn alternates in between visible and hidden.
Definition: blink.cpp:28

Definition at line 38 of file util.cpp.

◆ text() [2/2]

Element text ( std::string  text)

Display a piece of UTF8 encoded unicode text.

See also
ftxui::to_wstring

Example

Element document = text("Hello world!");

Output

Hello world!

Definition at line 87 of file text.cpp.

◆ vtext() [2/2]

Element vtext ( std::string  text)

Display a piece of unicode text vertically.

See also
ftxui::to_wstring

Example

Element document = vtext("Hello world!");

Output

H
e
l
l
o
w
o
r
l
d
!

Definition at line 136 of file text.cpp.

◆ separator() [1/2]

Element separator ( void  )

Draw a vertical or horizontal separation in between two other elements.

See also
separator
separatorLight
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"),
text("down"),
});
Element separator(void)
Draw a vertical or horizontal separation in between two other elements.
Definition: separator.cpp:114
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition: vbox.cpp:77

Output

up
────
down
Examples
examples/component/button.cpp, examples/component/composition.cpp, examples/component/focus.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/input.cpp, examples/component/menu2.cpp, examples/component/menu_entries.cpp, examples/component/menu_style.cpp, examples/component/modal_dialog.cpp, examples/component/nested_screen.cpp, examples/component/slider_rgb.cpp, examples/component/tab_horizontal.cpp, examples/component/tab_vertical.cpp, examples/dom/color_gallery.cpp, examples/dom/graph.cpp, examples/dom/package_manager.cpp, examples/dom/paragraph.cpp, examples/dom/separator.cpp, and examples/dom/spinner.cpp.

Definition at line 114 of file separator.cpp.

◆ separatorLight()

Element separatorLight ( )

Draw a vertical or horizontal separation in between two other elements, using the LIGHT style.

See also
separator
separatorLight
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"),
text("down"),
});
Element separatorLight()
Draw a vertical or horizontal separation in between two other elements, using the LIGHT style.
Definition: separator.cpp:187

Output

up
────
down
Examples
examples/dom/separator_style.cpp.

Definition at line 187 of file separator.cpp.

◆ separatorHeavy()

Element separatorHeavy ( )

Draw a vertical or horizontal separation in between two other elements, using the HEAVY style.

See also
separator
separatorLight
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"),
text("down"),
});
Element separatorHeavy()
Draw a vertical or horizontal separation in between two other elements, using the HEAVY style.
Definition: separator.cpp:223

Output

up
━━━━
down
Examples
examples/dom/separator_style.cpp.

Definition at line 223 of file separator.cpp.

◆ separatorDouble()

Element separatorDouble ( )

Draw a vertical or horizontal separation in between two other elements, using the DOUBLE style.

See also
separator
separatorLight
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"),
text("down"),
});
Element separatorDouble()
Draw a vertical or horizontal separation in between two other elements, using the DOUBLE style.
Definition: separator.cpp:259

Output

up
════
down
Examples
examples/dom/separator_style.cpp.

Definition at line 259 of file separator.cpp.

◆ separatorEmpty()

Element separatorEmpty ( )

Draw a vertical or horizontal separation in between two other elements, using the EMPTY style.

See also
separator
separatorLight
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"),
text("down"),
});

Output

up
down

Definition at line 295 of file separator.cpp.

◆ separatorStyled()

Element separatorStyled ( BorderStyle  style)

Draw a vertical or horizontal separation in between two other elements.

Parameters
stylethe style of the separator.
See also
separator
separatorLight
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"),
text("down"),
});
Element separatorStyled(BorderStyle)
Draw a vertical or horizontal separation in between two other elements.
Definition: separator.cpp:151
@ DOUBLE
Definition: elements.hpp:21

Output

up
════
down

Definition at line 151 of file separator.cpp.

◆ separator() [2/2]

Element separator ( Pixel  pixel)

Draw a separator in between two element filled with a given pixel.

See also
separator
separatorLight
separatorHeavy
separatorDouble
separatorStyled

Example

Pixel empty;
Element document = vbox({
text("Up"),
separator(empty),
text("Down"),
})

Output

Up
Down

Definition at line 362 of file separator.cpp.

◆ separatorCharacter()

Element separatorCharacter ( std::string  value)

Draw a vertical or horizontal separation in between two other elements.

Parameters
valuethe character to fill the separator area.
See also
separator
separatorLight
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"),
text("down"),
});

Output

up
────
down

Definition at line 332 of file separator.cpp.

◆ gauge()

Element gauge ( float  progress)

Draw a high definition progress bar.

Parameters
progressThe proportion of the area to be filled. Belong to [0,1].

Example

A gauge. It can be used to represent a progress bar.

Element gauge(float ratio)
Draw a high definition progress bar.
Definition: gauge.cpp:75
Element border(Element)
Draw a border around the element.
Definition: border.cpp:150

Output

┌──────────────────────────────────────────────────────────────────────────┐
│█████████████████████████████████████ │
└──────────────────────────────────────────────────────────────────────────┘
Examples
examples/component/button.cpp, examples/component/homescreen.cpp, examples/component/menu2.cpp, examples/dom/gauge.cpp, and examples/dom/package_manager.cpp.

Definition at line 75 of file gauge.cpp.

◆ border()

Element border ( Element  child)

Draw a border around the element.

See also
border
borderLight
borderDouble
borderHeavy
borderEmpty
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
examples/component/button.cpp, examples/component/checkbox.cpp, examples/component/checkbox_in_frame.cpp, examples/component/composition.cpp, examples/component/flexbox.cpp, examples/component/focus.cpp, examples/component/gallery.cpp, examples/component/homescreen.cpp, examples/component/input.cpp, examples/component/maybe.cpp, examples/component/menu2.cpp, examples/component/menu_entries.cpp, examples/component/menu_in_frame.cpp, examples/component/menu_style.cpp, examples/component/modal_dialog.cpp, examples/component/nested_screen.cpp, examples/component/radiobox_in_frame.cpp, examples/component/renderer.cpp, examples/component/resizable_split.cpp, examples/component/slider_rgb.cpp, examples/component/tab_horizontal.cpp, examples/component/tab_vertical.cpp, examples/dom/border.cpp, examples/dom/color_gallery.cpp, examples/dom/dbox.cpp, examples/dom/graph.cpp, examples/dom/gridbox.cpp, examples/dom/hflow.cpp, examples/dom/html_like.cpp, examples/dom/paragraph.cpp, examples/dom/separator.cpp, examples/dom/spinner.cpp, examples/dom/vflow.cpp, and examples/dom/window.cpp.

Definition at line 150 of file border.cpp.

◆ borderLight()

Element borderLight ( Element  child)

Draw a light border around the element.

See also
border
borderLight
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;
Element borderLight(Element)
Draw a light border around the element.
Definition: border.cpp:202

Output

┌──────────────┐
│The element │
└──────────────┘
Examples
examples/dom/border_style.cpp, and examples/dom/separator_style.cpp.

Definition at line 202 of file border.cpp.

◆ borderHeavy()

Element borderHeavy ( Element  child)

Draw a heavy border around the element.

See also
border
borderLight
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;
Element borderHeavy(Element)
Draw a heavy border around the element.
Definition: border.cpp:236

Output

┏━━━━━━━━━━━━━━┓
┃The element ┃
┗━━━━━━━━━━━━━━┛
Examples
examples/dom/border_style.cpp, and examples/dom/separator_style.cpp.

Definition at line 236 of file border.cpp.

◆ borderDouble()

Element borderDouble ( Element  child)

Draw a double border around the element.

See also
border
borderLight
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;
Element borderDouble(Element)
Draw a double border around the element.
Definition: border.cpp:270

Output

╔══════════════╗
║The element ║
╚══════════════╝
Examples
examples/dom/border_style.cpp, and examples/dom/separator_style.cpp.

Definition at line 270 of file border.cpp.

◆ borderRounded()

Element borderRounded ( Element  child)

Draw a rounded border around the element.

See also
border
borderLight
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;
Element borderRounded(Element)
Draw a rounded border around the element.
Definition: border.cpp:304

Output

╭──────────────╮
│The element │
╰──────────────╯
Examples
examples/dom/border_style.cpp.

Definition at line 304 of file border.cpp.

◆ borderEmpty()

Element borderEmpty ( Element  child)

Draw an empty border around the element.

See also
border
borderLight
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

Definition at line 338 of file border.cpp.

◆ borderStyled()

Decorator borderStyled ( BorderStyle  style)

Same as border but with different styles.

See also
border

Definition at line 166 of file border.cpp.

◆ borderWith()

Decorator borderWith ( Pixel  pixel)

Same as border but with a constant Pixel around the element.

See also
border

Definition at line 157 of file border.cpp.

◆ window()

Element window ( Element  title,
Element  content 
)

Draw window with a title and a border around the element.

Parameters
titleThe title of the window.
contentThe element to be wrapped.
See also
border

Example

Element document = window(text("Title"),
text("content")
);
Element window(Element title, Element content)
Draw window with a title and a border around the element.
Definition: border.cpp:363

Output

┌Title──┐
│content│
└───────┘
Examples
examples/component/flexbox.cpp, examples/component/homescreen.cpp, examples/component/menu_multiple.cpp, examples/component/print_key_press.cpp, examples/dom/color_truecolor_RGB.cpp, examples/dom/hflow.cpp, examples/dom/package_manager.cpp, examples/dom/size.cpp, and examples/dom/vflow.cpp.

Definition at line 363 of file border.cpp.

◆ 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".

Parameters
charset_indexThe type of "video".
image_indexThe "frame" of the video. You need to increase this for every "step".
Examples
examples/component/homescreen.cpp, examples/dom/html_like.cpp, and examples/dom/spinner.cpp.

Definition at line 255 of file spinner.cpp.

◆ paragraph() [2/2]

Element paragraph ( std::string  the_text)

Return an element drawing the paragraph on multiple lines.

See also
flexbox.

Definition at line 24 of file paragraph.cpp.

◆ paragraphAlignLeft()

Element paragraphAlignLeft ( std::string  the_text)

Return an element drawing the paragraph on multiple lines, aligned on the left.

See also
flexbox.
Examples
examples/component/homescreen.cpp.

Definition at line 32 of file paragraph.cpp.

◆ paragraphAlignRight()

Element paragraphAlignRight ( std::string  the_text)

Return an element drawing the paragraph on multiple lines, aligned on the right.

See also
flexbox.
Examples
examples/component/homescreen.cpp.

Definition at line 41 of file paragraph.cpp.

◆ paragraphAlignCenter()

Element paragraphAlignCenter ( std::string  the_text)

Return an element drawing the paragraph on multiple lines, aligned on the center.

See also
flexbox.
Examples
examples/component/homescreen.cpp.

Definition at line 51 of file paragraph.cpp.

◆ paragraphAlignJustify()

Element paragraphAlignJustify ( std::string  the_text)

Return an element drawing the paragraph on multiple lines, aligned using a justified alignment. the center.

See also
flexbox.
Examples
examples/component/homescreen.cpp.

Definition at line 62 of file paragraph.cpp.

◆ graph()

Element graph ( GraphFunction  graph_function)

Draw a graph using a GraphFunction.

Parameters
graph_functionthe function to be called to get the data.
Examples
examples/component/homescreen.cpp, examples/dom/graph.cpp, and examples/dom/window.cpp.

Definition at line 59 of file graph.cpp.

◆ emptyElement()

Element emptyElement ( )

An element of size 0x0 drawing nothing.

Definition at line 110 of file util.cpp.

◆ bold()

◆ dim()

◆ inverted()

Element inverted ( Element  child)

Add a filter that will invert the foreground and the background colors.

Examples
examples/component/menu_entries.cpp, examples/dom/graph.cpp, examples/dom/style_gallery.cpp, and examples/dom/style_inverted.cpp.

Definition at line 29 of file inverted.cpp.

◆ underlined()

Element underlined ( Element  child)

Make the underlined element to be underlined.

Examples
examples/dom/html_like.cpp, examples/dom/style_gallery.cpp, and examples/dom/style_underlined.cpp.

Definition at line 28 of file underlined.cpp.

◆ blink()

Element blink ( Element  child)

The text drawn alternates in between visible and hidden.

Examples
examples/dom/style_blink.cpp, and examples/dom/style_gallery.cpp.

Definition at line 28 of file blink.cpp.

◆ color() [1/2]

◆ bgcolor() [1/2]

Decorator bgcolor ( Color  color)

Decorate using a background color.

Parameters
colorThe background color to be applied.
Returns
The Decorator applying the color.

Example

Element document = text("red") | bgcolor(Color::Red);
Decorator bgcolor(Color)
Decorate using a background color.
Definition: color.cpp:100
Examples
examples/component/flexbox.cpp, examples/component/focus.cpp, examples/component/homescreen.cpp, examples/component/menu_style.cpp, examples/component/slider_rgb.cpp, examples/dom/color_gallery.cpp, examples/dom/color_info_palette256.cpp, examples/dom/color_truecolor_HSV.cpp, examples/dom/color_truecolor_RGB.cpp, examples/dom/style_color.cpp, examples/dom/style_gallery.cpp, and examples/dom/window.cpp.

Definition at line 100 of file color.cpp.

◆ color() [2/2]

Element color ( Color  color,
Element  child 
)

Set the foreground color of an element.

Parameters
colorThe color of the output element.
childThe input element.
Returns
The output element colored.

Example

Element document = color(Color::Green, text("Success")),

Definition at line 57 of file color.cpp.

◆ bgcolor() [2/2]

Element bgcolor ( Color  color,
Element  child 
)

Set the background color of an element.

Parameters
colorThe color of the output element.
childThe input element.
Returns
The output element colored.

Example

Element document = bgcolor(Color::Green, text("Success")),

Definition at line 72 of file color.cpp.

◆ 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;
Decorator focusPosition(int x, int y)
Used inside a frame, this force the view to be scrolled toward a a given position....
Definition: focus.cpp:72
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

Definition at line 72 of file focus.cpp.

◆ 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()
| frame;
Decorator focusPositionRelative(float x, float y)
Used inside a frame, this force the view to be scrolled toward a a given position....
Definition: focus.cpp:33
Examples
examples/component/focus.cpp.

Definition at line 33 of file focus.cpp.

◆ hbox()

◆ vbox()

◆ dbox()

Element dbox ( Elements  children_)

Stack several element on top of each other.

Parameters
children_The input element.
Returns
The right aligned element.
Examples
examples/component/modal_dialog.cpp, and examples/dom/dbox.cpp.

Definition at line 50 of file dbox.cpp.

◆ flexbox()

◆ gridbox()

Element gridbox ( std::vector< Elements lines)

A container displaying a grid of elements.

Parameters
linesA 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")} ,
});
Element gridbox(std::vector< Elements > lines)
A container displaying a grid of elements.
Definition: gridbox.cpp:154

Output:

╭──────────╮╭──────╮╭──────────╮
│north-west││north ││north-east│
╰──────────╯╰──────╯╰──────────╯
╭──────────╮╭──────╮╭──────────╮
│west ││center││east │
╰──────────╯╰──────╯╰──────────╯
╭──────────╮╭──────╮╭──────────╮
│south-west││south ││south-east│
╰──────────╯╰──────╯╰──────────╯
Examples
examples/component/focus.cpp, and examples/dom/gridbox.cpp.

Definition at line 154 of file gridbox.cpp.

◆ hflow()

◆ vflow()

Element ftxui::vflow ( Elements  )

◆ flex()

Element flex ( Element  child)

Make a child element to expand proportionnally to the space left in a container.

Examples:

text("left") | border ,
text("middle") | border | flex,
text("right") | border,
});
Element flex(Element)
Make a child element to expand proportionnally to the space left in a container.
Definition: flex.cpp:119

Output:

┌────┐┌─────────────────────────────────────────────────────────┐┌─────┐
│left││middle ││right│
└────┘└─────────────────────────────────────────────────────────┘└─────┘
Examples
examples/component/flexbox.cpp, examples/component/focus.cpp, examples/component/homescreen.cpp, examples/component/menu_multiple.cpp, examples/component/menu_style.cpp, examples/dom/gauge.cpp, examples/dom/graph.cpp, and examples/dom/separator.cpp.

Definition at line 119 of file flex.cpp.

◆ flex_grow()

Element flex_grow ( Element  child)

Expand if possible.

Examples
examples/component/homescreen.cpp.

Definition at line 137 of file flex.cpp.

◆ flex_shrink()

Element flex_shrink ( Element  child)

Minimize if needed.

Definition at line 155 of file flex.cpp.

◆ xflex()

Element xflex ( Element  child)

Expand/Minimize if possible/needed on the X axis.

Examples
examples/component/gallery.cpp, and examples/component/slider_rgb.cpp.

Definition at line 125 of file flex.cpp.

◆ xflex_grow()

Element xflex_grow ( Element  child)

Expand if possible on the X axis.

Examples
examples/component/flexbox.cpp.

Definition at line 143 of file flex.cpp.

◆ xflex_shrink()

Element xflex_shrink ( Element  child)

Minimize if needed on the X axis.

Definition at line 161 of file flex.cpp.

◆ yflex()

Element yflex ( Element  child)

Expand/Minimize if possible/needed on the Y axis.

Examples
examples/component/homescreen.cpp.

Definition at line 131 of file flex.cpp.

◆ yflex_grow()

Element yflex_grow ( Element  child)

Expand if possible on the Y axis.

Examples
examples/component/flexbox.cpp.

Definition at line 149 of file flex.cpp.

◆ yflex_shrink()

Element yflex_shrink ( Element  child)

Minimize if needed on the Y axis.

Definition at line 167 of file flex.cpp.

◆ notflex()

Element notflex ( Element  child)

Make the element not flexible.

Examples
examples/component/flexbox.cpp.

Definition at line 173 of file flex.cpp.

◆ filler()

◆ size()

◆ reflect()

Decorator reflect ( Box box)

Definition at line 39 of file reflect.cpp.

◆ frame()

Element frame ( Element  child)

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
examples/component/checkbox.cpp, examples/component/checkbox_in_frame.cpp, examples/component/focus.cpp, examples/component/homescreen.cpp, examples/component/menu_entries.cpp, examples/component/menu_in_frame.cpp, and examples/component/radiobox_in_frame.cpp.

Definition at line 138 of file frame.cpp.

◆ xframe()

Element xframe ( Element  child)

Definition at line 142 of file frame.cpp.

◆ yframe()

Element yframe ( Element  child)

Definition at line 146 of file frame.cpp.

◆ focus()

Element focus ( Element  child)

Definition at line 79 of file frame.cpp.

◆ select()

Element select ( Element  child)

Definition at line 38 of file frame.cpp.

◆ vscroll_indicator()

Element vscroll_indicator ( Element  child)

◆ hcenter()

Element hcenter ( Element  child)

Center an element horizontally.

Parameters
childThe decorated element.
Returns
The centered element.
Examples
examples/component/flexbox.cpp, examples/component/homescreen.cpp, examples/component/menu2.cpp, examples/dom/hflow.cpp, examples/dom/size.cpp, and examples/dom/vflow.cpp.

Definition at line 12 of file composite_decorator.cpp.

◆ vcenter()

Element vcenter ( Element  child)

Center an element vertically.

Parameters
childThe decorated element.
Returns
The centered element.

Definition at line 20 of file composite_decorator.cpp.

◆ center()

Element center ( Element  child)

◆ align_right()

Element align_right ( Element  child)

Align an element on the right side.

Parameters
childThe decorated element.
Returns
The right aligned element.
Examples
examples/dom/table.cpp.

Definition at line 36 of file composite_decorator.cpp.

◆ nothing()

Element nothing ( Element  element)

A decoration doing absolutely nothing.

Definition at line 26 of file util.cpp.

◆ clear_under()

Element clear_under ( Element  child)

Before drawing |child|, clear the pixels below. This is useful in.

See also
ftxui::dbox
Examples
examples/component/modal_dialog.cpp.

Definition at line 32 of file clear_under.cpp.

◆ Render() [1/2]

◆ Render() [2/2]

void Render ( Screen screen,
Node node 
)

Display an element on a ftxui::Screen.

Definition at line 46 of file node.cpp.

◆ GetColorInfo() [1/2]

ColorInfo GetColorInfo ( Color::Palette256  index)

Definition at line 266 of file color_info.cpp.

◆ GetColorInfo() [2/2]

ColorInfo GetColorInfo ( Color::Palette16  index)

Definition at line 270 of file color_info.cpp.

◆ wchar_width()

int wchar_width ( wchar_t  ucs)

Definition at line 210 of file string.cpp.

◆ wstring_width()

int wstring_width ( const std::wstring &  text)

Definition at line 214 of file string.cpp.

◆ to_string()

◆ to_wstring() [1/2]

std::wstring to_wstring ( const std::string &  s)

Convert a std::wstring into a UTF8 std::string.

Definition at line 395 of file string.cpp.

◆ to_wstring() [2/2]

std::wstring ftxui::to_wstring ( s)

Definition at line 12 of file string.hpp.

◆ string_width()

int string_width ( const std::string &  input)

Definition at line 226 of file string.cpp.

◆ Utf8ToGlyphs()

std::vector< std::string > Utf8ToGlyphs ( const std::string &  input)

Definition at line 250 of file string.cpp.

◆ GlyphPosition()

int GlyphPosition ( const std::string &  input,
size_t  glyph_index,
size_t  start = 0 
)

Definition at line 291 of file string.cpp.

◆ GlyphCount()

int GlyphCount ( const std::string &  input)

Definition at line 357 of file string.cpp.

◆ CellToGlyphIndex()

std::vector< int > CellToGlyphIndex ( const std::string &  input)

Definition at line 317 of file string.cpp.

◆ CatchEvent() [2/2]

Component ftxui::CatchEvent ( Component  child,
std::function< bool(Event event)>  on_event 
)

Return a component, using |on_event| to catch events. This function must returns true when the event has been handled, false otherwise.

Parameters
childThe wrapped component.
on_eventThe function drawing the interface.

Example

auto renderer = Renderer([] {
return text("My interface");
});
screen.Loop(renderer);

Definition at line 44 of file catch_event.cpp.

◆ Slider() [2/4]

template Component ftxui::Slider ( ConstStringRef  label,
int *  value,
int  min,
int  max,
int  increment 
)

◆ Slider() [3/4]

template Component ftxui::Slider ( ConstStringRef  label,
float *  value,
float  min,
float  max,
float  increment 
)

◆ Slider() [4/4]

template Component ftxui::Slider ( ConstStringRef  label,
long *  value,
long  min,
long  max,
long  increment 
)

Variable Documentation

◆ palette256

const ColorInfo palette256[]

Definition at line 7 of file color_info.cpp.