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
13 using namespace ftxui;
14#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
15
16 int 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}
color.hpp
color_info.hpp
main
int main()
Definition color_info_palette256.cpp:16
color_info_sorted_2d.ipp
ColorInfoSorted2D
std::vector< std::vector< ftxui::ColorInfo > > ColorInfoSorted2D()
Definition color_info_sorted_2d.ipp:5
elements.hpp
ftxui::bgcolor
Decorator bgcolor(Color)
Decorate using a background color.
Definition dom/color.cpp:124
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition text.cpp:160
ftxui::Render
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
Definition node.cpp:84
ftxui::vbox
Element vbox(Elements)
A container displaying elements vertically one by one.
Definition vbox.cpp:96
ftxui::Screen::Create
static Screen Create(Dimensions dimension)
Create a screen with the given dimension.
Definition screen.cpp:394
ftxui::Color::Palette256
Palette256
Definition color.hpp:72
ftxui::Color
Color is a class that represents a color in the terminal user interface.
Definition color.hpp:22
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::hbox
Element hbox(Elements)
A container displaying elements horizontally one by one.
Definition hbox.cpp:94
ftxui::Elements
std::vector< Element > Elements
Definition elements.hpp:23
node.hpp
screen.hpp