Skip to content

Commit 86c6128

Browse files
committed
bug symfony#15248 Added 'default' color (jaytaph)
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes symfony#15248). Discussion ---------- Added 'default' color | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#15246 | License | MIT | Doc PR | Adding a "default" ansi color which corresponds to 39 and 49. Commits ------- c4bf2e6 Added 'default' color
2 parents 5ec123f + c4bf2e6 commit 86c6128

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
2929
'magenta' => 35,
3030
'cyan' => 36,
3131
'white' => 37,
32+
'default' => 39,
3233
);
3334
private static $availableBackgroundColors = array(
3435
'black' => 40,
@@ -39,6 +40,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
3940
'magenta' => 45,
4041
'cyan' => 46,
4142
'white' => 47,
43+
'default' => 49,
4244
);
4345
private static $availableOptions = array(
4446
'bold' => 1,

src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function testForeground()
3737
$style->setForeground('blue');
3838
$this->assertEquals("\033[34mfoo\033[0m", $style->apply('foo'));
3939

40+
$style->setForeground('default');
41+
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
42+
4043
$this->setExpectedException('InvalidArgumentException');
4144
$style->setForeground('undefined-color');
4245
}
@@ -51,6 +54,9 @@ public function testBackground()
5154
$style->setBackground('yellow');
5255
$this->assertEquals("\033[43mfoo\033[0m", $style->apply('foo'));
5356

57+
$style->setBackground('default');
58+
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
59+
5460
$this->setExpectedException('InvalidArgumentException');
5561
$style->setBackground('undefined-color');
5662
}

0 commit comments

Comments
 (0)