我有一个非常简单的项目,使用 Symfony 组件,并在控制台中显示消息。
它声明了一个标准的ConsoleOutput
,如下所示:
$this->output = new ConsoleOutput();
$formatter = $this->output->getFormatter();
$formatter->setStyle('blink', new OutputFormatterStyle(null, null, array('blink')));
$formatter->setStyle('bold', new OutputFormatterStyle(null, null, array('bold')));
当我尝试用“blink”显示消息时
$this->output->writeln(sprintf('%s<blink>...</blink>', $message));
它不会“闪烁”,它以标准格式显示文本。一开始我以为是我自己的终端问题,但这是我检查的第二台计算机,它根本不闪烁。
我测试添加粗体+闪烁格式,如下所示
OutputFormatterStyle(null, null, ['bold', 'blink']);
结果是粗体文本,而不是闪烁。
如果您想访问完整的代码,请访问:https://github.com/akeneo/nelson/blob/master/src/Akeneo/System/AbstractConsoleLogger.php#L29
最佳答案
很可能您的终端不支持闪烁文本。您可以在 bash 中测试它的运行:
echo -e "Normal \e[33mYellow\e[0m \e[1mBold\e[0m \e[5mBlink\e[0m"
我的 Putty 正确显示黄色和粗体文本,但不闪烁。
大多数终端不支持:
http://misc.flogisoft.com/bash/tip_colors_and_formatting#terminals_compatibility
关于php - Symfony OutputFormatterStyle "blink"不闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36823166/