Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Console.php

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

Console

Namespace

SebastianBergmann\Environment

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal