FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/component/selection.cpp
// Copyright 2020 Arthur Sonzogni. Todos los derechos reservados.
// El uso de este código fuente se rige por la licencia MIT que se puede encontrar en
// el archivo LICENSE.
#include <string> // for char_traits, operator+, string, basic_string
#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for InputOption
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
#include "ftxui/util/ref.hpp" // for Ref
using namespace ftxui;
return vbox({
text("FTXUI: Una potente biblioteca para construir interfaces de usuario."),
text("Disfruta de un rico conjunto de componentes y un estilo declarativo."),
text("Crea UIs hermosas y responsivas con un mínimo esfuerzo."),
text("Únete a la comunidad y experimenta el poder de FTXUI."),
});
}
int main() {
auto screen = ScreenInteractive::TerminalOutput();
auto quit =
Button("Quit", screen.ExitLoopClosure(), ButtonOption::Animated());
int selection_change_counter = 0;
std::string selection_content = "";
screen.SelectionChange([&] {
selection_change_counter++;
selection_content = screen.GetSelection();
});
// Los componentes:
auto renderer = Renderer(quit, [&] {
return vbox({
text("Selección cambiada: " + std::to_string(selection_change_counter) +
" veces"),
text("Actualmente seleccionado: "),
paragraph(selection_content) | vscroll_indicator | frame | border |
size(HEIGHT, EQUAL, 10),
window(text("División horizontal"), hbox({
separator(),
separator(),
})),
window(text("División vertical"), vbox({
separator(),
separator(),
})),
window(text("División en cuadrícula con estilo diferente"),
vbox({
hbox({
separator(),
| selectionBackgroundColor(Color::Yellow) //
| selectionColor(Color::Black) //
| selectionStyleReset,
separator(),
LoremIpsum() | selectionColor(Color::Blue),
}),
separator(),
hbox({
LoremIpsum() | selectionColor(Color::Red),
separator(),
LoremIpsum() | selectionStyle([](Pixel& pixel) {
pixel.underlined_double = true;
}),
separator(),
}),
})),
quit->Render(),
});
});
screen.Loop(renderer);
}
auto screen
Element LoremIpsum()
Element vbox(Elements children)
Un contenedor que muestra elementos verticalmente uno por uno.
Definition vbox.cpp:95
bool underlined_double
Definition pixel.hpp:34
Un carácter Unicode y su estilo asociado.
Definition pixel.hpp:15
return dimx size(HEIGHT, EQUAL, dimy)
return EQUAL
return window(text(title)|hcenter|bold, text("contenido")|hcenter|dim)|size(WIDTH
return hbox({ text(std::to_string(int(progress *100))+"% ")|size(WIDTH, EQUAL, 5), gauge(progress), })
El espacio de nombres ftxui:: de FTXUI.
Definition animation.hpp:10
std::shared_ptr< Node > Element
Definition elements.hpp:22