#include <stddef.h>
#include <array>
#include <atomic>
#include <chrono>
#include <cmath>
#include <functional>
#include <memory>
#include <string>
#include <thread>
#include <utility>
#include <vector>
#include "../dom/color_info_sorted_2d.ipp"
auto screen = ScreenInteractive::Fullscreen();
auto my_graph = [&shift](int width, int height) {
std::vector<int> output(width);
for (int i = 0; i < width; ++i) {
float v = 0.5f;
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;
output[i] = (int)v;
}
return output;
};
auto htop = Renderer([&] {
text("Frequency [Mhz]") | hcenter,
text("2400 "),
filler(),
text("1200 "),
filler(),
text("0 "),
}),
graph(std::ref(my_graph)) | flex,
}) | flex,
});
auto utilization =
vbox({
text("Utilization [%]") | hcenter,
text("100 "),
filler(),
text("50 "),
filler(),
text("0 "),
}),
graph(std::ref(my_graph)) | color(Color::RedLight),
}) | flex,
});
text("Ram [Mo]") | hcenter,
text("8192"),
filler(),
text("4096 "),
filler(),
text("0 "),
}),
graph(std::ref(my_graph)) | color(Color::BlueLight),
}) | flex,
});
frequency | flex,
separator(),
utilization | flex,
}) | flex,
separator(),
ram | flex,
}) |
flex;
});
const std::vector<std::string> compiler_entries = {
"gcc",
"clang",
"emcc",
"game_maker",
"Compiladores de Ada",
"Compiladores de ALGOL 60",
"Compiladores de ALGOL 68",
"Ensambladores (Intel *86)",
"Ensambladores (Motorola 68*)",
"Ensambladores (Zilog Z80)",
"Ensambladores (otros)",
"Compiladores BASIC",
"Intérpretes BASIC",
"Compiladores por lotes",
"Compiladores C",
"Compiladores de fuente a fuente",
"Compiladores C++",
"Compiladores C#",
"Compiladores COBOL",
"Compiladores Common Lisp",
"Compiladores D",
"Compiladores DIBOL/DBL",
"Intérpretes ECMAScript",
"Compiladores Eiffel",
"Compiladores Fortran",
"Compiladores Go",
"Compiladores Haskell",
"Compiladores Java",
"Compiladores Pascal",
"Intérpretes Perl",
"Compiladores PHP",
"Compiladores PL/I",
"Compiladores Python",
"Compiladores e intérpretes Scheme",
"Compiladores Smalltalk",
"Intérpretes Tcl",
"Intérpretes VMS",
"Intérpretes Rexx",
"Compiladores CLI",
};
int compiler_selected = 0;
Component compiler = Radiobox(&compiler_entries, &compiler_selected);
std::array<std::string, 8> options_label = {
"-Wall",
"-Werror",
"-lpthread",
"-O3",
"-Wabi-tag",
"-Wno-class-conversion",
"-Wcomma-subscript",
"-Wno-conversion-null",
};
std::array<bool, 8> options_state = {
false, false, false, false, false, false, false, false,
};
std::vector<std::string> input_entries;
int input_selected = 0;
Component input = Menu(&input_entries, &input_selected);
std::string input_add_content;
input_option.on_enter = [&] {
input_entries.push_back(input_add_content);
input_add_content = "";
};
Component input_add = Input(&input_add_content,
"archivos de entrada", input_option);
std::string executable_content_ = "";
Component executable_ = Input(&executable_content_,
"ejecutable");
Checkbox(&options_label[0], &options_state[0]),
Checkbox(&options_label[1], &options_state[1]),
Checkbox(&options_label[2], &options_state[2]),
Checkbox(&options_label[3], &options_state[3]),
Checkbox(&options_label[4], &options_state[4]),
Checkbox(&options_label[5], &options_state[5]),
Checkbox(&options_label[6], &options_state[6]),
Checkbox(&options_label[7], &options_state[7]),
});
auto compiler_component = Container::Horizontal({
compiler,
flags,
Container::Vertical({
executable_,
Container::Horizontal({
input_add,
input,
}),
}),
});
auto render_command = [&] {
line.push_back(text(compiler_entries[compiler_selected]) | bold);
for (int i = 0; i < 8; ++i) {
if (options_state[i]) {
line.push_back(text(" "));
line.push_back(text(options_label[i]) | dim);
}
}
if (!executable_content_.empty()) {
line.push_back(text(" -o ") | bold);
line.push_back(text(executable_content_) | color(Color::BlueLight) |
bold);
}
for (auto& it : input_entries) {
line.push_back(text(" " + it) | color(Color::RedLight));
}
return line;
};
auto compiler_renderer = Renderer(compiler_component, [&] {
auto compiler_win =
window(text(
"Compilador"),
compiler->Render() | vscroll_indicator | frame);
auto flags_win =
window(text(
"Banderas"), flags->Render() | vscroll_indicator | frame);
auto executable_win =
window(text(
"Ejecutable:"), executable_->Render());
auto input_win =
text("Añadir: "),
input_add->Render(),
filler(),
}),
separator(),
input->Render() | vscroll_indicator | frame |
}));
compiler_win,
flags_win,
}),
filler(),
}) |
size(HEIGHT, LESS_THAN, 8),
hflow(render_command()) | flex_grow,
}) |
flex_grow;
});
for (int i = 0; i < 22; ++i) {
entries.push_back(spinner(i, shift / 5) | bold |
size(WIDTH, GREATER_THAN, 2) | border);
}
return hflow(std::move(entries));
});
text("Paleta de 16 colores:"),
separator(),
color(Color::Default, text("Predeterminado")),
color(Color::Black, text("Negro")),
color(Color::GrayDark, text("GrisOscuro")),
color(Color::GrayLight, text("GrisClaro")),
color(Color::White, text("Blanco")),
color(Color::Blue, text("Azul")),
color(Color::BlueLight, text("AzulClaro")),
color(Color::Cyan, text("Cian")),
color(Color::CyanLight, text("CianClaro")),
color(Color::Green, text("Verde")),
color(Color::GreenLight, text("VerdeClaro")),
color(Color::Magenta, text("Magenta")),
color(Color::MagentaLight, text("MagentaClaro")),
color(Color::Red, text("Rojo")),
color(Color::RedLight, text("RojoClaro")),
color(Color::Yellow, text("Amarillo")),
color(Color::YellowLight, text("AmarilloClaro")),
}),
bgcolor(Color::Default, text("Predeterminado")),
bgcolor(Color::Black, text("Negro")),
bgcolor(Color::GrayDark, text("GrisOscuro")),
bgcolor(Color::GrayLight, text("GrisClaro")),
bgcolor(Color::White, text("Blanco")),
bgcolor(Color::Blue, text("Azul")),
bgcolor(Color::BlueLight, text("AzulClaro")),
bgcolor(Color::Cyan, text("Cian")),
bgcolor(Color::CyanLight, text("CianClaro")),
bgcolor(Color::Green, text("Verde")),
bgcolor(Color::GreenLight, text("VerdeClaro")),
bgcolor(Color::Magenta, text("Magenta")),
bgcolor(Color::MagentaLight, text("MagentaClaro")),
bgcolor(Color::Red, text("Rojo")),
bgcolor(Color::RedLight, text("RojoClaro")),
bgcolor(Color::Yellow, text("Amarillo")),
bgcolor(Color::YellowLight, text("AmarilloClaro")),
}),
}),
}) |
border;
{
for (auto& column : info_columns) {
for (auto& it : column) {
column_elements.push_back(
}
}
separator(),
}) |
border;
}
{
int saturation = 255;
for (int value = 0; value < 255; value += 16) {
for (int hue = 0; hue < 255; hue += 6) {
line.push_back(text("▀")
| color(Color::HSV(hue, saturation, value))
| bgcolor(Color::HSV(hue, saturation, value + 8)));
}
}
separator(),
}) |
border;
}
{
},
});
float progress = (shift + delta) % 500 / 500.f;
text(std::to_string(
int(
progress * 100)) +
"% ") |
});
};
render_gauge(0) | color(Color::Black),
render_gauge(100) | color(Color::GrayDark),
render_gauge(50) | color(Color::GrayLight),
render_gauge(6894) | color(Color::White),
separator(),
render_gauge(6841) | color(Color::Blue),
render_gauge(9813) | color(Color::BlueLight),
render_gauge(98765) | color(Color::Cyan),
render_gauge(98) | color(Color::CyanLight),
render_gauge(9846) | color(Color::Green),
render_gauge(1122) | color(Color::GreenLight),
render_gauge(84) | color(Color::Magenta),
render_gauge(645) | color(Color::MagentaLight),
render_gauge(568) | color(Color::Red),
render_gauge(2222) | color(Color::RedLight),
render_gauge(220) | color(Color::Yellow),
render_gauge(348) | color(Color::YellowLight),
});
});
std::string
title = std::to_string(dimx) +
"x" + std::to_string(dimy);
text("contenido") | hcenter | dim) |
};
std::string str =
"Lorem Ipsum es simplemente un texto ficticio de la industria de la "
"impresión y la tipografía.\nLorem Ipsum ha sido el texto ficticio "
"estándar de la industria desde el siglo XVI, cuando una impresora "
"desconocida tomó una galera de tipos y la mezcló para hacer un libro "
"de muestras de tipos.";
window(text(
"Alinear izquierda:"), paragraphAlignLeft(str)),
window(text(
"Alinear centro:"), paragraphAlignCenter(str)),
window(text(
"Alinear derecha:"), paragraphAlignRight(str)),
window(text(
"Alinear justificar:"), paragraphAlignJustify(str)),
paragraph(str),
separator(),
paragraph(str),
})),
window(text(
"Elementos con diferente tamaño:"),
})),
}) |
vscroll_indicator | yframe | flex;
});
return paragraph("<--- Esta barra vertical es redimensionable usando el ratón") |
center;
});
"htop", "color", "spinner", "gauge", "compiler", "paragraph",
};
{
htop,
color_tab_renderer,
spinner_tab_renderer,
compiler_renderer,
},
Button(
"Salir", [&] {
screen.Exit(); }, ButtonOption::Animated());
Container::Horizontal({
}),
});
text("Demostración de FTXUI") | bold | hcenter,
}),
});
});
while (!loop.HasQuitted()) {
shift++;
screen.RequestAnimationFrame();
loop.RunOnce();
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 60));
}
return 0;
}
std::vector< std::vector< ftxui::ColorInfo > > ColorInfoSorted2D()
Element make_box(int x, int y)
Loop es una clase que gestiona el bucle de eventos de un componente.
FlexboxConfig & SetGap(int gap_x, int gap_y)
Establece el espacio (gap) del flexbox.
Element vbox(Elements children)
Un contenedor que muestra elementos verticalmente uno por uno.
FlexboxConfig es una estructura de configuración que define las propiedades de diseño para un contene...
Color es una clase que representa un color en la interfaz de usuario de la terminal.
std::vector< std::string > tab_entries
int paragraph_renderer_split_position
auto palette_256_color_display
auto paragraph_renderer_group_renderer
auto paragraph_renderer_right
return dimx size(HEIGHT, EQUAL, dimy)
auto paragraph_renderer_left
return window(text(title)|hcenter|bold, text("contenido")|hcenter|dim)|size(WIDTH
return flexbox({ basic_color_display, palette_256_color_display, true_color_display, }, FlexboxConfig().SetGap(1, 1))
return hbox({ text(std::to_string(int(progress *100))+"% ")|size(WIDTH, EQUAL, 5), gauge(progress), })
auto paragraph_renderer_group
El espacio de nombres ftxui:: de FTXUI.
std::vector< Element > Elements
std::shared_ptr< ComponentBase > Component