FTXUI  5.0.0
C++ functional terminal UI.
examples/dom/color_info_palette256.cpp
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <ftxui/dom/elements.hpp> // for text, bgcolor, hbox, operator|, Elements, Fit, vbox, Element
#include <ftxui/screen/color_info.hpp> // for ColorInfo
#include <ftxui/screen/screen.hpp> // for Full, Screen
#include <utility> // for move
#include <vector> // for vector, allocator
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::Palette256, ftxui
using namespace ftxui;
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
int main() {
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
// Draw every columns
Elements columns_elements;
for (auto& column : info_columns) {
Elements column_elements;
for (auto& it : column) {
column_elements.push_back(hbox({
text(" ") | bgcolor(Color(Color::Palette256(it.index_256))),
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));
Render(screen, document);
screen.Print();
return 0;
}
Dimensions Fit(Element &)
Definition: util.cpp:95
Dimensions Full()
Definition: screen.cpp:379
Decorator bgcolor(Color)
Decorate using a background color.
Definition: color.cpp:124
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition: hbox.cpp:83
Element text(std::wstring text)
Display a piece of unicode text.
Definition: text.cpp:120
std::vector< Element > Elements
Definition: elements.hpp:24
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition: node.cpp:47
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition: vbox.cpp:83