function Console::getNumberOfColumnsWindows
@codeCoverageIgnore
1 call to Console::getNumberOfColumnsWindows()
- Console::getNumberOfColumns in vendor/
sebastian/ environment/ src/ Console.php - Returns the number of columns of the terminal.
File
-
vendor/
sebastian/ environment/ src/ Console.php, line 152
Class
Namespace
SebastianBergmann\EnvironmentCode
private function getNumberOfColumnsWindows() : int {
$ansicon = getenv('ANSICON');
$columns = 80;
if (is_string($ansicon) && preg_match('/^(\\d+)x\\d+ \\(\\d+x(\\d+)\\)$/', trim($ansicon), $matches)) {
$columns = (int) $matches[1];
}
elseif (function_exists('proc_open')) {
$process = proc_open('mode CON', [
1 => [
'pipe',
'w',
],
2 => [
'pipe',
'w',
],
], $pipes, null, null, [
'suppress_errors' => true,
]);
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
if (preg_match('/--------+\\r?\\n.+?(\\d+)\\r?\\n.+?(\\d+)\\r?\\n/', $info, $matches)) {
$columns = (int) $matches[2];
}
}
}
return $columns - 1;
}