savePosition example

foreach ($autocomplete($ret) as $value) {
                    // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)                     if (str_starts_with($value$tempRet)) {
                        $matches[$numMatches++] = $value;
                    }
                }
            }

            $cursor->clearLineAfter();

            if ($numMatches > 0 && -1 !== $ofs) {
                $cursor->savePosition();
                // Write highlighted text, complete the partially entered response                 $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice)));
                $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs]$charactersEntered)).'</hl>');
                $cursor->restorePosition();
            }
        }

        // Reset stty so it behaves normally again         shell_exec('stty '.$sttyMode);

        return $fullChoice;
    }
foreach ($autocomplete($ret) as $value) {
                    // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)                     if (str_starts_with($value$tempRet)) {
                        $matches[$numMatches++] = $value;
                    }
                }
            }

            $cursor->clearLineAfter();

            if ($numMatches > 0 && -1 !== $ofs) {
                $cursor->savePosition();
                // Write highlighted text, complete the partially entered response                 $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice)));
                $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs]$charactersEntered)).'</hl>');
                $cursor->restorePosition();
            }
        }

        // Reset stty so it behaves normally again         shell_exec('stty '.$sttyMode);

        return $fullChoice;
    }
$cursor = new Cursor($output = $this->getOutputStream());

        $cursor->clearLine();

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

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

        $cursor->savePosition();

        $this->assertEquals("\x1b7", $this->getOutputContent($output));
    }

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

        $cursor->hide();

        $this->assertEquals("\x1b[?25l", $this->getOutputContent($output));
    }
Home | Imprint | This part of the site doesn't use cookies.