This commit is contained in:
1 parent
f7c532a648
commit
640bd67556
5801 files changed
+484532
-55857
No files matched your search
+26
-3
@@ -84,8 +84,31 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
*/
|
||||
public function overwrite(string|iterable $message): void
|
||||
{
|
||||
$this->clear();
|
||||
$this->writeln($message);
|
||||
if (!$this->content || !$this->isDecorated()) {
|
||||
$this->writeln($message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace own content and write everything in a single cursor-up + erase
|
||||
// pass, to avoid the flicker (and the line-eating artifacts on some
|
||||
// terminals) caused by calling clear() then writeln() back-to-back.
|
||||
$linesCleared = $this->lines;
|
||||
$this->content = [];
|
||||
$this->lines = 0;
|
||||
|
||||
if (!is_iterable($message)) {
|
||||
$message = [$message];
|
||||
}
|
||||
|
||||
foreach ($message as $line) {
|
||||
$this->addContent($this->getFormatter()->format($line) ?? '', true);
|
||||
}
|
||||
|
||||
$erasedContent = $this->popStreamContentUntilCurrentSection($this->maxHeight ? min($this->maxHeight, $linesCleared) : $linesCleared);
|
||||
|
||||
parent::doWrite($this->getVisibleContent(), false);
|
||||
parent::doWrite($erasedContent, false);
|
||||
}
|
||||
|
||||
public function getContent(): string
|
||||
@@ -222,7 +245,7 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
|
||||
if ($numberOfLinesToClear > 0) {
|
||||
// move cursor up n lines
|
||||
parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
|
||||
parent::doWrite(\sprintf("\x1b[%dA", $numberOfLinesToClear), false);
|
||||
// erase to end of screen
|
||||
parent::doWrite("\x1b[0J", false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user