7#define WIN32_LEAN_AND_MEAN
21#if defined(__EMSCRIPTEN__)
26static Dimensions fallback_size{140, 43};
36static Dimensions fallback_size{80, 24};
38 CONSOLE_SCREEN_BUFFER_INFO csbi;
40 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
41 return Dimensions{csbi.srWindow.Right - csbi.srWindow.Left + 1,
42 csbi.srWindow.Bottom - csbi.srWindow.Top + 1};
52static Dimensions fallback_size{80, 24};
55 const int status = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
58 if (w.ws_col == 0 || w.ws_row == 0 || status < 0) {
69 fallback_size = fallbackSize;
74const char* Safe(
const char* c) {
78bool Contains(
const std::string& s,
const char* key) {
79 return s.find(key) != std::string::npos;
82static bool cached =
false;
85#if defined(__EMSCRIPTEN__)
89 std::string COLORTERM = Safe(std::getenv(
"COLORTERM"));
90 if (Contains(COLORTERM,
"24bit") || Contains(COLORTERM,
"truecolor"))
93 std::string TERM = Safe(std::getenv(
"TERM"));
94 if (Contains(COLORTERM,
"256") || Contains(TERM,
"256"))
97#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
102 if (TERM ==
"" && COLORTERM ==
"")
114 cached_supported_color = ComputeColorSupport();
116 return cached_supported_color;
void SetFallbackSize(const Dimensions &fallbackSize)