2018-10-21 20:32:25 +08:00
|
|
|
Table of content.
|
|
|
|
- [DOM](#dom)
|
|
|
|
* [Style](#style)
|
|
|
|
* [Layout](#layout)
|
|
|
|
* [Widget.](#widget)
|
|
|
|
+ [text](#text)
|
|
|
|
+ [frame](#frame)
|
|
|
|
+ [separator](#separator)
|
|
|
|
+ [gauge](#gauge)
|
|
|
|
- [Components.](#components)
|
|
|
|
* [Input](#input)
|
|
|
|
* [Menu](#menu)
|
|
|
|
* [Toggle.](#toggle)
|
|
|
|
|
|
|
|
## DOM
|
2018-10-10 01:06:03 +08:00
|
|
|
All the dom element are declared in one header:
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~cpp
|
2018-10-10 01:06:03 +08:00
|
|
|
#include <ftxui/dom/elements.hpp>
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
It declares the following set of elements:
|
|
|
|
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~cpp
|
2018-10-10 01:06:03 +08:00
|
|
|
// --- Layout ----
|
|
|
|
Element vbox(Children);
|
|
|
|
Element hbox(Children);
|
|
|
|
Element flex();
|
2019-01-03 05:33:59 +08:00
|
|
|
Element flex(Element);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
// --- Widget --
|
|
|
|
Element text(std::wstring text);
|
|
|
|
Element separator();
|
|
|
|
Element gauge(float ratio);
|
|
|
|
Element frame(Child);
|
|
|
|
Element frame(Child title, Child content);
|
|
|
|
|
2019-01-03 05:33:59 +08:00
|
|
|
// -- Style ---
|
2018-10-10 01:06:03 +08:00
|
|
|
Element bold(Element);
|
|
|
|
Element dim(Element);
|
|
|
|
Element inverted(Element);
|
|
|
|
Element underlined(Element);
|
2019-01-03 05:33:59 +08:00
|
|
|
Element blink(Element);
|
|
|
|
Element color(Color, Element);
|
|
|
|
Element bgcolor(Color, Element);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-03 05:33:59 +08:00
|
|
|
// --- Util ---
|
2018-10-10 01:06:03 +08:00
|
|
|
Element hcenter(Element);
|
|
|
|
Element vcenter(Element);
|
|
|
|
Element center(Element);
|
2019-01-03 05:33:59 +08:00
|
|
|
|
|
|
|
// --- Util ---
|
|
|
|
Element nothing(Element element);
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
### Style
|
|
|
|
A terminal console can usually display colored text and colored background.
|
2019-01-03 05:33:59 +08:00
|
|
|
The text can also have different effects: bold, dim, underlined, inverted,
|
|
|
|
blink.
|
2018-10-21 20:32:25 +08:00
|
|
|
|
|
|
|
~~~cpp
|
|
|
|
Element bold(Element);
|
|
|
|
Element dim(Element);
|
|
|
|
Element inverted(Element);
|
|
|
|
Element underlined(Element);
|
|
|
|
Element blink(Element);
|
|
|
|
Element color(Color, Element);
|
|
|
|
Element bgcolor(Color, Element);
|
|
|
|
~~~
|
|
|
|
|
|
|
|
### Layout
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
vbox (Vertical-box) and hbox (Horizontal-box) are containers. They are used to
|
|
|
|
compose all the elements together. They will display their children one by one in one direction.
|
|
|
|
Each elements will occupy the space it required plus a fraction of the remaining
|
|
|
|
space dispatched to all the flexible elements.
|
|
|
|
|
|
|
|
flex() is used to make an element flexible.
|
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
#### Examples
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~cpp
|
2018-10-10 01:06:03 +08:00
|
|
|
hbox(
|
|
|
|
frame(text(L"left")),
|
|
|
|
flex(frame(text(L"middle"))),
|
|
|
|
frame(text(L"right"))
|
|
|
|
);
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
|
|
|
~~~bash
|
2018-10-10 01:06:03 +08:00
|
|
|
┌────┐┌─────────────────────────────────────────────────────────────────┐┌─────┐
|
|
|
|
│left││middle ││right│
|
|
|
|
└────┘└─────────────────────────────────────────────────────────────────┘└─────┘
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~cpp
|
2018-10-10 01:06:03 +08:00
|
|
|
hbox(
|
|
|
|
frame(text(L"left")),
|
|
|
|
flex(frame(text(L"middle"))),
|
|
|
|
flex(frame(text(L"right")))
|
|
|
|
);
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
|
|
|
~~~bash
|
2018-10-10 01:06:03 +08:00
|
|
|
┌────┐┌───────────────────────────────────┐┌───────────────────────────────────┐
|
|
|
|
│left││middle ││right │
|
|
|
|
└────┘└───────────────────────────────────┘└───────────────────────────────────┘
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
### Widget.
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
#### text
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
The most simple widget. It display a text.
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~cpp
|
2018-10-10 01:06:03 +08:00
|
|
|
text(L"I am a piece of text");
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
|
|
|
~~~bash
|
2018-10-10 01:06:03 +08:00
|
|
|
I am a piece of text.
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
#### frame
|
2018-10-10 01:06:03 +08:00
|
|
|
Add a border arround an element
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~c+
|
2018-10-10 01:06:03 +08:00
|
|
|
frame(text(L"The element"))
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~bash
|
2018-10-10 01:06:03 +08:00
|
|
|
┌───────────┐
|
|
|
|
│The element│
|
|
|
|
└───────────┘
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
#### separator
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
Display a vertical or horizontal line to visually split the content of a
|
|
|
|
container in two.
|
|
|
|
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~cpp
|
2018-10-10 01:06:03 +08:00
|
|
|
frame(hbox(
|
2018-10-21 20:32:25 +08:00
|
|
|
vbox(
|
|
|
|
text(L"left top"),
|
|
|
|
text(L"left bottom")
|
|
|
|
),
|
|
|
|
separator(),
|
|
|
|
vbox(
|
|
|
|
text(L"right top"),
|
|
|
|
text(L"right bottom")
|
|
|
|
)
|
2018-10-10 01:06:03 +08:00
|
|
|
));
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~bash
|
2018-10-10 01:06:03 +08:00
|
|
|
┌───────────┬────────────┐
|
|
|
|
│left top │right top │
|
|
|
|
│left bottom│right bottom│
|
|
|
|
└───────────┴────────────┘
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
#### gauge
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
A gauge. It can be used to represent a progress bar.
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~c+
|
2018-10-10 01:06:03 +08:00
|
|
|
frame(gauge(0.5))
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~bash
|
2018-10-10 01:06:03 +08:00
|
|
|
┌────────────────────────────────────────────────────────────────────────────┐
|
|
|
|
│██████████████████████████████████████ │
|
|
|
|
└────────────────────────────────────────────────────────────────────────────┘
|
2018-10-21 20:14:46 +08:00
|
|
|
~~~
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
## Components.
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2018-10-21 20:32:25 +08:00
|
|
|
### Input
|
2019-01-03 05:33:59 +08:00
|
|
|
TODO(arthursonzogni): Add Video
|
2018-10-21 20:32:25 +08:00
|
|
|
### Menu
|
2019-01-03 05:33:59 +08:00
|
|
|
TODO(arthursonzogni): Add Video
|
2018-10-21 20:32:25 +08:00
|
|
|
### Toggle.
|
2019-01-03 05:33:59 +08:00
|
|
|
TODO(arthursonzogni): Add video
|