Skip to content

Commit

Permalink
Add support for 256 colors
Browse files Browse the repository at this point in the history
  • Loading branch information
kodie committed Nov 25, 2024
1 parent 0945f82 commit c354406
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ echo $color->ok('This is ok msg');
```php
Ahc\Cli\Output\Color::style('mystyle', [
'bg' => Ahc\Cli\Output\Color::CYAN,
'fg' => Ahc\Cli\Output\Color::WHITE,
'fg' => '38;5;57', // 256 colors can be used as well
'bold' => 1, // You can experiment with 0, 1, 2, 3 ... as well
]);

Expand Down
4 changes: 2 additions & 2 deletions src/Output/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public function line(string $text, array $style = []): string

$line = strtr($format, [
':mod:' => (int) ($style['mod'] ?? $style['bold']),
':fg:' => (int) $style['fg'],
':bg:' => (int) $style['bg'] + 10,
':fg:' => $style['fg'],
':bg:' => is_int($style['bg']) ? ($style['bg'] + 10) : $style['bg'],
':txt:' => $text,
]);

Expand Down

0 comments on commit c354406

Please sign in to comment.