使用 xy.enable_color

This commit is contained in:
Aoran Zeng
2025-08-27 11:53:08 +08:00
parent 60ad6c1fc6
commit 90315917e9
3 changed files with 34 additions and 7 deletions

View File

@@ -58,10 +58,6 @@
#endif
/* 全局变量 */
bool xy_enable_color = true;
/* 由 xy_init() 赋值 */
bool xy_on_windows = false;
bool xy_on_linux = false;
bool xy_on_macos = false;
@@ -70,6 +66,34 @@ bool xy_on_android = false;
char *xy_os_devnull = NULL;
/* 全局变量 与 全局状态 */
struct
{
bool enable_color;
bool on_windows;
bool on_linux;
bool on_macos;
bool on_bsd;
bool on_android;
char *os_devnull;
}
xy =
{
.enable_color = true,
/* 由 xy_init() 赋值 */
.on_windows = false,
.on_linux = false,
.on_macos = false,
.on_bsd = false,
.on_android = false,
.os_devnull = NULL
};
#ifdef _WIN32
#define XY_Build_On_Windows 1
@@ -388,7 +412,7 @@ _xy_str_to_terminal_style (int style, const char *str)
{
char *color_fmt_str = NULL;
if (!xy_enable_color)
if (!xy.enable_color)
{
color_fmt_str = "%s";
goto new_str;