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

Breadcrumb

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

function Cursor::getCurrentPosition

Returns the current cursor position as x,y coordinates.

File

vendor/symfony/console/Cursor.php, line 183

Class

Cursor
@author Pierre du Plessis <pdples@gmail.com>

Namespace

Symfony\Component\Console

Code

public function getCurrentPosition() : array {
    static $isTtySupported;
    if (!($isTtySupported ??= '/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT))) {
        return [
            1,
            1,
        ];
    }
    $sttyMode = shell_exec('stty -g');
    shell_exec('stty -icanon -echo');
    @fwrite($this->input, "\x1b[6n");
    $code = trim(fread($this->input, 1024));
    shell_exec(\sprintf('stty %s', $sttyMode));
    sscanf($code, "\x1b[%d;%dR", $row, $col);
    return [
        $col,
        $row,
    ];
}

API Navigation

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