本文整理汇总了PHP中Symfony\Component\Console\Application::getTerminalDimensions方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getTerminalDimensions方法的具体用法?PHP Application::getTerminalDimensions怎么用?PHP Application::getTerminalDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::getTerminalDimensions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* ConsoleApplication constructor.
*
* ><p>**Note:** you'll have to configure the IO channels (ex. calling {@see setupStandardIO}) before running the
* application.
*
* @param ConsoleIO $io
* @param ConsoleSettings $settings
* @param SymfonyConsole $console
* @param InjectorInterface $injector
*/
function __construct(ConsoleIO $io, ConsoleSettings $settings, SymfonyConsole $console, InjectorInterface $injector)
{
$this->io = $io;
$this->console = $console;
$this->injector = $injector;
$this->settings = $settings;
$console->setAutoExit(false);
$io->terminalSize($console->getTerminalDimensions());
}
示例2: getTerminalWidth
/**
* Returns the terminal width.
*
* @return int
*/
private function getTerminalWidth()
{
$application = new Application();
$terminalDimensions = $application->getTerminalDimensions();
$width = 120;
if (isset($terminalDimensions[0])) {
$width = $terminalDimensions[0];
}
return $width;
}
示例3: table
public function table(array $headers, array $rows)
{
$application = new Application();
$dimensions = $application->getTerminalDimensions();
$terminalWidth = $dimensions[0] ?: self::MAX_LINE_LENGTH;
$maxHeaderWidth = strlen($headers[0]);
foreach ($rows as $row) {
$length = strlen($row[0]);
if ($maxHeaderWidth === null || $length > $maxHeaderWidth) {
$maxHeaderWidth = $length;
}
}
$wrap = function ($rows) use($terminalWidth, $maxHeaderWidth) {
return array_map(function ($row) use($terminalWidth, $maxHeaderWidth) {
return array_map(function ($s) use($terminalWidth, $maxHeaderWidth) {
if ($terminalWidth > $maxHeaderWidth + 5) {
return wordwrap($s, $terminalWidth - $maxHeaderWidth - 5, "\n", true);
}
return $s;
}, $row);
}, $rows);
};
parent::table($headers, $wrap($rows));
}
示例4: testTerminalDimensions
public function testTerminalDimensions()
{
$application = new Application();
$originalDimensions = $application->getTerminalDimensions();
$this->assertCount(2, $originalDimensions);
$width = 80;
if ($originalDimensions[0] == $width) {
$width = 100;
}
$application->setTerminalDimensions($width, 80);
$this->assertSame(array($width, 80), $application->getTerminalDimensions());
}
示例5: getTerminalWidth
private function getTerminalWidth()
{
$application = new Application();
$dimensions = $application->getTerminalDimensions();
return $dimensions[0] ?: self::MAX_LINE_LENGTH;
}
示例6: getTerminalWidth
/**
* @param int $default
*
* @return int
*/
protected function getTerminalWidth($default = 80)
{
static $dimensions;
if (!$dimensions) {
$application = new ConsoleApplication();
$dimensions = $application->getTerminalDimensions();
}
return $dimensions[0] ?: $default;
}
示例7: getDefaultTerminalDimensions
/**
* {@inheritdoc}
*/
protected function getDefaultTerminalDimensions()
{
$application = new Application();
list($width, $height) = $application->getTerminalDimensions();
return new Rectangle($width ?: 80, $height ?: 20);
}