Skip to content

Commit 21d49f7

Browse files
committed
Add support for 256 colors
1 parent fd794a7 commit 21d49f7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ echo $color->ok('This is ok msg');
450450
```php
451451
Ahc\Cli\Output\Color::style('mystyle', [
452452
'bg' => Ahc\Cli\Output\Color::CYAN,
453-
'fg' => Ahc\Cli\Output\Color::WHITE,
453+
'fg' => '38;5;57', // 256 colors can be used as well
454454
'bold' => 1, // You can experiment with 0, 1, 2, 3 ... as well
455455
]);
456456

src/Output/Color.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ public function line(string $text, array $style = []): string
130130

131131
$line = strtr($format, [
132132
':mod:' => (int) ($style['mod'] ?? $style['bold']),
133-
':fg:' => (int) $style['fg'],
134-
':bg:' => (int) $style['bg'] + 10,
133+
':fg:' => $style['fg'],
134+
':bg:' => is_int($style['bg']) ? ($style['bg'] + 10) : $style['bg'],
135135
':txt:' => $text,
136136
]);
137137

0 commit comments

Comments
 (0)