Skip to content

Commit 8ba7684

Browse files
committed
update ...
1 parent 0b35871 commit 8ba7684

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

examples/HomeController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public function progressCommand($input)
107107
if ($input->getOpt('type') === 'bar') {
108108
$bar = $this->output->progressBar($total, [
109109
'msg' => 'Msg Text',
110-
'doneChar' => $input->getOpt('done-char', '='),
111-
'waitChar' => $input->getOpt('wait-char', '-'),
110+
'doneChar' => $input->getOpt('done-char', '='), // ▓
111+
'waitChar' => $input->getOpt('wait-char', '-'), // ░
112112
'signChar' => $input->getOpt('sign-char', '>'),
113113
]);
114114
} else {

examples/baks/color.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
// $text = 'test message';
4+
// $setCodes = [32];
5+
// $unsetCodes = [39];
6+
// $text = sprintf("\033[%sm%s\033[%sm\n", implode(';', $setCodes), $text, implode(';', $unsetCodes));
7+
// var_dump(chr(27));
8+
// echo $text;
9+
fwrite(STDOUT, "\033[32;40;1;4mfoo\033[39;49;22;24m");
10+
fflush(STDOUT);

src/style/Color.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
/**
99
* Class Color
10+
* - fg unset 39
11+
* - bg unset 49
1012
* @package inhere\console\style
1113
*/
1214
final class Color
@@ -61,13 +63,13 @@ final class Color
6163
* @var array
6264
*/
6365
private static $knownOptions = [
64-
'bold' => 1, // 加粗
66+
'bold' => 1, // 22 加粗
6567
'fuzzy' => 2, // 模糊(不是所有的终端仿真器都支持)
6668
'italic' => 3, // 斜体(不是所有的终端仿真器都支持)
67-
'underscore' => 4, // 下划线
68-
'blink' => 5, // 闪烁
69-
'reverse' => 7, // 颠倒的 交换背景色与前景色
70-
'concealed' => 8, // 隐匿的
69+
'underscore' => 4, // 24 下划线
70+
'blink' => 5, // 25 闪烁
71+
'reverse' => 7, // 27 颠倒的 交换背景色与前景色
72+
'concealed' => 8, // 28 隐匿的
7173
];
7274

7375
/**

src/style/Style.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ public function format($text)
181181
protected function replaceColor($text, $tag, $match, Color $color): string
182182
{
183183
$style = $color->toStyle();
184-
$replace = $this->noColor ? $match : "\033[{$style}m{$match}\033[0m";
184+
$replace = $this->noColor ? $match : sprintf("\033[%sm%s\033[0m", $style, $match);
185+
// $replace = $this->noColor ? $match : sprintf("\033[%sm%s\033[39m", $style, $match);
185186

186187
return str_replace("<$tag>$match</$tag>", $replace, $text);
188+
// return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
187189
}
188190

189191
/**

src/utils/Helper.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ public static function isSupportColor()
3535
{
3636
if (DIRECTORY_SEPARATOR === '\\') {
3737
return
38-
'10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD
39-
|| false !== getenv('ANSICON')
40-
|| 'ON' === getenv('ConEmuANSI')
41-
|| 'xterm' === getenv('TERM')// || 'cygwin' === getenv('TERM')
38+
'10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD ||
39+
// 0 == strpos(PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . PHP_WINDOWS_VERSION_BUILD, '10.') ||
40+
false !== getenv('ANSICON') ||
41+
'ON' === getenv('ConEmuANSI') ||
42+
'xterm' === getenv('TERM')// || 'cygwin' === getenv('TERM')
4243
;
4344
}
4445

src/utils/Show.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ public static function write($messages, $nl = true, $quit = false, array $opts =
782782

783783
fwrite($stream, $messages . ($nl ? PHP_EOL : ''));
784784

785-
if (isset($opts['flush']) && $opts['flush']) {
785+
if (!isset($opts['flush']) || $opts['flush']) {
786786
fflush($stream);
787787
}
788788

0 commit comments

Comments
 (0)