mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-08 07:34:42 +08:00
使用 xy.enable_color
This commit is contained in:
parent
60ad6c1fc6
commit
90315917e9
34
lib/xy.h
34
lib/xy.h
@ -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;
|
||||
|
@ -716,7 +716,7 @@ main (int argc, char const *argv[])
|
||||
else if (xy_streql (argv[i], "-no-color") || xy_streql (argv[i], "-no-colour"))
|
||||
{
|
||||
ProgMode.NoColorMode = true;
|
||||
xy_enable_color = false;
|
||||
xy.enable_color = false;
|
||||
}
|
||||
else if ( xy_streql (argv[i], "-h")
|
||||
|| xy_streql (argv[i], "-help")
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Test Authors : 曾奥然 <ccmywish@qq.com>
|
||||
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
* Created On : <2023-08-30>
|
||||
* Last Modified : <2025-08-26>
|
||||
* Last Modified : <2025-08-27>
|
||||
*
|
||||
* Test xy.h
|
||||
* ------------------------------------------------------------*/
|
||||
@ -30,6 +30,9 @@ main (int argc, char const *argv[])
|
||||
{
|
||||
xy_init ();
|
||||
|
||||
// 关闭颜色
|
||||
// xy.enable_color = false;
|
||||
|
||||
println (xy_os_depend_str ("Hello, Windows!", "Hello, Unix!"));
|
||||
|
||||
println (3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user