FTXUI
0.8.1
C++ functional terminal UI.
|
Welcome to the FTXUI documentation. Here, you will find the detail of every functions and classes.
Short example
main.cpp
output
CMakeLists.txt
Build
The project is split into 3 modules:
ftxui::Screen
, this is a grid of ftxui::Pixel
.ftxui::Element
. An element draws something on the ftxui::Screen
. It is responsive to the size of its container.ftxui::Component
. The use can navigates using the arrow keys and interact with widgets like checkbox/inputbox/... You can make you own components.It defines a ftxui::Screen
. This is a grid of ftxui::Pixel
. A Pixel represent a Unicode character and its associated style (bold, colors, etc...). The screen can be printed as a string using ftxui::Screen::ToString()
.
This module defines a hierarchical set of Element. An element manages layout and can be responsive to the terminal dimensions.
Example:
List of elements
You only need one header: ftxui/dom/elements.hpp
The most simple widget. It displays a text.
Add a border around an element
A ftxui::window
is a ftxui::border
, but with some text on top of the border. Add a border around an element
Display a vertical or horizontal line to visually split the content of a container in two.
A gauge. It can be used to represent a progress bar.
A terminal console can usually display colored text and colored background.
On most terminal the following colors are supported:
Example:
On terminal supporting 256 colors.
On terminal supporting trueColor, you can directly chose the 24bit RGB color:
There are two constructors:
A terminal console can usually display colored text and colored background. The text can also have different effects: bold, dim, underlined, inverted, blink.
Example:
Tips: The pipe operator can be used to chain Decorator:
These layout are similar to the HTML flexbox:
flex(element)
can be used to make a non-flexible element flexible. filler()
is a flexible empty element. You can use it align children on one side of the container.
An horizontal flow layout is implemented by:
Examples
The ftxui/component
directory defines the logic to get produce interactive component responding to user's events (keyboard, mouse, etc...)
A ftxui::ScreenInteractive
defines a main loop to render a component.
A ftxui::Component
is a shared pointer to a ftxui::ComponentBase
. The later defines
ftxui::ComponentBase::Render()
: How to render the interface.ftxui::ComponentBase::OnEvent()
: How to react to events.ftxui::ComponentBase::Add()
: Give a parent/child relation ship in between two component. This defines a tree a components, which help properly define how keyboard navigation works.Predefined components are available in ftxui/dom/component.hpp
:
Element are stateless object. On the other side, components are used when an internal state is needed. Components are used to interact with the user with its keyboard. They handle keyboard navigation, including component focus.
Produced by: ftxui::Input()
from "ftxui/component/component.hpp"
Produced by: ftxui::Menu()
from "ftxui/component/component.hpp"
Produced by: ftxui::Toggle()
from "ftxui/component/component.hpp"
Produced by: ftxui::Checkbox()
from "ftxui/component/component.hpp"
Produced by: ftxui::Radiobox()
from "ftxui/component/component.hpp"
Produced by: ftxui::Renderer()
from "ftxui/component/component.hpp". This component decorate another one by using a different function to render an interface.
Produced by: ftxui::CatchEvent()
from "ftxui/component/component.hpp". This component decorate another one and catch the events before the underlying component.
Produced by: ftxui::Container::Horizontal()
from "ftxui/component/component.hpp". It displays a list of components horizontally and handle keyboard/mouse navigation.
Produced by: ftxui::Container::Vertical()
from "ftxui/component/component.hpp". It displays a list of components vertically and handles keyboard/mouse navigation.
Produced by: ftxui::Container::Tab()
from "ftxui/component/component.hpp". It take a list of component and display only one of them. This is useful for implementing a tab bar.
Produced by:
ftxui::ResizableSplitLeft()
ftxui::ResizableSplitRight()
ftxui::ResizableSplitTop()
ftxui::ResizableSplitBottom()
from "ftxui/component/component.hpp"It defines an horizontal or vertical separation in between two children component. The position of the split is variable and controllable using the mouse.
Whenever a new group of events have been processed: keyboard, mouse, window resize, etc..., the ftxui::ScreenInteractive::Loop()
is responsible for drawing a new frame.
You might want to react to arbitrary events that are unknown to FTXUI. This can be achieve by posting events via ftxui::ScreenInteractive::PostEvent
, via a thread. You can post the eventftxui::Event::Custom
.
ftxui::ScreenInteractive::PostEvent
is thread safe.