10#define WIN32_LEAN_AND_MEAN
29Dimensions& FallbackSize() {
30#if defined(__EMSCRIPTEN__)
34 constexpr int fallback_width = 140;
35 constexpr int fallback_height = 43;
40 constexpr int fallback_width = 80;
41 constexpr int fallback_height = 24;
43 static Dimensions g_fallback_size{
47 return g_fallback_size;
50const char* Safe(
const char* c) {
51 return (c !=
nullptr) ? c :
"";
54bool Contains(
const std::string& s,
const char* key) {
55 return s.find(key) != std::string::npos;
59#if defined(__EMSCRIPTEN__)
63 std::string COLORTERM = Safe(std::getenv(
"COLORTERM"));
64 if (Contains(COLORTERM,
"24bit") || Contains(COLORTERM,
"truecolor")) {
68 std::string TERM = Safe(std::getenv(
"TERM"));
69 if (Contains(COLORTERM,
"256") || Contains(TERM,
"256")) {
73#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
78 if (TERM.empty() && COLORTERM.empty()) {
94#if defined(__EMSCRIPTEN__)
99 return FallbackSize();
101 CONSOLE_SCREEN_BUFFER_INFO csbi;
103 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
104 return Dimensions{csbi.srWindow.Right - csbi.srWindow.Left + 1,
105 csbi.srWindow.Bottom - csbi.srWindow.Top + 1};
108 return FallbackSize();
111 const int status = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
114 if (w.ws_col == 0 || w.ws_row == 0 || status < 0) {
115 return FallbackSize();
124 FallbackSize() = fallbackSize;
132 g_cached_supported_color = ComputeColorSupport();
134 return g_cached_supported_color;
141 g_cached_supported_color =
color;
void SetColorSupport(Color color)
Anula el soporte de color del terminal en caso de que la autodetección falle.
Decorator color(Color)
Decora usando un color de primer plano.
Color
Color es una enumeración que representa el soporte de color de la terminal.
Dimensions Size()
Obtiene el tamaño del terminal.
Color ColorSupport()
Obtiene el soporte de color del terminal.
Dimensions es una estructura que representa el tamaño de la terminal.
El espacio de nombres ftxui::Terminal:: de FTXUI.
void SetFallbackSize(const Dimensions &fallbackSize)
Anula el tamaño del terminal en caso de que la autodetección falle.
El espacio de nombres ftxui:: de FTXUI.