10#define WIN32_LEAN_AND_MEAN
29Dimensions& FallbackSize() {
30#if defined(__EMSCRIPTEN__)
34 constexpr int fallback_height = 43;
39 constexpr int fallback_width = 80;
40 constexpr int fallback_height = 24;
42 static Dimensions g_fallback_size{
46 return g_fallback_size;
49const char* Safe(
const char* c) {
50 return (c !=
nullptr) ? c :
"";
53bool Contains(
const std::string& s,
const char* key) {
54 return s.find(key) != std::string::npos;
58#if defined(__EMSCRIPTEN__)
62 std::string COLORTERM = Safe(std::getenv(
"COLORTERM"));
63 if (Contains(COLORTERM,
"24bit") || Contains(COLORTERM,
"truecolor")) {
67 std::string TERM = Safe(std::getenv(
"TERM"));
68 if (Contains(COLORTERM,
"256") || Contains(TERM,
"256")) {
72#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
77 if (TERM.empty() && COLORTERM.empty()) {
93#if defined(__EMSCRIPTEN__)
97 return FallbackSize();
99 CONSOLE_SCREEN_BUFFER_INFO csbi;
101 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
102 return Dimensions{csbi.srWindow.Right - csbi.srWindow.Left + 1,
103 csbi.srWindow.Bottom - csbi.srWindow.Top + 1};
106 return FallbackSize();
109 const int status = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
112 if (w.ws_col == 0 || w.ws_row == 0 || status < 0) {
113 return FallbackSize();
122 FallbackSize() = fallbackSize;
130 g_cached_supported_color = ComputeColorSupport();
132 return g_cached_supported_color;
139 g_cached_supported_color =
color;
void SetColorSupport(Color color)
Outrepasser le support couleur du terminal en cas d'échec de la détection automatique.
Decorator color(Color)
Décore en utilisant une couleur de premier plan.
Color
Color est une énumération qui représente le support des couleurs du terminal.
Dimensions Size()
Obtenir la taille du terminal.
Color ColorSupport()
Obtenir le support couleur du terminal.
Dimensions est une structure qui représente la taille du terminal.
void SetFallbackSize(const Dimensions &fallbackSize)
Outrepasser la taille du terminal en cas d'échec de la détection automatique.
L'espace de noms FTXUI ftxui::