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#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
15
16int main() {
17 std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
18
19 // Draw every columns
20 Elements columns_elements;
21 for (auto& column : info_columns) {
22 Elements column_elements;
23 for (auto& it : column) {
24 column_elements.push_back(hbox({
25 text(" ") | bgcolor(Color(Color::Palette256(it.index_256))),
26 text(it.name),
27 }));
28 }
29 columns_elements.push_back(vbox(std::move(column_elements)));
30 }
31 auto document = hbox(std::move(columns_elements));
32
33 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
34 Render(screen, document);
35
36 screen.Print();
37
38 return 0;
39}
std::vector< std::vector< ftxui::ColorInfo > > ColorInfoSorted2D()
Decorator bgcolor(Color)
Decorate using a background color.
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition node.cpp:84
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition vbox.cpp:96
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
Definition screen.cpp:394
Color is a class that represents a color in the terminal user interface.
Definition color.hpp:22
Dimensions Fit(Element &, bool extend_beyond_screen=false)
Definition dom/util.cpp:93
Dimensions Full()
Definition screen.cpp:382
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94
std::vector< Element > Elements
Definition elements.hpp:23