@@ -35,7 +35,7 @@ class Color
3535 const DARKGRAY = 100 ;
3636
3737 /** @var string Cli format */
38- protected $ format = "\033[:bold :;:fg:;:bg:m:text : \033[0m " ;
38+ protected $ format = "\033[:mod :;:fg:;:bg:m:txt : \033[0m " ;
3939
4040 /** @var array Custom styles */
4141 protected static $ styles = [];
@@ -50,7 +50,7 @@ class Color
5050 */
5151 public function comment (string $ text , array $ style = []): string
5252 {
53- return $ this ->line ($ text , ['bold ' => 2 ] + $ style );
53+ return $ this ->line ($ text , ['mod ' => 2 ] + $ style );
5454 }
5555
5656 /**
@@ -115,17 +115,17 @@ public function info(string $text, array $style = []): string
115115 */
116116 public function line (string $ text , array $ style = []): string
117117 {
118- $ style += ['bg ' => null , 'fg ' => static ::WHITE , 'bold ' => 0 ];
118+ $ style += ['bg ' => null , 'fg ' => static ::WHITE , 'bold ' => 0 , ' mod ' => null ];
119119
120120 $ format = $ style ['bg ' ] === null
121121 ? \str_replace (';:bg: ' , '' , $ this ->format )
122122 : $ this ->format ;
123123
124124 $ line = \strtr ($ format , [
125- ':bold : ' => (int ) $ style ['bold ' ],
126- ':fg: ' => (int ) $ style ['fg ' ],
127- ':bg: ' => (int ) $ style ['bg ' ] + 10 ,
128- ':text : ' => $ text ,
125+ ':mod : ' => (int ) ( $ style ['mod ' ] ?? $ style [ ' bold ' ]) ,
126+ ':fg: ' => (int ) $ style ['fg ' ],
127+ ':bg: ' => (int ) $ style ['bg ' ] + 10 ,
128+ ':txt : ' => $ text ,
129129 ]);
130130
131131 return $ line ;
@@ -227,9 +227,13 @@ protected function parseCall(string $name, array $arguments): array
227227 {
228228 list ($ text , $ style ) = $ arguments + ['' , []];
229229
230- if (\stripos ($ name , 'bold ' ) !== false ) {
231- $ name = \str_ireplace ('bold ' , '' , $ name );
232- $ style += ['bold ' => 1 ];
230+ $ mods = ['bold ' => 1 , 'dim ' => 2 , 'italic ' => 3 , 'underline ' => 4 , 'flash ' => 5 ];
231+
232+ foreach ($ mods as $ mod => $ value ) {
233+ if (\stripos ($ name , $ mod ) !== false ) {
234+ $ name = \str_ireplace ($ mod , '' , $ name );
235+ $ style += ['bold ' => $ value ];
236+ }
233237 }
234238
235239 if (!\preg_match_all ('/([b|B|f|F]g)?([A-Z][a-z]+)([^A-Z])?/ ' , $ name , $ matches )) {
0 commit comments