Add colors.

+ example.
This commit is contained in:
Arthur Sonzogni
2018-10-12 09:23:37 +02:00
parent 711b71688e
commit 1a4b2c98b2
17 changed files with 234 additions and 64 deletions

View File

@@ -0,0 +1,40 @@
#ifndef FTXUI_COLOR_H_
#define FTXUI_COLOR_H_
#include <cstdint>
namespace ftxui {
enum class Color : uint8_t {
// --- Transparent -----
Default = 39,
// --- Grayscale -----
Black = 30,
GrayDark = 90,
GrayLight = 37,
White = 97,
// --- Hue -----
Blue = 34,
BlueLight = 94,
Cyan = 36,
CyanLight = 96,
Green = 32,
GreenLight = 92,
Magenta = 35,
MagentaLight = 95,
Red = 31,
RedLight = 91,
Yellow = 33,
YellowLight = 93,
};
}; // namespace ftxui
#endif /* end of include guard: FTXUI_COLOR_H_ */

View File

@@ -1,6 +1,7 @@
#ifndef FTXUI_DOM_ELEMENTS_HPP
#define FTXUI_DOM_ELEMENTS_HPP
#include "ftxui/color.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {
@@ -27,6 +28,8 @@ Element bold(Element);
Element dim(Element);
Element inverted(Element);
Element underlined(Element);
Element color(Color, Element);
Element bgcolor(Color, Element);
// --- Decorator ---
Element hcenter(Element);

View File

@@ -5,6 +5,8 @@
#include <vector>
#include <memory>
#include <ftxui/color.hpp>
namespace ftxui {
namespace dom {
class Node;
@@ -16,6 +18,8 @@ struct Pixel {
bool inverted = false;
bool underlined = false;
bool dim = false;
Color background_color = Color::Default;
Color foreground_color = Color::Default;
};
class Screen {