FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
color_info_palette256.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <ftxui/dom/elements.hpp> // for text, bgcolor, hbox, operator|, Elements, Fit, vbox, Element
5#include <ftxui/screen/color_info.hpp> // for ColorInfo
6#include <ftxui/screen/screen.hpp> // for Full, Screen
7#include <utility> // for move
8#include <vector> // for vector, allocator
9
10#include "ftxui/dom/node.hpp" // for Render
11#include "ftxui/screen/color.hpp" // for Color, Color::Palette256, ftxui
12
13using namespace ftxui;
14
15int main() {
16 std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
17
18 // Draw every columns
19 Elements columns_elements;
20 for (auto& column : info_columns) {
21 Elements column_elements;
22 for (auto& it : column) {
23 column_elements.push_back(hbox({
24 text(" ") | bgcolor(Color(Color::Palette256(it.index_256))),
25 text(it.name),
26 }));
27 }
28 columns_elements.push_back(vbox(std::move(column_elements)));
29 }
30 auto document = hbox(std::move(columns_elements));
31
32 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
33 Render(screen, document);
34
35 screen.Print();
36
37 return 0;
38}
Element text(std::string_view text)
Display a piece of UTF8 encoded unicode text.
Element bgcolor(Color color, Element child)
Set the background color of an element.
Definition dom/color.cpp:96
Element vbox(Elements children)
A container displaying elements vertically one by one.
Definition vbox.cpp:96
The FTXUI ftxui:: namespace.
Definition animation.hpp:11
Element hbox(Elements children)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94
std::vector< Element > Elements
Definition elements.hpp:25
std::vector< std::vector< ColorInfo > > ColorInfoSorted2D()
void Render(Screen &screen, Node *node, Selection &selection)
Definition node.cpp:105
Color
Build a transparent color.
Definition elements.hpp:91