mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-20 02:28:10 +08:00
Add colors.
+ example.
This commit is contained in:
40
ftxui/include/ftxui/color.hpp
Normal file
40
ftxui/include/ftxui/color.hpp
Normal 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_ */
|
@@ -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);
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user