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

Breadcrumb

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

function ConsoleSectionOutput::popStreamContentUntilCurrentSection

At initial stage, cursor is at the end of stream output. This method makes cursor crawl upwards until it hits current section. Then it erases content it crawled through. Optionally, it erases part of current section too.

3 calls to ConsoleSectionOutput::popStreamContentUntilCurrentSection()
ConsoleSectionOutput::clear in vendor/symfony/console/Output/ConsoleSectionOutput.php
Clears previous output for this section.
ConsoleSectionOutput::doWrite in vendor/symfony/console/Output/ConsoleSectionOutput.php
Writes a message to the output.
ConsoleSectionOutput::setMaxHeight in vendor/symfony/console/Output/ConsoleSectionOutput.php
Defines a maximum number of lines for this section.

File

vendor/symfony/console/Output/ConsoleSectionOutput.php, line 204

Class

ConsoleSectionOutput
@author Pierre du Plessis <pdples@gmail.com> @author Gabriel Ostrolucký <gabriel.ostrolucky@gmail.com>

Namespace

Symfony\Component\Console\Output

Code

private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0) : string {
    $numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
    $erasedContent = [];
    foreach ($this->sections as $section) {
        if ($section === $this) {
            break;
        }
        $numberOfLinesToClear += $section->maxHeight ? min($section->lines, $section->maxHeight) : $section->lines;
        if ('' !== ($sectionContent = $section->getVisibleContent())) {
            if (!str_ends_with($sectionContent, \PHP_EOL)) {
                $sectionContent .= \PHP_EOL;
            }
            $erasedContent[] = $sectionContent;
        }
    }
    if ($numberOfLinesToClear > 0) {
        // move cursor up n lines
        parent::doWrite(\sprintf("\x1b[%dA", $numberOfLinesToClear), false);
        // erase to end of screen
        parent::doWrite("\x1b[0J", false);
    }
    return implode('', array_reverse($erasedContent));
}

API Navigation

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