restorePosition example


                }
            }

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

    private function mostRecentlyEnteredValue(string $entered): string
    {
        
$cursor = new Cursor($output = $this->getOutputStream());

        $cursor->show();

        $this->assertEquals("\x1b[?25h\x1b[?0c", $this->getOutputContent($output));
    }

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

        $cursor->restorePosition();

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

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

        $cursor->clearOutput();

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

                }
            }

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

    private function mostRecentlyEnteredValue(string $entered): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.