1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
<?php
namespace Webmozart\Console\IO;
use Symfony\Component\Console\Application;
use Webmozart\Console\Api\IO\Input;
use Webmozart\Console\Api\IO\IO;
use Webmozart\Console\Api\IO\Output;
use Webmozart\Console\Formatter\AnsiFormatter;
use Webmozart\Console\Formatter\PlainFormatter;
use Webmozart\Console\IO\InputStream\StandardInputStream;
use Webmozart\Console\IO\OutputStream\ErrorOutputStream;
use Webmozart\Console\IO\OutputStream\StandardOutputStream;
use Webmozart\Console\UI\Rectangle;
class ConsoleIO extends IO
{
public function __construct(Input $input = null, Output $output = null, Output $errorOutput = null)
{
if (null === $input) {
$inputStream = new StandardInputStream();
$input = new Input($inputStream);
}
if (null === $output) {
$outputStream = new StandardOutputStream();
$formatter = $outputStream->supportsAnsi() ? new AnsiFormatter() : new PlainFormatter();
$output = new Output($outputStream, $formatter);
}
if (null === $errorOutput) {
$errorStream = new ErrorOutputStream();
$formatter = $errorStream->supportsAnsi() ? new AnsiFormatter() : new PlainFormatter();
$errorOutput = new Output($errorStream, $formatter);
}
parent::__construct($input, $output, $errorOutput);
}
protected function getDefaultTerminalDimensions()
{
$application = new Application();
list($width, $height) = $application->getTerminalDimensions();
return new Rectangle($width ?: 80, $height ?: 20);
}
}