FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
ftxui/component

Detailed Description

Please check the tutorial of the ftxui/component module.

Classes

class  ComponentBase
 It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event. More...
 
struct  AnimatedColorOption
 Option about a potentially animated color. More...
 
struct  MenuEntryOption
 Option for the MenuEntry component. More...
 
struct  MenuOption
 Option for the Menu component. More...
 
struct  ButtonOption
 Option for the AnimatedButton 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  DropdownOption
 Option for the Dropdown component.A dropdown menu is a checkbox opening/closing a radiobox. More...
 
struct  Mouse
 A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift, ctrl, meta). More...
 

Functions

Component Button (ButtonOption option)
 Draw a button. Execute a function when clicked.
 
Component Button (ConstStringRef label, std::function< void()> on_click, ButtonOption option)
 Draw a button. Execute a function when clicked.
 
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.
 
ComponentDecorator CatchEvent (std::function< bool(Event)> on_event)
 Decorate a component, using |on_event| to catch events. This function must returns true when the event has been handled, false otherwise.
 
Component Checkbox (CheckboxOption option)
 Draw checkable element.
 
Component Checkbox (ConstStringRef label, bool *checked, CheckboxOption option)
 Draw checkable element.
 
Component Vertical (Components children)
 A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys.
 
Component Vertical (Components children, int *selector)
 A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys. This is useful for implementing a Menu for instance.
 
Component Horizontal (Components children)
 A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys.
 
Component Horizontal (Components children, int *selector)
 A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys.
 
Component Tab (Components children, int *selector)
 A list of components, where only one is drawn and interacted with at a time. The |selector| gives the index of the selected component. This is useful to implement tabs.
 
Component Stacked (Components children)
 A list of components to be stacked on top of each other. Events are propagated to the first component, then the second if not handled, etc. The components are drawn in the reverse order they are given. When a component take focus, it is put at the front, without changing the relative order of the other elements.
 
Component Dropdown (ConstStringListRef entries, int *selected)
 A dropdown menu.
 
Component Dropdown (DropdownOption option)
 A dropdown menu.
 
Component Hoverable (Component component, bool *hover)
 Wrap a component. Gives the ability to know if it is hovered by the mouse.
 
Component Hoverable (Component component, std::function< void()> on_enter, std::function< void()> on_leave)
 Wrap a component. Uses callbacks.
 
ComponentDecorator Hoverable (bool *hover)
 Wrap a component. Gives the ability to know if it is hovered by the mouse.
 
ComponentDecorator Hoverable (std::function< void()> on_enter, std::function< void()> on_leave)
 Wrap a component. Gives the ability to know if it is hovered by the mouse.
 
Component Hoverable (Component component, std::function< void(bool)> on_change)
 Wrap a component. Gives the ability to know if it is hovered by the mouse.
 
ComponentDecorator Hoverable (std::function< void(bool)> on_change)
 Wrap a component. Gives the ability to know if it is hovered by the mouse.
 
Component Input (InputOption option)
 An input box for editing text.
 
Component Input (StringRef content, InputOption option)
 An input box for editing text.
 
Component Input (StringRef content, StringRef placeholder, InputOption option)
 An input box for editing text.
 
Component Maybe (Component child, std::function< bool()> show)
 Decorate a component |child|. It is shown only when |show| returns true.
 
ComponentDecorator Maybe (std::function< bool()> show)
 Decorate a component. It is shown only when the |show| function returns true.
 
Component Maybe (Component child, const bool *show)
 Decorate a component |child|. It is shown only when |show| is true.
 
ComponentDecorator Maybe (const bool *show)
 Decorate a component. It is shown only when |show| is true.
 
Component Menu (MenuOption option)
 A list of text. The focused element is selected.
 
Component Menu (ConstStringListRef entries, int *selected, MenuOption option)
 A list of text. The focused element is selected.
 
Component Toggle (ConstStringListRef entries, int *selected)
 An horizontal list of elements. The user can navigate through them.
 
Component MenuEntry (ConstStringRef label, MenuEntryOption option)
 A specific menu entry. They can be put into a Container::Vertical to form a menu.
 
Component MenuEntry (MenuEntryOption option)
 A specific menu entry. They can be put into a Container::Vertical to form a menu.
 
Component Modal (Component main, Component modal, const bool *show_modal)
 
ComponentDecorator Modal (Component modal, const bool *show_modal)
 
Component Radiobox (RadioboxOption option)
 A list of element, where only one can be selected.
 
Component Radiobox (ConstStringListRef entries, int *selected, RadioboxOption option)
 A list of element, where only one can be selected.
 
Component Renderer (std::function< Element()> render)
 Return a component, using |render| to render its interface.
 
Component Renderer (Component child, std::function< Element()> render)
 Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
 
Component Renderer (std::function< Element(bool)> render)
 Return a focusable component, using |render| to render its interface.
 
ComponentDecorator Renderer (ElementDecorator decorator)
 Decorate a component, by decorating what it renders.
 
Component ResizableSplitLeft (Component main, Component back, int *main_size)
 An horizontal split in between two components, configurable using the mouse.
 
Component ResizableSplitRight (Component main, Component back, int *main_size)
 An horizontal split in between two components, configurable using the mouse.
 
Component ResizableSplitTop (Component main, Component back, int *main_size)
 An vertical split in between two components, configurable using the mouse.
 
Component ResizableSplitBottom (Component main, Component back, int *main_size)
 An vertical split in between two components, configurable using the mouse.
 
Component Slider (ConstStringRef label, Ref< int > value, ConstRef< int > min, ConstRef< int > max, ConstRef< int > increment)
 An horizontal slider.
 
Component Window (WindowOptions option)
 A draggeable / resizeable window. To use multiple of them, they must be stacked using Container::Stacked({...}) component;.
 
ComponentBaseParent () const
 Return the parent ComponentBase, or nul if any.
 
ComponentChildAt (size_t i)
 Access the child at index i.
 
size_t ChildCount () const
 Returns the number of children.
 
int Index () const
 Return index of the component in its parent. -1 if no parent.
 
void Add (Component children)
 Add a child. @param child The child to be attached.
 
void Detach ()
 Detach this child from its parent.
 
void DetachAllChildren ()
 Remove all children.
 
Element Render ()
 Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.
 
virtual Element OnRender ()
 Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.
 
virtual bool OnEvent (Event)
 Called in response to an event.
 
virtual void OnAnimation (animation::Params &params)
 Called in response to an animation event.
 
virtual Component ActiveChild ()
 Return the currently Active child.
 
virtual bool Focusable () const
 Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.
 
bool Active () const
 Returns if the element if the currently active child of its parent.
 
bool Focused () const
 Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().
 
virtual void SetActiveChild (ComponentBase *child)
 Make the |child| to be the "active" one.
 
void SetActiveChild (Component child)
 Make the |child| to be the "active" one.
 
void TakeFocus ()
 Configure all the ancestors to give focus to this component.
 
CapturedMouse CaptureMouse (const Event &event)
 Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.
 
void Set (Color inactive, Color active, animation::Duration duration=std::chrono::milliseconds(250), animation::easing::Function function=animation::easing::QuadraticInOut)
 A color option that can be animated. @params _inactive The color when the component is inactive. @params _active The color when the component is active. @params _duration The duration of the animation. @params _function The easing function of the animation.
 
void SetAnimation (animation::Duration d, animation::easing::Function f)
 Set how the underline should animate.
 
void SetAnimationDuration (animation::Duration d)
 Set how the underline should animate.
 
void SetAnimationFunction (animation::easing::Function f)
 Set how the underline should animate.
 
void SetAnimationFunction (animation::easing::Function f_leader, animation::easing::Function f_follower)
 Set how the underline should animate. This is useful to desynchronize the animation of the leader and the follower.
 
static MenuOption Horizontal ()
 Standard options for a horizontal menu. This can be useful to implement a tab bar.
 
static MenuOption HorizontalAnimated ()
 Standard options for an animated horizontal menu. This can be useful to implement a tab bar.
 
static MenuOption Vertical ()
 Standard options for a vertical menu. This can be useful to implement a list of selectable items.
 
static MenuOption VerticalAnimated ()
 Standard options for an animated vertical menu. This can be useful to implement a list of selectable items.
 
static MenuOption Toggle ()
 Standard options for a horizontal menu with some separator. This can be useful to implement a tab bar.
 
static ButtonOption Ascii ()
 Create a ButtonOption, highlighted using [] characters.
 
static ButtonOption Simple ()
 Create a ButtonOption, inverted when focused.
 
static ButtonOption Border ()
 Create a ButtonOption. The button is shown using a border, inverted when focused. This is the current default.
 
static ButtonOption Animated ()
 Create a ButtonOption, using animated colors.
 
static ButtonOption Animated (Color color)
 Create a ButtonOption, using animated colors.
 
static ButtonOption Animated (Color background, Color foreground)
 Create a ButtonOption, using animated colors.
 
static ButtonOption Animated (Color background, Color foreground, Color background_active, Color foreground_active)
 Create a ButtonOption, using animated colors.
 
static CheckboxOption Simple ()
 Option for standard Checkbox.
 
static RadioboxOption Simple ()
 Option for standard Radiobox.
 
static InputOption Default ()
 Create the default input style:
 
static InputOption Spacious ()
 A white on black style with high margins:
 
static Event Character (std::string)
 An event corresponding to a given typed character.
 
static Event Character (char)
 An event corresponding to a given typed character.
 
static Event Character (wchar_t)
 An event corresponding to a given typed character.
 
static Event Mouse (std::string, Mouse mouse)
 An event corresponding to a given typed character.
 
static Event Special (std::string)
 An custom event whose meaning is defined by the user of the library.
 
 Loop (ScreenInteractive *screen, Component component)
 A Loop is a wrapper around a Component and a ScreenInteractive. It is used to run a Component in a terminal.
 
bool HasQuitted ()
 Whether the loop has quitted.
 
static ScreenInteractive Fullscreen ()
 
static ScreenInteractive FullscreenPrimaryScreen ()
 
static ScreenInteractive FullscreenAlternateScreen ()
 
void TrackMouse (bool enable=true)
 Set whether mouse is tracked and events reported. called outside of the main loop. E.g ScreenInteractive::Loop(...).
 
void Post (Task task)
 Add a task to the main loop. It will be executed later, after every other scheduled tasks.
 
void PostEvent (Event event)
 Add an event to the main loop. It will be executed later, after every other scheduled events.
 
CapturedMouse CaptureMouse ()
 Try to get the unique lock about behing able to capture the mouse.
 
void Loop (Component)
 Execute the main loop.
 
Closure ExitLoopClosure ()
 Return a function to exit the main loop.
 
void Exit ()
 Exit the main loop.
 

Class Documentation

◆ ftxui::ComponentBase

class ftxui::ComponentBase

It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event.

Definition at line 30 of file component_base.hpp.

Public Member Functions

 ComponentBase (Components children)
 
virtual ~ComponentBase ()
 
 ComponentBase ()=default
 
 ComponentBase (const ComponentBase &)=delete
 
 ComponentBase (ComponentBase &&)=delete
 
ComponentBaseoperator= (const ComponentBase &)=delete
 
ComponentBaseoperator= (ComponentBase &&)=delete
 
ComponentBaseParent () const
 Return the parent ComponentBase, or nul if any.
 
ComponentChildAt (size_t i)
 Access the child at index i.
 
size_t ChildCount () const
 Returns the number of children.
 
int Index () const
 Return index of the component in its parent. -1 if no parent.
 
void Add (Component children)
 Add a child. @param child The child to be attached.
 
void Detach ()
 Detach this child from its parent.
 
void DetachAllChildren ()
 Remove all children.
 
Element Render ()
 Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.
 
virtual Element OnRender ()
 Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.
 
virtual bool OnEvent (Event)
 Called in response to an event.
 
virtual void OnAnimation (animation::Params &params)
 Called in response to an animation event.
 
virtual Component ActiveChild ()
 Return the currently Active child.
 
virtual bool Focusable () const
 Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.
 
bool Active () const
 Returns if the element if the currently active child of its parent.
 
bool Focused () const
 Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().
 
virtual void SetActiveChild (ComponentBase *child)
 Make the |child| to be the "active" one.
 
void SetActiveChild (Component child)
 Make the |child| to be the "active" one.
 
void TakeFocus ()
 Configure all the ancestors to give focus to this component.
 

Protected Member Functions

CapturedMouse CaptureMouse (const Event &event)
 Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.
 

Protected Attributes

Components children_
 

Constructor & Destructor Documentation

◆ ComponentBase() [1/4]

ComponentBase ( Components children)
inlineexplicit

Definition at line 32 of file component_base.hpp.

◆ ~ComponentBase()

~ComponentBase ( )
virtual

Definition at line 31 of file component.cpp.

◆ ComponentBase() [2/4]

ComponentBase ( )
default

◆ ComponentBase() [3/4]

ComponentBase ( const ComponentBase & )
delete

◆ ComponentBase() [4/4]

Member Function Documentation

◆ operator=() [1/2]

ComponentBase & operator= ( const ComponentBase & )
delete

◆ operator=() [2/2]

ComponentBase & operator= ( ComponentBase && )
delete

Member Data Documentation

◆ children_

Components children_
protected

Definition at line 96 of file component_base.hpp.

◆ ftxui::AnimatedColorOption

struct ftxui::AnimatedColorOption

Option about a potentially animated color.

Definition at line 55 of file component_options.hpp.

Public Member Functions

void Set (Color inactive, Color active, animation::Duration duration=std::chrono::milliseconds(250), animation::easing::Function function=animation::easing::QuadraticInOut)
 A color option that can be animated. @params _inactive The color when the component is inactive. @params _active The color when the component is active. @params _duration The duration of the animation. @params _function The easing function of the animation.
 

Public Attributes

bool enabled = false
 
Color inactive
 
Color active
 
animation::Duration duration = std::chrono::milliseconds(250)
 
animation::easing::Function function = animation::easing::QuadraticInOut
 

Member Data Documentation

◆ enabled

bool enabled = false

Definition at line 62 of file component_options.hpp.

◆ inactive

Color inactive

Definition at line 63 of file component_options.hpp.

◆ active

Color active

Definition at line 64 of file component_options.hpp.

◆ duration

animation::Duration duration = std::chrono::milliseconds(250)

Definition at line 65 of file component_options.hpp.

◆ function

animation::easing::Function function = animation::easing::QuadraticInOut

Definition at line 66 of file component_options.hpp.

◆ ftxui::MenuEntryOption

struct ftxui::MenuEntryOption

Option for the MenuEntry component.

Definition at line 76 of file component_options.hpp.

Public Attributes

ConstStringRef label = "MenuEntry"
 
std::function< Element(const EntryState &state)> transform
 
AnimatedColorsOption animated_colors
 

Member Data Documentation

◆ label

ConstStringRef label = "MenuEntry"

Definition at line 77 of file component_options.hpp.

◆ transform

std::function<Element(const EntryState& state)> transform

Definition at line 78 of file component_options.hpp.

◆ animated_colors

AnimatedColorsOption animated_colors

Definition at line 79 of file component_options.hpp.

◆ ftxui::MenuOption

struct ftxui::MenuOption

Option for the Menu component.

Definition at line 84 of file component_options.hpp.

Static Public Member Functions

static MenuOption Horizontal ()
 Standard options for a horizontal menu. This can be useful to implement a tab bar.
 
static MenuOption HorizontalAnimated ()
 Standard options for an animated horizontal menu. This can be useful to implement a tab bar.
 
static MenuOption Vertical ()
 Standard options for a vertical menu. This can be useful to implement a list of selectable items.
 
static MenuOption VerticalAnimated ()
 Standard options for an animated vertical menu. This can be useful to implement a list of selectable items.
 
static MenuOption Toggle ()
 Standard options for a horizontal menu with some separator. This can be useful to implement a tab bar.
 

Public Attributes

ConstStringListRef entries
 
Ref< int > selected = 0
 
UnderlineOption underline
 
MenuEntryOption entries_option
 
Direction direction = Direction::Down
 
std::function< Element()> elements_prefix
 
std::function< Element()> elements_infix
 
std::function< Element()> elements_postfix
 
std::function< void()> on_change
 
std::function< void()> on_enter
 
Ref< int > focused_entry = 0
 

Member Data Documentation

◆ entries

Definition at line 92 of file component_options.hpp.

◆ selected

Ref<int> selected = 0

‍The list of entries.

Definition at line 93 of file component_options.hpp.

◆ underline

UnderlineOption underline

‍The index of the selected entry.

Definition at line 96 of file component_options.hpp.

◆ entries_option

MenuEntryOption entries_option

Definition at line 97 of file component_options.hpp.

◆ direction

Definition at line 98 of file component_options.hpp.

◆ elements_prefix

std::function<Element()> elements_prefix

Definition at line 99 of file component_options.hpp.

◆ elements_infix

std::function<Element()> elements_infix

Definition at line 100 of file component_options.hpp.

◆ elements_postfix

std::function<Element()> elements_postfix

Definition at line 101 of file component_options.hpp.

◆ on_change

std::function<void()> on_change

Definition at line 104 of file component_options.hpp.

◆ on_enter

std::function<void()> on_enter

‍Called when the selected entry changes.

Definition at line 105 of file component_options.hpp.

◆ focused_entry

Ref<int> focused_entry = 0

‍Called when the user presses enter.

Definition at line 106 of file component_options.hpp.

◆ ftxui::ButtonOption

struct ftxui::ButtonOption

Option for the AnimatedButton component.

Definition at line 111 of file component_options.hpp.

Static Public Member Functions

static ButtonOption Ascii ()
 Create a ButtonOption, highlighted using [] characters.
 
static ButtonOption Simple ()
 Create a ButtonOption, inverted when focused.
 
static ButtonOption Border ()
 Create a ButtonOption. The button is shown using a border, inverted when focused. This is the current default.
 
static ButtonOption Animated ()
 Create a ButtonOption, using animated colors.
 
static ButtonOption Animated (Color color)
 Create a ButtonOption, using animated colors.
 
static ButtonOption Animated (Color background, Color foreground)
 Create a ButtonOption, using animated colors.
 
static ButtonOption Animated (Color background, Color foreground, Color background_active, Color foreground_active)
 Create a ButtonOption, using animated colors.
 

Public Attributes

ConstStringRef label = "Button"
 
std::function< void()> on_click = [] {}
 
std::function< Element(const EntryState &)> transform
 
AnimatedColorsOption animated_colors
 

Member Data Documentation

◆ label

ConstStringRef label = "Button"

Definition at line 124 of file component_options.hpp.

◆ on_click

std::function<void()> on_click = [] {}

Definition at line 125 of file component_options.hpp.

◆ transform

std::function<Element(const EntryState&)> transform

Definition at line 128 of file component_options.hpp.

◆ animated_colors

AnimatedColorsOption animated_colors

Definition at line 129 of file component_options.hpp.

◆ ftxui::CheckboxOption

struct ftxui::CheckboxOption

Option for the Checkbox component.

Definition at line 134 of file component_options.hpp.

Static Public Member Functions

static CheckboxOption Simple ()
 Option for standard Checkbox.
 

Public Attributes

ConstStringRef label = "Checkbox"
 
Ref< bool > checked = false
 
std::function< Element(const EntryState &)> transform
 
std::function< void()> on_change = [] {}
 Called when the user change the state.
 

Member Data Documentation

◆ label

ConstStringRef label = "Checkbox"

Definition at line 138 of file component_options.hpp.

◆ checked

Ref<bool> checked = false

Definition at line 140 of file component_options.hpp.

◆ transform

std::function<Element(const EntryState&)> transform

Definition at line 143 of file component_options.hpp.

◆ on_change

std::function<void()> on_change = [] {}

Called when the user change the state.

Definition at line 147 of file component_options.hpp.

◆ ftxui::InputOption

struct ftxui::InputOption

Option for the Input component.

Definition at line 161 of file component_options.hpp.

Static Public Member Functions

static InputOption Default ()
 Create the default input style:
 
static InputOption Spacious ()
 A white on black style with high margins:
 

Public Attributes

StringRef content = ""
 The content of the input.
 
StringRef placeholder = ""
 The content of the input when it's empty.
 
std::function< Element(InputState)> transform
 
Ref< bool > password = false
 Obscure the input content using '*'.
 
Ref< bool > multiline = true
 Whether the input can be multiline.
 
Ref< bool > insert = true
 Insert or overtype character mode.
 
std::function< void()> on_change = [] {}
 Called when the content changes.
 
std::function< void()> on_enter = [] {}
 Called when the user presses enter.
 
Ref< int > cursor_position = 0
 

Member Data Documentation

◆ content

StringRef content = ""

The content of the input.

Definition at line 170 of file component_options.hpp.

◆ placeholder

StringRef placeholder = ""

The content of the input when it's empty.

Definition at line 173 of file component_options.hpp.

◆ transform

std::function<Element(InputState)> transform

Definition at line 176 of file component_options.hpp.

◆ password

Ref<bool> password = false

Obscure the input content using '*'.

Definition at line 177 of file component_options.hpp.

◆ multiline

Ref<bool> multiline = true

Whether the input can be multiline.

Definition at line 178 of file component_options.hpp.

◆ insert

Ref<bool> insert = true

Insert or overtype character mode.

Definition at line 179 of file component_options.hpp.

◆ on_change

std::function<void()> on_change = [] {}

Called when the content changes.

Definition at line 182 of file component_options.hpp.

◆ on_enter

std::function<void()> on_enter = [] {}

Called when the user presses enter.

Definition at line 184 of file component_options.hpp.

◆ cursor_position

Ref<int> cursor_position = 0

Definition at line 187 of file component_options.hpp.

◆ ftxui::RadioboxOption

struct ftxui::RadioboxOption

Option for the Radiobox component.

Definition at line 192 of file component_options.hpp.

Static Public Member Functions

static RadioboxOption Simple ()
 Option for standard Radiobox.
 

Public Attributes

ConstStringListRef entries
 
Ref< int > selected = 0
 
std::function< Element(const EntryState &)> transform
 
std::function< void()> on_change = [] {}
 Called when the selected entry changes.
 
Ref< int > focused_entry = 0
 

Member Data Documentation

◆ entries

Definition at line 197 of file component_options.hpp.

◆ selected

Ref<int> selected = 0

Definition at line 198 of file component_options.hpp.

◆ transform

std::function<Element(const EntryState&)> transform

Definition at line 201 of file component_options.hpp.

◆ on_change

std::function<void()> on_change = [] {}

Called when the selected entry changes.

Definition at line 205 of file component_options.hpp.

◆ focused_entry

Ref<int> focused_entry = 0

Definition at line 206 of file component_options.hpp.

◆ ftxui::DropdownOption

struct ftxui::DropdownOption

Option for the Dropdown component.

A dropdown menu is a checkbox opening/closing a radiobox.

Definition at line 269 of file component_options.hpp.

Public Attributes

Ref< bool > open = false
 Whether the dropdown is open or closed:
 
CheckboxOption checkbox
 
RadioboxOption radiobox
 
std::function< Element(bool open, Element checkbox, Element radiobox)> transform
 

Member Data Documentation

◆ open

Ref<bool> open = false

Whether the dropdown is open or closed:

Definition at line 271 of file component_options.hpp.

◆ checkbox

CheckboxOption checkbox

Definition at line 273 of file component_options.hpp.

◆ radiobox

RadioboxOption radiobox

Definition at line 275 of file component_options.hpp.

◆ transform

std::function<Element(bool open, Element checkbox, Element radiobox)> transform

Definition at line 278 of file component_options.hpp.

◆ ftxui::Mouse

struct ftxui::Mouse

A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift, ctrl, meta).

Definition at line 11 of file mouse.hpp.

Public Types

enum  Button {
  Left = 0 ,
  Middle = 1 ,
  Right = 2 ,
  None = 3 ,
  WheelUp = 4 ,
  WheelDown = 5 ,
  WheelLeft = 6 ,
  WheelRight = 7
}
 
enum  Motion {
  Released = 0 ,
  Pressed = 1 ,
  Moved = 2
}
 

Public Attributes

Button button = Button::None
 
Motion motion = Motion::Pressed
 
bool shift = false
 
bool meta = false
 
bool control = false
 
int x = 0
 
int y = 0
 

Member Enumeration Documentation

◆ Button

enum Button
Enumerator
Left 
Middle 
Right 
None 
WheelUp 
WheelDown 
WheelLeft 
WheelRight 

Supported terminal only.

Definition at line 12 of file mouse.hpp.

◆ Motion

enum Motion
Enumerator
Released 
Pressed 
Moved 

Definition at line 23 of file mouse.hpp.

Member Data Documentation

◆ button

Button button = Button::None

Definition at line 30 of file mouse.hpp.

◆ motion

Definition at line 33 of file mouse.hpp.

◆ shift

bool shift = false

Definition at line 36 of file mouse.hpp.

◆ meta

bool meta = false

Definition at line 37 of file mouse.hpp.

◆ control

bool control = false

Definition at line 38 of file mouse.hpp.

◆ x

int x = 0

Definition at line 41 of file mouse.hpp.

◆ y

int y = 0

Definition at line 42 of file mouse.hpp.

Function Documentation

◆ Button() [1/2]

Component Button ( ButtonOption option)

Draw a button. Execute a function when clicked.

Parameters
optionAdditional optional parameters.
See also
ButtonBase

Example

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

Output

┌─────────────┐
│Click to quit│
└─────────────┘

Definition at line 176 of file src/ftxui/component/button.cpp.

◆ Button() [2/2]

Component Button ( ConstStringRef label,
std::function< void()> on_click,
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)

Output

┌─────────────┐
│Click to quit│
└─────────────┘

Definition at line 204 of file src/ftxui/component/button.cpp.

◆ CatchEvent() [1/2]

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.

Parameters
childThe wrapped component.
on_eventThe function drawing the interface.

Example

auto renderer = Renderer([] {
return text("My interface");
});
auto component = CatchEvent(renderer, [&](Event event) {
if (event == Event::Character('q')) {
screen.ExitLoopClosure()();
return true;
}
return false;
});
screen.Loop(component);
static ScreenInteractive TerminalOutput()
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
Component CatchEvent(Component child, std::function< bool(Event)>)

Definition at line 54 of file catch_event.cpp.

◆ CatchEvent() [2/2]

ComponentDecorator CatchEvent ( std::function< bool(Event)> on_event)

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

Parameters
on_eventThe function drawing the interface.

Example

auto renderer = Renderer([] { return text("Hello world"); });
renderer |= CatchEvent([&](Event event) {
if (event == Event::Character('q')) {
screen.ExitLoopClosure()();
return true;
}
return false;
});
screen.Loop(renderer);

Definition at line 80 of file catch_event.cpp.

◆ Checkbox() [1/2]

Component Checkbox ( CheckboxOption option)

Draw checkable element.

Parameters
optionAdditional optional parameters.
See also
CheckboxBase

Example

option.label = "Make a sandwidth";
option.checked = false;
Component checkbox = Checkbox(option);
screen.Loop(checkbox)
Component Checkbox(CheckboxOption options)
Draw checkable element.
Option for the Checkbox component.

Output

☐ Make a sandwitch

Definition at line 108 of file src/ftxui/component/checkbox.cpp.

◆ Checkbox() [2/2]

Component Checkbox ( ConstStringRef label,
bool * checked,
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)

Output

☐ Make a sandwitch

Definition at line 135 of file src/ftxui/component/checkbox.cpp.

◆ Vertical() [1/3]

Component Vertical ( Components children)

A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys.

Parameters
childrenthe list of components.
See also
ContainerBase

Example

auto container = Container::Vertical({
children_1,
children_2,
children_3,
children_4,
});
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...

Definition at line 317 of file container.cpp.

◆ Vertical() [2/3]

Component Vertical ( Components children,
int * selector )

A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys. This is useful for implementing a Menu for instance.

Parameters
childrenthe list of components.
selectorA reference to the index of the selected children.
See also
ContainerBase

Example

auto container = Container::Vertical({
children_1,
children_2,
children_3,
children_4,
}, &selected_children);

Definition at line 339 of file container.cpp.

◆ Horizontal() [1/3]

Component Horizontal ( Components children)

A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys.

Parameters
childrenthe list of components.
See also
ContainerBase

Example

int selected_children = 2;
auto container = Container::Horizontal({
children_1,
children_2,
children_3,
children_4,
});
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...

Definition at line 360 of file container.cpp.

◆ Horizontal() [2/3]

Component Horizontal ( Components children,
int * selector )

A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow key or 'h'/'l' keys.

Parameters
childrenthe list of components.
selectorA reference to the index of the selected children.
See also
ContainerBase

Example

int selected_children = 2;
auto container = Container::Horizontal({
children_1,
children_2,
children_3,
children_4,
}, selected_children);

Definition at line 382 of file container.cpp.

◆ Tab()

Component Tab ( Components children,
int * selector )

A list of components, where only one is drawn and interacted with at a time. The |selector| gives the index of the selected component. This is useful to implement tabs.

Parameters
childrenThe list of components.
selectorThe index of the drawn children.
See also
ContainerBase

Example

int tab_drawn = 0;
auto container = Container::Tab({
children_1,
children_2,
children_3,
children_4,
}, &tab_drawn);
Component Tab(Components children, int *selector)
A list of components, where only one is drawn and interacted with at a time. The |selector| gives the...

Definition at line 405 of file container.cpp.

◆ Stacked()

Component Stacked ( Components children)

A list of components to be stacked on top of each other. Events are propagated to the first component, then the second if not handled, etc. The components are drawn in the reverse order they are given. When a component take focus, it is put at the front, without changing the relative order of the other elements.

This should be used with the Window component.

Parameters
childrenThe list of components.
See also
Window

Example

auto container = Container::Stacked({
children_1,
children_2,
children_3,
children_4,
});
Component Stacked(Components children)
A list of components to be stacked on top of each other. Events are propagated to the first component...

Definition at line 432 of file container.cpp.

◆ Dropdown() [1/2]

Component Dropdown ( ConstStringListRef entries,
int * selected )

A dropdown menu.

Parameters
entriesThe list of entries to display.
selectedThe index of the selected entry.

Definition at line 22 of file src/ftxui/component/dropdown.cpp.

◆ Dropdown() [2/2]

Component Dropdown ( DropdownOption option)

A dropdown menu.

Parameters
optionThe options for the dropdown.

Definition at line 33 of file src/ftxui/component/dropdown.cpp.

◆ Hoverable() [1/6]

Component Hoverable ( Component component,
bool * hover )

Wrap a component. Gives the ability to know if it is hovered by the mouse.

Parameters
componentThe wrapped component.
hoverThe value to reflect whether the component is hovered or not.

Example

auto button = Button("exit", screen.ExitLoopClosure());
bool hover = false;
auto button_hover = Hoverable(button, &hover);
Component Hoverable(Component component, bool *hover)
Wrap a component. Gives the ability to know if it is hovered by the mouse.
Definition hoverable.cpp:43

Definition at line 43 of file hoverable.cpp.

◆ Hoverable() [2/6]

Component Hoverable ( Component component,
std::function< void()> on_enter,
std::function< void()> on_leave )

Wrap a component. Uses callbacks.

Parameters
componentThe wrapped component.
on_enterCallback OnEnter
on_leaveCallback OnLeave

Example

auto button = Button("exit", screen.ExitLoopClosure());
bool hover = false;
auto button_hover = Hoverable(button, &hover);

Definition at line 86 of file hoverable.cpp.

◆ Hoverable() [3/6]

ComponentDecorator Hoverable ( bool * hover)

Wrap a component. Gives the ability to know if it is hovered by the mouse.

Parameters
hoverThe value to reflect whether the component is hovered or not.

Example

bool hover = false;
auto button = Button("exit", screen.ExitLoopClosure());
button |= Hoverable(&hover);

Definition at line 141 of file hoverable.cpp.

◆ Hoverable() [4/6]

ComponentDecorator Hoverable ( std::function< void()> on_enter,
std::function< void()> on_leave )

Wrap a component. Gives the ability to know if it is hovered by the mouse.

Parameters
on_enteris called when the mouse hover the component.
on_leaveis called when the mouse leave the component.

Example

auto button = Button("exit", screen.ExitLoopClosure());
int on_enter_cnt = 0;
int on_leave_cnt = 0;
button |= Hoverable(
[&]{ on_enter_cnt++; },
[&]{ on_leave_cnt++; }
);

Definition at line 165 of file hoverable.cpp.

◆ Hoverable() [5/6]

Component Hoverable ( Component component,
std::function< void(bool)> on_change )

Wrap a component. Gives the ability to know if it is hovered by the mouse.

Parameters
componentthe wrapped component.
on_changeis called when the mouse enter or leave the component.

Example

auto button = Button("exit", screen.ExitLoopClosure());
bool hovered = false;
auto button_hoverable = Hoverable(button,
[&](bool hover) { hovered = hover;});

Definition at line 188 of file hoverable.cpp.

◆ Hoverable() [6/6]

ComponentDecorator Hoverable ( std::function< void(bool)> on_change)

Wrap a component. Gives the ability to know if it is hovered by the mouse.

Parameters
on_changeis called when the mouse enter or leave the component.

Example

auto button = Button("exit", screen.ExitLoopClosure());
bool hovered = false;
button |= Hoverable([&](bool hover) { hovered = hover;});

Definition at line 209 of file hoverable.cpp.

◆ Input() [1/3]

Component Input ( InputOption option)

An input box for editing text.

Parameters
optionAdditional optional parameters.
See also
InputBase

Example

std::string content= "";
std::string placeholder = "placeholder";
Component input = Input({
.content = &content,
.placeholder = &placeholder,
})
screen.Loop(input);
Component Input(InputOption options={})
An input box for editing text.

Output

placeholder

Definition at line 571 of file src/ftxui/component/input.cpp.

◆ Input() [2/3]

Component Input ( StringRef content,
InputOption option )

An input box for editing text.

Parameters
contentThe editable content.
optionAdditional optional parameters.
See also
InputBase

Example

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

Output

placeholder

Definition at line 599 of file src/ftxui/component/input.cpp.

◆ Input() [3/3]

Component Input ( StringRef content,
StringRef placeholder,
InputOption option )

An input box for editing text.

Parameters
contentThe editable content.
placeholderThe placeholder text.
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 626 of file src/ftxui/component/input.cpp.

◆ Maybe() [1/4]

Component Maybe ( Component child,
std::function< bool()> show )

Decorate a component |child|. It is shown only when |show| returns true.

Parameters
childthe component to decorate.
showa function returning whether |child| should shown.

Definition at line 21 of file src/ftxui/component/maybe.cpp.

◆ Maybe() [2/4]

ComponentDecorator Maybe ( std::function< bool()> show)

Decorate a component. It is shown only when the |show| function returns true.

Parameters
showa function returning whether the decorated component should be shown.

Example

auto component = Renderer([]{ return text("Hello World!"); });
auto maybe_component = component | Maybe([&]{ return counter == 42; });
Component Maybe(Component, const bool *show)
Decorate a component |child|. It is shown only when |show| is true.

Definition at line 57 of file src/ftxui/component/maybe.cpp.

◆ Maybe() [3/4]

Component Maybe ( Component child,
const bool * show )

Decorate a component |child|. It is shown only when |show| is true.

Parameters
childthe component to decorate.
showa boolean. |child| is shown when |show| is true.

Example

auto component = Renderer([]{ return text("Hello World!"); });
auto maybe_component = Maybe(component, &show);

Definition at line 74 of file src/ftxui/component/maybe.cpp.

◆ Maybe() [4/4]

ComponentDecorator Maybe ( const bool * show)

Decorate a component. It is shown only when |show| is true.

Parameters
showa boolean. |child| is shown when |show| is true.

Example

auto component = Renderer([]{ return text("Hello World!"); });
auto maybe_component = component | Maybe(&show);

Definition at line 88 of file src/ftxui/component/maybe.cpp.

◆ Menu() [1/2]

Component Menu ( MenuOption option)

A list of text. The focused element is selected.

Parameters
optiona structure containing all the paramters.

Example

std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Menu({
.entries = &entries,
.selected = &selected,
});
screen.Loop(menu);
Component Menu(MenuOption options)
A list of text. The focused element is selected.

Output

> entry 1
entry 2
entry 3

Definition at line 512 of file src/ftxui/component/menu.cpp.

◆ Menu() [2/2]

Component Menu ( ConstStringListRef entries,
int * selected,
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.

Example

std::vector<std::string> entries = {
"entry 1",
"entry 2",
"entry 3",
};
int selected = 0;
auto menu = Menu(&entries, &selected);
screen.Loop(menu);

Output

> entry 1
entry 2
entry 3

Definition at line 543 of file src/ftxui/component/menu.cpp.

◆ Toggle() [1/2]

Component Toggle ( ConstStringListRef entries,
int * selected )

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

Parameters
entriesThe list of selectable entries to display.
selectedReference the selected entry. See also |Menu|.

Definition at line 554 of file src/ftxui/component/menu.cpp.

◆ MenuEntry() [1/2]

Component MenuEntry ( ConstStringRef label,
MenuEntryOption option )

A specific menu entry. They can be put into a Container::Vertical to form a menu.

Parameters
labelThe text drawn representing this element.
optionAdditional optional parameters.

Example

int selected = 0;
auto menu = Container::Vertical({
MenuEntry("entry 1"),
MenuEntry("entry 2"),
MenuEntry("entry 3"),
}, &selected);
screen.Loop(menu);
Component MenuEntry(MenuEntryOption options)
A specific menu entry. They can be put into a Container::Vertical to form a menu.

Output

> entry 1
entry 2
entry 3

Definition at line 584 of file src/ftxui/component/menu.cpp.

◆ MenuEntry() [2/2]

Component MenuEntry ( MenuEntryOption option)

A specific menu entry. They can be put into a Container::Vertical to form a menu.

Parameters
optionThe parameters.

Example

int selected = 0;
auto menu = Container::Vertical({
MenuEntry({.label = "entry 1"}),
MenuEntry({.label = "entry 2"}),
MenuEntry({.label = "entry 3"}),
}, &selected);
screen.Loop(menu);

Output

> entry 1
entry 2
entry 3

Definition at line 614 of file src/ftxui/component/menu.cpp.

◆ Modal() [1/2]

Component Modal ( Component main,
Component modal,
const bool * show_modal )

Definition at line 18 of file modal.cpp.

◆ Modal() [2/2]

ComponentDecorator Modal ( Component modal,
const bool * show_modal )

Definition at line 58 of file modal.cpp.

◆ Radiobox() [1/2]

Component Radiobox ( RadioboxOption option)

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

Parameters
optionThe parameters
See also
RadioboxBase

Example

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

Output

◉ entry 1
○ entry 2
○ entry 3

NOLINTNEXTLINE

Definition at line 204 of file src/ftxui/component/radiobox.cpp.

◆ Radiobox() [2/2]

Component Radiobox ( ConstStringListRef entries,
int * selected,
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);

Output

◉ entry 1
○ entry 2
○ entry 3

Definition at line 236 of file src/ftxui/component/radiobox.cpp.

◆ Renderer() [1/4]

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 29 of file src/ftxui/component/renderer.cpp.

◆ Renderer() [2/4]

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);
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Definition node.cpp:63
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94

Definition at line 61 of file src/ftxui/component/renderer.cpp.

◆ Renderer() [3/4]

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:34

Definition at line 84 of file src/ftxui/component/renderer.cpp.

◆ Renderer() [4/4]

ComponentDecorator Renderer ( ElementDecorator decorator)

Decorate a component, by decorating what it renders.

Parameters
decoratorthe function modifying the element it renders.

Example

auto renderer = */
// Renderer([] { return text("Hello");)
/** | Renderer(bold)
| Renderer(inverted);
screen.Loop(renderer);

Definition at line 125 of file src/ftxui/component/renderer.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 ResizableSplitLeft(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Element center(Element)
Center an element horizontally and vertically.
std::uint8_t left
Definition screen.cpp:129
std::uint8_t right
Definition screen.cpp:131

Output

left │ right

Definition at line 215 of file src/ftxui/component/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

Definition at line 249 of file src/ftxui/component/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.
std::uint8_t top
Definition screen.cpp:130

Output

top
────────────
bottom

Definition at line 283 of file src/ftxui/component/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

Definition at line 317 of file src/ftxui/component/resizable_split.cpp.

◆ Slider()

Component Slider ( ConstStringRef label,
Ref< int > value,
ConstRef< int > min,
ConstRef< int > max,
ConstRef< int > 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(SliderOption< T > options)
A slider in any direction.

Output

Value:[██████████████████████████ ]

Definition at line 289 of file src/ftxui/component/slider.cpp.

◆ Window()

Component Window ( WindowOptions option)

A draggeable / resizeable window. To use multiple of them, they must be stacked using Container::Stacked({...}) component;.

Parameters
optionA struct holding every parameters.
See also
Window

Example

auto window_1= Window({
.inner = DummyWindowContent(),
.title = "First window",
});
auto window_2= Window({
.inner = DummyWindowContent(),
.title = "Second window",
});
auto container = Container::Stacked({
window_1,
window_2,
});
Component Window(WindowOptions option)
A draggeable / resizeable window. To use multiple of them, they must be stacked using Container::Stac...
Component DummyWindowContent()
Definition scrollbar.cpp:10

Definition at line 312 of file src/ftxui/component/window.cpp.

◆ Parent()

ComponentBase * Parent ( ) const

Return the parent ComponentBase, or nul if any.

See also
Detach
Parent

Definition at line 39 of file component.cpp.

◆ ChildAt()

Component & ChildAt ( size_t i)

Access the child at index i.

Definition at line 45 of file component.cpp.

◆ ChildCount()

size_t ChildCount ( ) const

Returns the number of children.

Definition at line 52 of file component.cpp.

◆ Index()

int Index ( ) const

Return index of the component in its parent. -1 if no parent.

Definition at line 58 of file component.cpp.

◆ Add()

void Add ( Component children)

Add a child. @param child The child to be attached.

Definition at line 75 of file component.cpp.

◆ Detach()

void Detach ( )

Detach this child from its parent.

See also
Detach
Parent

Definition at line 85 of file component.cpp.

◆ DetachAllChildren()

void DetachAllChildren ( )

Remove all children.

Definition at line 101 of file component.cpp.

◆ Render()

Element Render ( )

Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.

Definition at line 111 of file component.cpp.

◆ OnRender()

Element OnRender ( )
virtual

Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.

Definition at line 147 of file component.cpp.

◆ OnEvent()

bool OnEvent ( Event event)
virtual

Called in response to an event.

Parameters
eventThe event.
Returns
True when the event has been handled. The default implementation called OnEvent on every child until one return true. If none returns true, return false.

Definition at line 161 of file component.cpp.

◆ OnAnimation()

void OnAnimation ( animation::Params & params)
virtual

Called in response to an animation event.

Parameters
paramsthe parameters of the animation The default implementation dispatch the event to every child.

Definition at line 174 of file component.cpp.

◆ ActiveChild()

Component ActiveChild ( )
virtual

Return the currently Active child.

Returns
the currently Active child.

Definition at line 183 of file component.cpp.

◆ Focusable()

bool Focusable ( ) const
virtual

Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.

Definition at line 196 of file component.cpp.

◆ Active()

bool Active ( ) const

Returns if the element if the currently active child of its parent.

Definition at line 207 of file component.cpp.

◆ Focused()

bool Focused ( ) const

Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().

Definition at line 216 of file component.cpp.

◆ SetActiveChild() [1/2]

void SetActiveChild ( ComponentBase * child)
virtual

Make the |child| to be the "active" one.

Parameters
childthe child to become active.

Definition at line 227 of file component.cpp.

◆ SetActiveChild() [2/2]

void SetActiveChild ( Component child)

Make the |child| to be the "active" one.

Parameters
childthe child to become active.

Definition at line 232 of file component.cpp.

◆ TakeFocus()

void TakeFocus ( )

Configure all the ancestors to give focus to this component.

Definition at line 238 of file component.cpp.

◆ CaptureMouse() [1/2]

CapturedMouse CaptureMouse ( const Event & event)
protected

Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.

Parameters
eventThe event

Definition at line 250 of file component.cpp.

◆ Set()

void Set ( Color inactive,
Color active,
animation::Duration duration = std::chrono::milliseconds(250),
animation::easing::Function function = animation::easing::QuadraticInOut )

A color option that can be animated. @params _inactive The color when the component is inactive. @params _active The color when the component is active. @params _duration The duration of the animation. @params _function The easing function of the animation.

Definition at line 21 of file component_options.cpp.

◆ SetAnimation()

void SetAnimation ( animation::Duration d,
animation::easing::Function f )

Set how the underline should animate.

Parameters
dThe duration of the animation.
fThe easing function of the animation.

Definition at line 36 of file component_options.cpp.

◆ SetAnimationDuration()

void SetAnimationDuration ( animation::Duration d)

Set how the underline should animate.

Parameters
dThe duration of the animation.

Definition at line 45 of file component_options.cpp.

◆ SetAnimationFunction() [1/2]

void SetAnimationFunction ( animation::easing::Function f)

Set how the underline should animate.

Parameters
fThe easing function of the animation.

Definition at line 53 of file component_options.cpp.

◆ SetAnimationFunction() [2/2]

void SetAnimationFunction ( animation::easing::Function f_leader,
animation::easing::Function f_follower )

Set how the underline should animate. This is useful to desynchronize the animation of the leader and the follower.

Parameters
f_leaderThe duration of the animation for the leader.
f_followerThe duration of the animation for the follower.

Definition at line 64 of file component_options.cpp.

◆ Horizontal() [3/3]

MenuOption Horizontal ( )
static

Standard options for a horizontal menu. This can be useful to implement a tab bar.

Definition at line 75 of file component_options.cpp.

◆ HorizontalAnimated()

MenuOption HorizontalAnimated ( )
static

Standard options for an animated horizontal menu. This can be useful to implement a tab bar.

Definition at line 100 of file component_options.cpp.

◆ Vertical() [3/3]

MenuOption Vertical ( )
static

Standard options for a vertical menu. This can be useful to implement a list of selectable items.

Definition at line 110 of file component_options.cpp.

◆ VerticalAnimated()

MenuOption VerticalAnimated ( )
static

Standard options for an animated vertical menu. This can be useful to implement a list of selectable items.

Definition at line 132 of file component_options.cpp.

◆ Toggle() [2/2]

MenuOption Toggle ( )
static

Standard options for a horizontal menu with some separator. This can be useful to implement a tab bar.

Definition at line 155 of file component_options.cpp.

◆ Ascii()

ButtonOption Ascii ( )
static

Create a ButtonOption, highlighted using [] characters.

Definition at line 164 of file component_options.cpp.

◆ Simple() [1/3]

ButtonOption Simple ( )
static

Create a ButtonOption, inverted when focused.

Definition at line 177 of file component_options.cpp.

◆ Border()

ButtonOption Border ( )
static

Create a ButtonOption. The button is shown using a border, inverted when focused. This is the current default.

Definition at line 192 of file component_options.cpp.

◆ Animated() [1/4]

ButtonOption Animated ( )
static

Create a ButtonOption, using animated colors.

Definition at line 210 of file component_options.cpp.

◆ Animated() [2/4]

ButtonOption Animated ( Color color)
static

Create a ButtonOption, using animated colors.

Definition at line 218 of file component_options.cpp.

◆ Animated() [3/4]

ButtonOption Animated ( Color background,
Color foreground )
static

Create a ButtonOption, using animated colors.

Definition at line 229 of file component_options.cpp.

◆ Animated() [4/4]

ButtonOption Animated ( Color background,
Color foreground,
Color background_active,
Color foreground_active )
static

Create a ButtonOption, using animated colors.

Definition at line 242 of file component_options.cpp.

◆ Simple() [2/3]

CheckboxOption Simple ( )
static

Option for standard Checkbox.

Definition at line 262 of file component_options.cpp.

◆ Simple() [3/3]

RadioboxOption Simple ( )
static

Option for standard Radiobox.

Definition at line 287 of file component_options.cpp.

◆ Default()

InputOption Default ( )
static

Create the default input style:

Standard options for the input component.

Definition at line 312 of file component_options.cpp.

◆ Spacious()

InputOption Spacious ( )
static

A white on black style with high margins:

Standard options for a more beautiful input component.

Definition at line 335 of file component_options.cpp.

◆ Character() [1/3]

Event Character ( std::string input)
static

An event corresponding to a given typed character.

Parameters
inputThe character typed by the user.

Definition at line 29 of file event.cpp.

◆ Character() [2/3]

Event Character ( char c)
static

An event corresponding to a given typed character.

Parameters
cThe character typed by the user.

Definition at line 40 of file event.cpp.

◆ Character() [3/3]

Event Character ( wchar_t c)
static

An event corresponding to a given typed character.

Parameters
cThe character typed by the user.

Definition at line 48 of file event.cpp.

◆ Mouse()

Event Mouse ( std::string input,
Mouse mouse )
static

An event corresponding to a given typed character.

Parameters
inputThe sequence of character send by the terminal.
mouseThe mouse state.

Definition at line 57 of file event.cpp.

◆ Special()

Event Special ( std::string input)
static

An custom event whose meaning is defined by the user of the library.

Parameters
inputAn arbitrary sequence of character defined by the developer.

Definition at line 79 of file event.cpp.

◆ Loop() [1/2]

Loop ( ScreenInteractive * screen,
Component component )

A Loop is a wrapper around a Component and a ScreenInteractive. It is used to run a Component in a terminal.

See also
Component, ScreenInteractive.
ScreenInteractive::Loop().
ScreenInteractive::ExitLoop().
Parameters
[in]screenThe screen to use.
[in]componentThe component to run.

Definition at line 21 of file loop.cpp.

◆ HasQuitted()

bool HasQuitted ( )

Whether the loop has quitted.

Definition at line 32 of file loop.cpp.

◆ Fullscreen()

ScreenInteractive Fullscreen ( )
static

Create a ScreenInteractive taking the full terminal size. This is using the alternate screen buffer to avoid messing with the terminal content.

Note
This is the same as ScreenInteractive::FullscreenAlternateScreen()

Definition at line 374 of file screen_interactive.cpp.

◆ FullscreenPrimaryScreen()

ScreenInteractive FullscreenPrimaryScreen ( )
static

Create a ScreenInteractive taking the full terminal size. The primary screen buffer is being used. It means if the terminal is resized, the previous content might mess up with the terminal content.

Definition at line 383 of file screen_interactive.cpp.

◆ FullscreenAlternateScreen()

ScreenInteractive FullscreenAlternateScreen ( )
static

Create a ScreenInteractive taking the full terminal size. This is using the alternate screen buffer to avoid messing with the terminal content.

Definition at line 396 of file screen_interactive.cpp.

◆ TrackMouse()

void TrackMouse ( bool enable = true)

Set whether mouse is tracked and events reported. called outside of the main loop. E.g ScreenInteractive::Loop(...).

Parameters
enableWhether to enable mouse event tracking.
Note
This muse be called outside of the main loop. E.g. before calling ScreenInteractive::Loop.
Mouse tracking is enabled by default.
Mouse tracking is only supported on terminals that supports it.

Example

screen.TrackMouse(false);
screen.Loop(component);

Definition at line 441 of file screen_interactive.cpp.

◆ Post()

void Post ( Task task)

Add a task to the main loop. It will be executed later, after every other scheduled tasks.

Definition at line 448 of file screen_interactive.cpp.

◆ PostEvent()

void PostEvent ( Event event)

Add an event to the main loop. It will be executed later, after every other scheduled events.

Definition at line 461 of file screen_interactive.cpp.

◆ CaptureMouse() [2/2]

CapturedMouse CaptureMouse ( )

Try to get the unique lock about behing able to capture the mouse.

Returns
A unique lock if the mouse is not already captured, otherwise a null.

Definition at line 483 of file screen_interactive.cpp.

◆ Loop() [2/2]

void Loop ( Component component)

Execute the main loop.

Parameters
componentThe component to draw.

Definition at line 495 of file screen_interactive.cpp.

◆ ExitLoopClosure()

Closure ExitLoopClosure ( )

Return a function to exit the main loop.

Definition at line 1026 of file screen_interactive.cpp.

◆ Exit()

void Exit ( )

Exit the main loop.

Definition at line 1032 of file screen_interactive.cpp.