46
46
*/
47
47
class Color
48
48
{
49
- public const RESET = 0 ;
49
+ public const RESET = 0 ;
50
50
51
51
public const NORMAL = 0 ;
52
52
@@ -63,87 +63,87 @@ class Color
63
63
public const BG_EXTRA = 100 ;
64
64
65
65
// Foreground color
66
- public const FG_BLACK = 30 ;
66
+ public const FG_BLACK = 30 ;
67
67
68
- public const FG_RED = 31 ;
68
+ public const FG_RED = 31 ;
69
69
70
- public const FG_GREEN = 32 ;
70
+ public const FG_GREEN = 32 ;
71
71
72
- public const FG_BROWN = 33 ; // like yellow
72
+ public const FG_BROWN = 33 ; // like yellow
73
73
74
- public const FG_BLUE = 34 ;
74
+ public const FG_BLUE = 34 ;
75
75
76
- public const FG_CYAN = 36 ;
76
+ public const FG_CYAN = 36 ;
77
77
78
- public const FG_WHITE = 37 ;
78
+ public const FG_WHITE = 37 ;
79
79
80
80
public const FG_DEFAULT = 39 ;
81
81
82
82
// extra Foreground color
83
- public const FG_DARK_GRAY = 90 ;
83
+ public const FG_DARK_GRAY = 90 ;
84
84
85
- public const FG_LIGHT_RED = 91 ;
85
+ public const FG_LIGHT_RED = 91 ;
86
86
87
- public const FG_LIGHT_GREEN = 92 ;
87
+ public const FG_LIGHT_GREEN = 92 ;
88
88
89
- public const FG_LIGHT_YELLOW = 93 ;
89
+ public const FG_LIGHT_YELLOW = 93 ;
90
90
91
- public const FG_LIGHT_BLUE = 94 ;
91
+ public const FG_LIGHT_BLUE = 94 ;
92
92
93
93
public const FG_LIGHT_MAGENTA = 95 ;
94
94
95
- public const FG_LIGHT_CYAN = 96 ;
95
+ public const FG_LIGHT_CYAN = 96 ;
96
96
97
- public const FG_LIGHT_WHITE = 97 ;
97
+ public const FG_LIGHT_WHITE = 97 ;
98
98
99
99
// Background color
100
- public const BG_BLACK = 40 ;
100
+ public const BG_BLACK = 40 ;
101
101
102
- public const BG_RED = 41 ;
102
+ public const BG_RED = 41 ;
103
103
104
- public const BG_GREEN = 42 ;
104
+ public const BG_GREEN = 42 ;
105
105
106
- public const BG_BROWN = 43 ; // like yellow
106
+ public const BG_BROWN = 43 ; // like yellow
107
107
108
- public const BG_BLUE = 44 ;
108
+ public const BG_BLUE = 44 ;
109
109
110
- public const BG_CYAN = 46 ;
110
+ public const BG_CYAN = 46 ;
111
111
112
- public const BG_WHITE = 47 ;
112
+ public const BG_WHITE = 47 ;
113
113
114
114
public const BG_DEFAULT = 49 ;
115
115
116
116
// extra Background color
117
- public const BG_DARK_GRAY = 100 ;
117
+ public const BG_DARK_GRAY = 100 ;
118
118
119
- public const BG_LIGHT_RED = 101 ;
119
+ public const BG_LIGHT_RED = 101 ;
120
120
121
- public const BG_LIGHT_GREEN = 102 ;
121
+ public const BG_LIGHT_GREEN = 102 ;
122
122
123
- public const BG_LIGHT_YELLOW = 103 ;
123
+ public const BG_LIGHT_YELLOW = 103 ;
124
124
125
- public const BG_LIGHT_BLUE = 104 ;
125
+ public const BG_LIGHT_BLUE = 104 ;
126
126
127
127
public const BG_LIGHT_MAGENTA = 105 ;
128
128
129
- public const BG_LIGHT_CYAN = 106 ;
129
+ public const BG_LIGHT_CYAN = 106 ;
130
130
131
- public const BG_WHITE_W = 107 ;
131
+ public const BG_WHITE_W = 107 ;
132
132
133
133
// color option
134
- public const BOLD = 1 ; // 加粗
134
+ public const BOLD = 1 ; // 加粗
135
135
136
- public const FUZZY = 2 ; // 模糊(不是所有的终端仿真器都支持)
136
+ public const FUZZY = 2 ; // 模糊(不是所有的终端仿真器都支持)
137
137
138
- public const ITALIC = 3 ; // 斜体(不是所有的终端仿真器都支持)
138
+ public const ITALIC = 3 ; // 斜体(不是所有的终端仿真器都支持)
139
139
140
140
public const UNDERSCORE = 4 ; // 下划线
141
141
142
- public const BLINK = 5 ; // 闪烁
142
+ public const BLINK = 5 ; // 闪烁
143
143
144
- public const REVERSE = 7 ; // 颠倒的 交换背景色与前景色
144
+ public const REVERSE = 7 ; // 颠倒的 交换背景色与前景色
145
145
146
- public const CONCEALED = 8 ; // 隐匿的
146
+ public const CONCEALED = 8 ; // 隐匿的
147
147
148
148
/**
149
149
* There are some internal styles
@@ -155,15 +155,19 @@ class Color
155
155
// basic
156
156
'normal ' => '39 ' ,// no color
157
157
'red ' => '0;31 ' ,
158
+ 'red1 ' => '1;31 ' ,
158
159
'blue ' => '0;34 ' ,
159
160
'cyan ' => '0;36 ' ,
161
+ 'cyan1 ' => '1;36 ' ,
160
162
'black ' => '0;30 ' ,
161
163
'green ' => '0;32 ' ,
164
+ 'green1 ' => '1;32 ' ,
162
165
'brown ' => '0;33 ' ,
166
+ 'brown1 ' => '1;33 ' ,
163
167
'white ' => '1;37 ' ,
164
168
'ylw0 ' => '0;33 ' ,
165
- 'yellow0 ' => '0;33 ' ,
166
169
'ylw ' => '1;33 ' ,
170
+ 'yellow0 ' => '0;33 ' ,
167
171
'yellow ' => '1;33 ' ,
168
172
'mga0 ' => '0;35 ' ,
169
173
'magenta0 ' => '0;35 ' ,
@@ -340,11 +344,11 @@ public static function render(string $text, $style = null): string
340
344
if (is_string ($ style )) {
341
345
$ color = self ::STYLES [$ style ] ?? '' ;
342
346
343
- // custom style: [self::FG_GREEN, self::BG_WHITE, self::UNDERSCORE]
347
+ // custom style: [self::FG_GREEN, self::BG_WHITE, self::UNDERSCORE]
344
348
} elseif (is_array ($ style )) {
345
349
$ color = implode ('; ' , $ style );
346
350
347
- // user color tag: <info>message</info>
351
+ // user color tag: <info>message</info>
348
352
} elseif (strpos ($ text , '</ ' ) > 0 ) {
349
353
return self ::parseTag ($ text );
350
354
}
0 commit comments