getCurrentPosition example

$cursor->clearOutput();

        $this->assertEquals("\x1b[0J", $this->getOutputContent($output));
    }

    public function testGetCurrentPosition()
    {
        $cursor = new Cursor($output = $this->getOutputStream());

        $cursor->moveToPosition(10, 10);
        $position = $cursor->getCurrentPosition();

        $this->assertEquals("\x1b[11;10H", $this->getOutputContent($output));

        $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r']['file', '/dev/tty', 'w']['file', '/dev/tty', 'w']]$pipes);
        $this->assertEquals($isTtySupported, '/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT));

        if ($isTtySupported) {
            // When tty is supported, we can't validate the exact cursor position since it depends where the cursor is when the test runs.             // Instead we just make sure that it doesn't return 1,1             $this->assertNotEquals([1, 1]$position);
        } else {
            
Home | Imprint | This part of the site doesn't use cookies.