border
Demo
#include <stdlib.h>
#include <memory>
auto document =
text("Line 1"),
text("Line 2"),
text("Line 3"),
}) | border,
text("Line 4"),
text("Line 5"),
text("Line 6"),
}) | border,
text("Line 7"),
text("Line 8"),
text("Line 9"),
}) | border,
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return EXIT_SUCCESS;
}
Element vbox(Elements children)
Un contenedor que muestra elementos verticalmente uno por uno.
return hbox({ text(std::to_string(int(progress *100))+"% ")|size(WIDTH, EQUAL, 5), gauge(progress), })
El espacio de nombres ftxui:: de FTXUI.
border_colored
Demo
#include <iostream>
#include <memory>
auto make_boxed = [] {
text("borderLight") | borderStyled(LIGHT, Color::Red),
text("borderDashed") | borderStyled(DASHED, Color::Green),
text("borderHeavy") | borderStyled(HEAVY, Color::Blue),
text("borderDouble") | borderStyled(DOUBLE, Color::Yellow),
text("borderRounded") | borderStyled(ROUNDED, Color::Cyan),
});
};
make_boxed(),
separator() | color(Color::Red),
make_boxed(),
separator() | color(Color::Red),
make_boxed(),
}) |
borderStyled(ROUNDED, Color::Red);
Screen::Create(Dimension::Fit(document), Dimension::Fit(document));
std::cout << std::endl;
}
border_style
Demo
#include <iostream>
#include <memory>
text("borderLight") | borderLight,
text("borderDashed") | borderDashed,
text("borderHeavy") | borderHeavy,
text("borderDouble") | borderDouble,
text("borderRounded") | borderRounded,
});
Screen::Create(Dimension::Fit(document), Dimension::Fit(document));
std::cout << std::endl;
}
canvas
Demo
#include <stdio.h>
#include <cmath>
#include <vector>
c.DrawText(0, 0,
"This is a canvas", [](
Pixel& p) {
});
c.DrawPointLine(10, 10, 80, 10, Color::Red);
c.DrawPointLine(80, 10, 80, 40, Color::Blue);
c.DrawPointLine(80, 40, 10, 10, Color::Green);
c.DrawPointCircle(30, 50, 20);
c.DrawPointCircleFilled(40, 40, 10);
std::vector<int> ys(100);
for (int x = 0; x < 100; x++) {
ys[x] = int(80 + 20 * cos(x * 0.2));
}
for (int x = 0; x < 99; x++) {
c.DrawPointLine(x, ys[x], x + 1, ys[x + 1], Color::Red);
}
auto document =
canvas(&c) | border;
auto screen = Screen::Create(Dimension::Fit(document));
getchar();
return 0;
}
Canvas es un búfer dibujable asociado con operaciones de dibujo.
Un carácter Unicode y su estilo asociado.
Element canvas(ConstRef< Canvas > canvas)
Produce un elemento a partir de un Canvas, o una referencia a un Canvas.
color_gallery
Demo
#include <memory>
#include <utility>
#include <vector>
text("Paleta de 16 colores:"),
separator(),
color(Color::Default, text("Default")),
color(Color::Black, text("Black")),
color(Color::GrayDark, text("GrayDark")),
color(Color::GrayLight, text("GrayLight")),
color(Color::White, text("White")),
color(Color::Blue, text("Blue")),
color(Color::BlueLight, text("BlueLight")),
color(Color::Cyan, text("Cyan")),
color(Color::CyanLight, text("CyanLight")),
color(Color::Green, text("Green")),
color(Color::GreenLight, text("GreenLight")),
color(Color::Magenta, text("Magenta")),
color(Color::MagentaLight, text("MagentaLight")),
color(Color::Red, text("Red")),
color(Color::RedLight, text("RedLight")),
color(Color::Yellow, text("Yellow")),
color(Color::YellowLight, text("YellowLight"))
),
bgcolor(Color::Default, text("Default")),
bgcolor(Color::Black, text("Black")),
bgcolor(Color::GrayDark, text("GrayDark")),
bgcolor(Color::GrayLight, text("GrayLight")),
bgcolor(Color::White, text("White")),
bgcolor(Color::Blue, text("Blue")),
bgcolor(Color::BlueLight, text("BlueLight")),
bgcolor(Color::Cyan, text("Cyan")),
bgcolor(Color::CyanLight, text("CyanLight")),
bgcolor(Color::Green, text("Green")),
bgcolor(Color::GreenLight, text("GreenLight")),
bgcolor(Color::Magenta, text("Magenta")),
bgcolor(Color::MagentaLight, text("MagentaLight")),
bgcolor(Color::Red, text("Red")),
bgcolor(Color::RedLight, text("RedLight")),
bgcolor(Color::Yellow, text("Yellow")),
bgcolor(Color::YellowLight, text("YellowLight"))
)
)
);
{
for (auto& column : info_columns) {
for (auto& it : column) {
column_elements.push_back(
}
}
separator(),
});
}
{
const int max_value = 255;
const int value_increment = 8;
const int hue_increment = 6;
int saturation = max_value;
for (int value = 0; value < max_value; value += 2 * value_increment) {
for (int hue = 0; hue < max_value; hue += hue_increment) {
line.push_back(
text("▀")
| color(Color::HSV(hue, saturation, value))
| bgcolor(Color::HSV(hue, saturation, value + value_increment)));
}
}
separator(),
});
}
auto terminal_info =
Terminal::ColorSupport() >= Terminal::Color::Palette16
? text(" Soporte de paleta de 16 colores : Sí")
: text(" Soporte de paleta de 16 colores : No"),
? text("Soporte de paleta de 256 colores : Sí")
: text("Soporte de paleta de 256 colores : No"),
? text(" Soporte de color verdadero : Sí")
: text(" Soporte de color verdadero : No"),
}) |
border;
text(" "),
text(" "),
}),
terminal_info});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
std::vector< std::vector< ftxui::ColorInfo > > ColorInfoSorted2D()
Color es una clase que representa un color en la interfaz de usuario de la terminal.
auto palette_256_color_display
El espacio de nombres ftxui::Terminal:: de FTXUI.
std::vector< Element > Elements
color_info_palette256
Demo
#include <utility>
#include <vector>
for (auto& column : info_columns) {
for (auto& it : column) {
column_elements.push_back(
hbox({
text(it.name),
}));
}
columns_elements.push_back(
vbox(std::move(column_elements)));
}
auto document =
hbox(std::move(columns_elements));
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
color_truecolor_HSV
Demo
#include <memory>
#include <utility>
int saturation = 255;
for (int value = 0; value < 255; value += 20) {
for (int hue = 0; hue < 255; hue += 2) {
line.push_back(text("▀")
| color(Color::HSV(hue, saturation, value))
| bgcolor(Color::HSV(hue, saturation, value + 10)));
}
}
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
color_truecolor_RGB
Demo
#include <memory>
#include <utility>
for (int value = 0; value < 255; value += 3) {
int v = value * value / 255;
red_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, 0)));
green_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, 0)));
blue_line.push_back(text(" ") | bgcolor(Color::RGB(0, 0, v)));
cyan_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, v)));
magenta_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, v)));
yellow_line.push_back(text(" ") | bgcolor(Color::RGB(v, v, 0)));
}
window(text(
"Colores primarios"),
hbox({text(
"Línea roja :"),
hbox(std::move(red_line))}),
hbox({text(
"Línea verde :"),
hbox(std::move(green_line))}),
hbox({text(
"Línea azul :"),
hbox(std::move(blue_line))}),
})),
window(text(
"Colores secundarios"),
hbox({text(
"Línea cian :"),
hbox(std::move(cyan_line))}),
hbox({text(
"Línea magenta :"),
hbox(std::move(magenta_line))}),
hbox({text(
"Línea amarilla:"),
hbox(std::move(yellow_line))}),
})),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
return window(text(title)|hcenter|bold, text("contenido")|hcenter|dim)|size(WIDTH
dbox
Demo
#include <memory>
auto document = dbox({
text("line_1"),
text("line_2"),
text("line_3"),
text("line_4"),
text("line_5"),
}) | border,
text("overlay") | border | center,
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
gauge
Demo
#include <chrono>
#include <iostream>
#include <string>
#include <thread>
using namespace std::chrono_literals;
std::string reset_position;
for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
std::string data_downloaded =
std::to_string(int(percentage * 5000)) + "/5000";
text("downloading:"),
gauge(percentage) | flex,
text(" " + data_downloaded),
});
std::cout << reset_position;
reset_position =
screen.ResetPosition();
std::this_thread::sleep_for(0.01s);
}
std::cout << std::endl;
}
Una cuadrícula rectangular de píxeles.
gauge_direction
Demo
#include <chrono>
#include <iostream>
#include <string>
#include <thread>
using namespace std::chrono_literals;
std::string reset_position;
for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
std::string data_downloaded =
std::to_string(int(percentage * 5000)) + "/5000";
auto gauge_up =
vtext("gauge vertical"),
separator(),
gaugeUp(percentage),
}) |
border;
auto gauge_down =
vtext("gauge vertical"),
separator(),
gaugeDown(percentage),
}) |
border;
auto gauge_right =
text("gauge horizontal"),
separator(),
gaugeRight(percentage),
}) |
border;
auto gauge_left =
text("gauge horizontal"),
separator(),
gaugeLeft(percentage),
}) |
border;
gauge_up,
filler(),
gauge_right,
filler(),
text(data_downloaded) | border | center,
filler(),
gauge_left,
}),
filler(),
gauge_down,
});
std::cout << reset_position;
reset_position =
screen.ResetPosition();
std::this_thread::sleep_for(0.01s);
}
std::cout << std::endl;
}
graph
Demo
#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <utility>
#include <vector>
class Graph {
public:
std::vector<int> operator()(int width, int height) const {
std::vector<int> output(width);
for (int i = 0; i < width; ++i) {
float v = 0;
v += 0.1f * sin((i + shift) * 0.1f);
v += 0.2f * sin((i + shift + 10) * 0.15f);
v += 0.1f * sin((i + shift) * 0.03f);
v *= height;
v += 0.5f * height;
output[i] = static_cast<int>(v);
}
return output;
}
int shift = 0;
};
std::vector<int>
triangle(
int width,
int height) {
std::vector<int> output(width);
for (int i = 0; i < width; ++i) {
output[i] = i % (height - 4) + 2;
}
return output;
}
using namespace std::chrono_literals;
Graph my_graph;
std::string reset_position;
for (int i = 0;; ++i) {
std::ignore = i;
graph(std::ref(my_graph)),
separator(),
}) | flex,
separator(),
graph(std::ref(my_graph)) | color(Color::BlueLight),
separator(),
graph(std::ref(my_graph)) | color(Color::RedLight),
separator(),
graph(std::ref(my_graph)) | color(Color::YellowLight),
}) | flex,
});
document |= border;
const int min_width = 40;
document |=
size(HEIGHT, GREATER_THAN, min_width);
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
std::cout << reset_position;
reset_position =
screen.ResetPosition();
const auto sleep_time = 0.03s;
std::this_thread::sleep_for(sleep_time);
my_graph.shift++;
}
return 0;
}
std::vector< int > triangle(int width, int height)
return dimx size(HEIGHT, EQUAL, dimy)
gridbox
Demo
#include <stdio.h>
#include <memory>
auto cell = [](const char* t) { return text(t) | border; };
auto document =
gridbox({
{
cell("north-west"),
cell("north"),
cell("north-east"),
},
{
cell("center-west"),
gridbox({
{
cell("center-north-west"),
cell("center-north-east"),
},
{
cell("center-south-west"),
cell("center-south-east"),
},
}),
cell("center-east"),
},
{
cell("south-west"),
cell("south"),
cell("south-east"),
},
});
auto screen = Screen::Create(Dimension::Fit(document));
getchar();
return 0;
}
hflow
Demo
#include <stdio.h>
#include <string>
auto make_box = [](
int dimx,
int dimy) {
std::string
title = std::to_string(dimx) +
"x" + std::to_string(dimy);
text("content") | hcenter | dim) |
};
auto style =
size(WIDTH, GREATER_THAN, 20) | border |
size(HEIGHT, GREATER_THAN, 30) |
size(WIDTH, LESS_THAN, 50);
auto document = hflow({
}) |
style;
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
getchar();
return 0;
}
Element make_box(int x, int y)
html_like
Demo
#include <chrono>
#include <iostream>
#include <string>
#include <thread>
using namespace std::chrono_literals;
auto img1 = []() { return text("img") | border; };
auto img2 = []() {
return vbox({text(
"big"), text(
"image")}) | border; };
std::string reset_position;
for (int i = 0;; ++i) {
auto document =
hflow(
paragraph("¡Hola mundo! Aquí hay una imagen:"), img1(),
paragraph(" Aquí hay un texto "), text("subrayado ") | underlined,
paragraph(" Aquí hay un texto "), text("negrita ") | bold,
paragraph("Hello world! Here is an image:"), img2(),
paragraph(
"Lorem Ipsum es simplemente un texto falso utilizado en la "
"composición y maquetación antes de la impresión. Lorem "
"Ipsum ha sido el texto de relleno estándar de la industria "
"desde el año 1500, cuando un impresor desconocido tomó una "
"galera de tipos y la mezcló de tal manera que logró hacer un "
"libro de muestras tipográficas. No solo sobrevivió 500 años, "
"sino que también se adaptó a la tipografía electrónica, "
"permaneciendo esencialmente sin cambios. Fue popularizado en "
"los años 60 con la publicación de hojas \"Letraset\" que "
"contenían pasajes de Lorem Ipsum, y más recientemente con el "
"software de autoedición, como Aldus PageMaker, que incluye "
"versiones de Lorem Ipsum."),
paragraph(" Aquí hay un texto "), text("tenue ") | dim,
paragraph("¡Hola mundo! Aquí hay una imagen:"), img1(),
paragraph(" Aquí hay un texto "), text("rojo ") | color(Color::Red),
paragraph(" Un spinner "), spinner(6, i / 10)) |
border;
auto screen = Screen::Create(Dimension::Fit(document));
std::cout << reset_position;
reset_position =
screen.ResetPosition();
std::this_thread::sleep_for(0.01s);
}
return 0;
}
linear_gradient
Demo
#include <memory>
auto document = text("gradient") | center;
.Angle(45)
.Stop(Color::DeepPink1)
.Stop(Color::DeepSkyBlue1));
auto screen = Screen::Create(Dimension::Full(), Dimension::Full());
return 0;
}
Una clase que representa la configuración para el efecto de color de gradiente lineal.
package_manager
Demo
#include <chrono>
#include <iostream>
#include <list>
#include <memory>
#include <string>
#include <thread>
#include <utility>
#include <vector>
std::string name;
int number_of_threads;
int downloaded;
};
std::list<Task> remaining_tasks = {
{"contact server ", 10, 0, 6 * 25},
{"download index.html ", 10, 0, 9 * 25},
{"download script.js ", 1, 0, 3 * 25},
{"download style.js ", 1, 0, 4 * 25},
{"download image.png ", 1, 0, 5 * 25},
{"download big_1.png ", 1, 0, 30 * 25},
{"download icon_1.png ", 1, 0, 7 * 25},
{"download icon_2.png ", 1, 0, 8 * 25},
{"download big_2.png ", 1, 0, 30 * 25},
{"download small_1.png ", 1, 0, 10 * 25},
{"download small_2.png ", 1, 0, 11 * 25},
{"download small_3.png ", 1, 0, 12 * 25},
};
std::list<Task> displayed_task;
int remaining_threads = 12;
int nb_queued = (int)remaining_tasks.size();
int nb_active = 0;
int nb_done = 0;
auto to_text = [](int number) {
return text(std::to_string(number)) |
size(WIDTH,
EQUAL, 3);
};
auto renderTask = [&](
const Task& task) {
auto style = (task.downloaded == task.size) ? dim : bold;
text(task.name) | style,
separator(),
to_text(task.downloaded),
text("/"),
to_text(task.size),
separator(),
gauge(task.downloaded / float(task.size)),
});
};
auto renderSummary = [&]() {
text("- done: "),
to_text(nb_done) | bold,
}) | color(Color::Green),
text("- active: "),
to_text(nb_active) | bold,
}) | color(Color::RedLight),
text("- queue: "),
to_text(nb_queued) | bold,
}) | color(Color::Red),
});
return window(text(
" Summary "), summary);
};
auto render = [&]() {
std::vector<Element> entries;
for (auto& task : displayed_task) {
entries.push_back(renderTask(task));
}
renderSummary(),
filler(),
}),
});
};
auto updateModel = [&]() {
for (auto& task : displayed_task) {
if (task.downloaded != task.size) {
task.downloaded++;
} else if (task.number_of_threads) {
remaining_threads += task.number_of_threads;
task.number_of_threads = 0;
nb_active--;
nb_done++;
}
}
if (remaining_tasks.size() &&
remaining_tasks.front().number_of_threads <= remaining_threads) {
remaining_threads -= remaining_tasks.front().number_of_threads;
displayed_task.push_back(remaining_tasks.front());
remaining_tasks.pop_front();
nb_queued--;
nb_active++;
}
};
std::string reset_position;
for (;;) {
auto document = render();
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
std::cout << reset_position;
reset_position =
screen.ResetPosition();
using namespace std::chrono_literals;
std::this_thread::sleep_for(0.01s);
if (nb_active + nb_queued == 0) {
break;
}
updateModel();
}
std::cout << std::endl;
}
std::variant< Event, Closure, AnimationTask > Task
paragraph
Demo
#include <chrono>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
using namespace std::chrono_literals;
std::string p =
R"(En la teoría de la probabilidad y la estadística, el teorema de Bayes (alternativamente ley de Bayes o regla de Bayes) describe la probabilidad de un evento, basándose en el conocimiento previo de las condiciones que podrían estar relacionadas con el evento. Por ejemplo, si el cáncer está relacionado con la edad, entonces, utilizando el teorema de Bayes, la edad de una persona puede utilizarse para evaluar con mayor precisión la probabilidad de que tenga cáncer, en comparación con la evaluación de la probabilidad de cáncer realizada sin el conocimiento de la edad de la persona. Una de las muchas aplicaciones del teorema de Bayes es la inferencia bayesiana, un enfoque particular de la inferencia estadística. Cuando se aplica, las probabilidades implicadas en el teorema de Bayes pueden tener diferentes interpretaciones de probabilidad. Con la interpretación de probabilidad bayesiana, el teorema expresa cómo un grado subjetivo de creencia debe cambiar racionalmente para tener en cuenta la disponibilidad de pruebas relacionadas. La inferencia bayesiana es fundamental para la estadística bayesiana.)";
std::string reset_position;
while (true) {
hflow(paragraph(p)),
separator(),
hflow(paragraph(p)),
separator(),
hflow(paragraph(p)),
separator(),
hflow(paragraph(p)),
}),
}) |
border;
document =
vbox(filler(), document);
auto screen = Screen::Create(Dimension::Full());
std::cout << reset_position;
reset_position =
screen.ResetPosition();
std::this_thread::sleep_for(0.01s);
}
return 0;
}
separator
Demo
#include <memory>
text("left-column"),
separator(),
center(text("top")) | flex,
separator(),
center(text("bottom")),
}) | flex,
separator(),
text("right-column"),
}) |
border;
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
separator_style
Demo
#include <iostream>
#include <memory>
text("separatorLight"),
separatorLight(),
hbox(text(
"left"), separatorLight(), text(
"right")),
}) | borderLight,
text("separatorDashed"),
separatorDashed(),
hbox(text(
"left"), separatorDashed(), text(
"right")),
}) | borderDashed,
text("separatorHeavy"),
separatorHeavy(),
hbox(text(
"left"), separatorHeavy(), text(
"right")),
}) | borderHeavy,
text("separatorDouble"),
separatorDouble(),
hbox(text(
"left"), separatorDouble(), text(
"right")),
}) | borderDouble,
});
Screen::Create(Dimension::Fit(document), Dimension::Fit(document));
std::cout << std::endl;
}
size
Demo
#include <memory>
#include <string>
#include <utility>
text("content") | hcenter | dim);
};
for (int x = 3; x < 30; ++x) {
}
auto document =
hbox(std::move(content));
auto screen = Screen::Create(Dimension::Fit(document));
return 0;
}
spinner
Demo
#include <chrono>
#include <iostream>
#include <string>
#include <thread>
#include <utility>
#include <vector>
using namespace std::chrono_literals;
std::string reset_position;
for (int index = 0; index < 200; ++index) {
std::vector<Element> entries;
for (int i = 0; i < 23; ++i) {
if (i != 0) {
entries.push_back(separator());
}
entries.push_back(
text(std::to_string(i)) |
size(WIDTH,
EQUAL, 2),
separator(),
spinner(i, index) | bold,
}));
}
vbox(std::move(entries)) | border,
filler(),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
std::cout << reset_position;
reset_position =
screen.ResetPosition();
std::this_thread::sleep_for(0.1s);
}
std::cout << std::endl;
}
style_blink
Demo
#include <memory>
auto document =
text("This text is "),
text("blink") | blink,
text(". Do you like it?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_bold
Demo
#include <memory>
auto document =
text("Este texto es "),
text("negrita") | bold,
text(". ¿Te gusta?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_color
Demo
#include <memory>
color(Color::Default, text("Default")),
color(Color::Black, text("Black")),
color(Color::GrayDark, text("GrayDark")),
color(Color::GrayLight, text("GrayLight")),
color(Color::White, text("White")),
color(Color::Blue, text("Blue")),
color(Color::BlueLight, text("BlueLight")),
color(Color::Cyan, text("Cyan")),
color(Color::CyanLight, text("CyanLight")),
color(Color::Green, text("Green")),
color(Color::GreenLight, text("GreenLight")),
color(Color::Magenta, text("Magenta")),
color(Color::MagentaLight, text("MagentaLight")),
color(Color::Red, text("Red")),
color(Color::RedLight, text("RedLight")),
color(Color::Yellow, text("Yellow")),
color(Color::YellowLight, text("YellowLight")),
color(0x66ff66_rgb, text("Phosphor")),
text("Skyblue to DeepSkyBlue")),
}),
bgcolor(Color::Default, text("Default")),
bgcolor(Color::Black, text("Black")),
bgcolor(Color::GrayDark, text("GrayDark")),
bgcolor(Color::GrayLight, text("GrayLight")),
bgcolor(Color::White, text("White")),
bgcolor(Color::Blue, text("Blue")),
bgcolor(Color::BlueLight, text("BlueLight")),
bgcolor(Color::Cyan, text("Cyan")),
bgcolor(Color::CyanLight, text("CyanLight")),
bgcolor(Color::Green, text("Green")),
bgcolor(Color::GreenLight, text("GreenLight")),
bgcolor(Color::Magenta, text("Magenta")),
bgcolor(Color::MagentaLight, text("MagentaLight")),
bgcolor(Color::Red, text("Red")),
bgcolor(Color::RedLight, text("RedLight")),
bgcolor(Color::Yellow, text("Yellow")),
bgcolor(Color::YellowLight, text("YellowLight")),
bgcolor(0x66ff66_rgb, text("Phosphor")),
text("Skyblue to DeepSkyBlue")),
}),
filler(),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_dim
Demo
#include <memory>
auto document =
text("This text is "),
text("dim") | dim,
text(". Do you like it?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_gallery
Demo
#include <memory>
auto document =
text("normal") , text(" ") ,
text("bold") | bold , text(" ") ,
text("italic") | italic , text(" ") ,
text("dim") | dim , text(" ") ,
text("inverted") | inverted , text(" ") ,
text("underlined") | underlined , text(" ") ,
text("underlinedDouble") | underlinedDouble , text(" ") ,
text("blink") | blink , text(" ") ,
text("strikethrough") | strikethrough , text(" ") ,
text("color") | color(Color::Blue) , text(" ") ,
text("bgcolor") | bgcolor(Color::Blue) , text(" ") ,
text("hyperlink") | hyperlink("https://github.com/ArthurSonzogni/FTXUI"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_hyperlink
Demo
#include <memory>
auto document =
text("Este texto es un "),
text("hipervínculo") | hyperlink("https://www.google.com"),
text(". ¿Te gusta?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_inverted
Demo
#include <memory>
text("Este texto esta "),
text("invertido") | inverted,
text(". Te gusta?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_italic
Demo
#include <memory>
text("This text is "),
text("italic") | italic,
text(". Do you like it?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_strikethrough
Demo
#include <memory>
auto document =
text("Este texto es "),
text("strikethrough") | strikethrough,
text(". ¿Te gusta?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_underlined
Demo
#include <memory>
auto document =
text("This text is "),
text("underlined") | underlined,
text(". Do you like it?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
style_underlined_double
Demo
#include <memory>
auto document =
text("Este texto está "),
text("subrayado doble") | underlinedDouble,
text(". ¿Te gusta?"),
});
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
return 0;
}
table
Demo
#include <iostream>
#include <string>
#include <vector>
{"Version", "Marketing name", "Release date", "API level", "Runtime"},
{"2.3", "Gingerbread", "February 9 2011", "10", "Dalvik 1.4.0"},
{"4.0", "Ice Cream Sandwich", "October 19 2011", "15", "Dalvik"},
{"4.1", "Jelly Bean", "July 9 2012", "16", "Dalvik"},
{"4.2", "Jelly Bean", "November 13 2012", "17", "Dalvik"},
{"4.3", "Jelly Bean", "July 24 2013", "18", "Dalvik"},
{"4.4", "KitKat", "October 31 2013", "19", "Dalvik and ART"},
{"5.0", "Lollipop", "November 3 2014", "21", "ART"},
{"5.1", "Lollipop", "March 9 2015", "22", "ART"},
{"6.0", "Marshmallow", "October 5 2015", "23", "ART"},
{"7.0", "Nougat", "August 22 2016", "24", "ART"},
{"7.1", "Nougat", "October 4 2016", "25", "ART"},
{"8.0", "Oreo", "August 21 2017", "26", "ART"},
{"8.1", "Oreo", "December 5 2017", "27", "ART"},
{"9", "Pie", "August 6 2018", "28", "ART"},
{"10", "10", "September 3 2019", "29", "ART"},
{"11", "11", "September 8 2020", "30", "ART"},
});
table.SelectColumn(0).Border(LIGHT);
table.SelectRow(0).Decorate(bold);
table.SelectRow(0).SeparatorVertical(LIGHT);
table.SelectRow(0).Border(DOUBLE);
table.SelectColumn(2).DecorateCells(align_right);
auto content = table.SelectRows(1, -1);
content.DecorateCellsAlternateRow(color(Color::Blue), 3, 0);
content.DecorateCellsAlternateRow(color(Color::Cyan), 3, 1);
content.DecorateCellsAlternateRow(color(Color::White), 3, 2);
auto document = table.Render();
Screen::Create(Dimension::Fit(document, true));
std::cout << std::endl;
return 0;
}
void Border(BorderStyle border=LIGHT)
Aplica un border alrededor de la selección.
TableSelection SelectAll()
Selecciona toda la tabla.
Table es una utilidad para dibujar tablas.
vbox_hbox
Demo
#include <stdio.h>
#include <memory>
auto document =
text("north-west"),
filler(),
text("north-east"),
}),
filler(),
filler(),
text("center"),
filler(),
}),
filler(),
text("south-west"),
filler(),
text("south-east"),
}),
});
auto screen = Screen::Create(Dimension::Full());
getchar();
return 0;
}
vflow
Demo
#include <stdio.h>
#include <string>
auto make_box = [](
int dimx,
int dimy) {
std::string
title = std::to_string(dimx) +
"x" + std::to_string(dimy);
text("content") | hcenter | dim) |
};
auto document = vflow({
}) |
border;
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
getchar();
return 0;
}