public function Console::getNumberOfColumns in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/sebastian/environment/src/Console.php \SebastianBergmann\Environment\Console::getNumberOfColumns()
Returns the number of columns of the terminal.
Return value
int
File
- vendor/
sebastian/ environment/ src/ Console.php, line 47
Class
Namespace
SebastianBergmann\EnvironmentCode
public function getNumberOfColumns() {
// Windows terminals have a fixed size of 80
// but one column is used for the cursor.
if (DIRECTORY_SEPARATOR == '\\') {
return 79;
}
if (!$this
->isInteractive(self::STDIN)) {
return 80;
}
if (preg_match('#\\d+ (\\d+)#', shell_exec('stty size'), $match) === 1) {
return (int) $match[1];
}
if (preg_match('#columns = (\\d+);#', shell_exec('stty'), $match) === 1) {
return (int) $match[1];
}
return 80;
}