You are here

private function ProgressBar::overwrite in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Helper/ProgressBar.php \Symfony\Component\Console\Helper\ProgressBar::overwrite()

Overwrites a previous message to the output.

Parameters

string $message The message:

2 calls to ProgressBar::overwrite()
ProgressBar::clear in vendor/symfony/console/Helper/ProgressBar.php
Removes the progress bar from the current line.
ProgressBar::display in vendor/symfony/console/Helper/ProgressBar.php
Outputs the current progress string.

File

vendor/symfony/console/Helper/ProgressBar.php, line 515

Class

ProgressBar
The ProgressBar provides helpers to display progress output.

Namespace

Symfony\Component\Console\Helper

Code

private function overwrite($message) {
  $lines = explode("\n", $message);

  // append whitespace to match the line's length
  if (null !== $this->lastMessagesLength) {
    foreach ($lines as $i => $line) {
      if ($this->lastMessagesLength > Helper::strlenWithoutDecoration($this->output
        ->getFormatter(), $line)) {
        $lines[$i] = str_pad($line, $this->lastMessagesLength, " ", STR_PAD_RIGHT);
      }
    }
  }
  if ($this->overwrite) {

    // move back to the beginning of the progress bar before redrawing it
    $this->output
      ->write("\r");
  }
  elseif ($this->step > 0) {

    // move to new line
    $this->output
      ->writeln('');
  }
  if ($this->formatLineCount) {
    $this->output
      ->write(sprintf("\33[%dA", $this->formatLineCount));
  }
  $this->output
    ->write(implode("\n", $lines));
  $this->lastMessagesLength = 0;
  foreach ($lines as $line) {
    $len = Helper::strlenWithoutDecoration($this->output
      ->getFormatter(), $line);
    if ($len > $this->lastMessagesLength) {
      $this->lastMessagesLength = $len;
    }
  }
}