Cursor example



        if (!$this->output->isDecorated()) {
            // disable overwrite when output does not support ANSI codes.             $this->overwrite = false;

            // set a reasonable redraw frequency so output isn't flooded             $this->redrawFreq = null;
        }

        $this->startTime = time();
        $this->cursor = new Cursor($output);
    }

    /** * Sets a placeholder formatter for a given name, globally for all instances of ProgressBar. * * This method also allow you to override an existing placeholder. * * @param string $name The placeholder name (including the delimiter char like %) * @param callable(ProgressBar):string $callable A PHP callable */
    public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
    {
foreach ($config->getAttributeSanitizers() as $attributeSanitizer) {
            foreach ($attributeSanitizer->getSupportedElements() ?? ['*'] as $element) {
                foreach ($attributeSanitizer->getSupportedAttributes() ?? ['*'] as $attribute) {
                    $this->attributeSanitizers[$element][$attribute][] = $attributeSanitizer;
                }
            }
        }
    }

    public function visit(\DOMDocumentFragment $domNode): ?NodeInterface
    {
        $cursor = new Cursor(new DocumentNode());
        $this->visitChildren($domNode$cursor);

        return $cursor->node;
    }

    private function visitNode(\DOMNode $domNode, Cursor $cursor): void
    {
        $nodeName = StringSanitizer::htmlLower($domNode->nodeName);

        // Element should be dropped, including its children         if (!\array_key_exists($nodeName$this->elementsConfig)) {
            
return $data;
    }

    /** * Dumps data with a DumperInterface dumper. * * @return void */
    public function dump(DumperInterface $dumper)
    {
        $refs = [0];
        $cursor = new Cursor();
        $cursor->hashType = -1;
        $cursor->attr = $this->context[SourceContextProvider::class] ?? [];
        $label = $this->context['label'] ?? '';

        if ($cursor->attr || '' !== $label) {
            $dumper->dumpScalar($cursor, 'label', $label);
        }
        $cursor->hashType = 0;
        $this->dumpItem($dumper$cursor$refs$this->data[$this->position][$this->key]);
    }

    
return $data;
    }

    /** * Dumps data with a DumperInterface dumper. * * @return void */
    public function dump(DumperInterface $dumper)
    {
        $refs = [0];
        $cursor = new Cursor();
        $cursor->hashType = -1;
        $cursor->attr = $this->context[SourceContextProvider::class] ?? [];
        $label = $this->context['label'] ?? '';

        if ($cursor->attr || '' !== $label) {
            $dumper->dumpScalar($cursor, 'label', $label);
        }
        $cursor->hashType = 0;
        $this->dumpItem($dumper$cursor$refs$this->data[$this->position][$this->key]);
    }

    
$output->writeln($message);
    }

    /** * Autocompletes a question. * * @param resource $inputStream */
    private function autocomplete(OutputInterface $output, Question $question$inputStream, callable $autocomplete): string
    {
        $cursor = new Cursor($output$inputStream);

        $fullChoice = '';
        $ret = '';

        $i = 0;
        $ofs = -1;
        $matches = $autocomplete($ret);
        $numMatches = \count($matches);

        $sttyMode = shell_exec('stty -g');
        $isStdin = 'php://stdin' === (stream_get_meta_data($inputStream)['uri'] ?? null);
        


        if (!$this->output->isDecorated()) {
            // disable overwrite when output does not support ANSI codes.             $this->overwrite = false;

            // set a reasonable redraw frequency so output isn't flooded             $this->redrawFreq = null;
        }

        $this->startTime = time();
        $this->cursor = new Cursor($output);
    }

    /** * Sets a placeholder formatter for a given name, globally for all instances of ProgressBar. * * This method also allow you to override an existing placeholder. * * @param string $name The placeholder name (including the delimiter char like %) * @param callable(ProgressBar):string $callable A PHP callable */
    public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
    {

        $this->stream = fopen('php://memory', 'r+');
    }

    protected function tearDown(): void
    {
        unset($this->stream);
    }

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

        $cursor->moveUp();

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

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

        $cursor->moveUp(12);

        
$output->writeln($message);
    }

    /** * Autocompletes a question. * * @param resource $inputStream */
    private function autocomplete(OutputInterface $output, Question $question$inputStream, callable $autocomplete): string
    {
        $cursor = new Cursor($output$inputStream);

        $fullChoice = '';
        $ret = '';

        $i = 0;
        $ofs = -1;
        $matches = $autocomplete($ret);
        $numMatches = \count($matches);

        $sttyMode = shell_exec('stty -g');
        $isStdin = 'php://stdin' === (stream_get_meta_data($inputStream)['uri'] ?? null);
        
Home | Imprint | This part of the site doesn't use cookies.