File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5858#endif
5959
6060
61- /* 全局变量 */
62- bool xy_enable_color = true;
63-
64- /* 由 xy_init() 赋值 */
6561bool xy_on_windows = false;
6662bool xy_on_linux = false;
6763bool xy_on_macos = false;
@@ -70,6 +66,34 @@ bool xy_on_android = false;
7066
7167char * xy_os_devnull = NULL ;
7268
69+ /* 全局变量 与 全局状态 */
70+ struct
71+ {
72+ bool enable_color ;
73+
74+ bool on_windows ;
75+ bool on_linux ;
76+ bool on_macos ;
77+ bool on_bsd ;
78+ bool on_android ;
79+
80+ char * os_devnull ;
81+ }
82+ xy =
83+ {
84+ .enable_color = true,
85+
86+ /* 由 xy_init() 赋值 */
87+ .on_windows = false,
88+ .on_linux = false,
89+ .on_macos = false,
90+ .on_bsd = false,
91+ .on_android = false,
92+
93+ .os_devnull = NULL
94+ };
95+
96+
7397
7498#ifdef _WIN32
7599 #define XY_Build_On_Windows 1
@@ -388,7 +412,7 @@ _xy_str_to_terminal_style (int style, const char *str)
388412{
389413 char * color_fmt_str = NULL ;
390414
391- if (!xy_enable_color )
415+ if (!xy . enable_color )
392416 {
393417 color_fmt_str = "%s" ;
394418 goto new_str ;
Original file line number Diff line number Diff line change @@ -716,7 +716,7 @@ main (int argc, char const *argv[])
716716 else if (xy_streql (argv [i ], "-no-color" ) || xy_streql (argv [i ], "-no-colour" ))
717717 {
718718 ProgMode .NoColorMode = true;
719- xy_enable_color = false;
719+ xy . enable_color = false;
720720 }
721721 else if ( xy_streql (argv [i ], "-h" )
722722 || xy_streql (argv [i ], "-help" )
Original file line number Diff line number Diff line change 55 * Test Authors : 曾奥然 <ccmywish@qq.com>
66 * Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
77 * Created On : <2023-08-30>
8- * Last Modified : <2025-08-26 >
8+ * Last Modified : <2025-08-27 >
99 *
1010 * Test xy.h
1111 * ------------------------------------------------------------*/
@@ -30,6 +30,9 @@ main (int argc, char const *argv[])
3030{
3131 xy_init ();
3232
33+ // 关闭颜色
34+ // xy.enable_color = false;
35+
3336 println (xy_os_depend_str ("Hello, Windows!" , "Hello, Unix!" ));
3437
3538 println (3 );
You can’t perform that action at this time.
0 commit comments