public function overwrite($message, $newlines = 1, $size = null)
    {
        $size = $size ?: $this->_lastWritten;

        // Output backspaces.
        $this->out(str_repeat("\x08", $size), 0);

        $newBytes = $this->out($message, 0);

        // Fill any remaining bytes with spaces.
        $fill = $size - $newBytes;
        if ($fill > 0) {
            $this->out(str_repeat(' ', $fill), 0);
        }
        if ($newlines) {
            $this->out($this->nl($newlines), 0);
        }

        // Store length of content + fill so if the new content
        // is shorter than the old content the next overwrite
        // will work.
        if ($fill > 0) {
            $this->_lastWritten = $newBytes + $fill;
        }
    }
public function overwrite($message, $newlines = 1, $size = null)
    {
        $size = $size ?: $this->_lastWritten;

        // Output backspaces.
        $this->out(str_repeat("\x08", $size), 0);

        $newBytes = $this->out($message, 0);

        // Fill any remaining bytes with spaces.
        $fill = $size - $newBytes;
        if ($fill > 0) {
            $this->out(str_repeat(' ', $fill), 0);
        }
        if ($newlines) {
            $this->out($this->nl($newlines), 0);
        }

        // Store length of content + fill so if the new content
        // is shorter than the old content the next overwrite
        // will work.
        if ($fill > 0) {
            $this->_lastWritten = $newBytes + $fill;
        }
    }
public function overwrite ( $ message , $ newlines = 1 , $ size = null ) { $ size = $ size ? : $ this -> _lastWritten ; // Output backspaces. $ this -> out ( str_repeat ( "\x08" , $ size ) , 0 ) ; $ newBytes = $ this -> out ( $ message , 0 ) ; // Fill any remaining bytes with spaces. $ fill = $ size - $ newBytes ; if ( $ fill > 0 ) { $ this -> out ( str_repeat ( ' ' , $ fill ) , 0 ) ; } if ( $ newlines ) { $ this -> out ( $ this -> nl ( $ newlines ) , 0 ) ; } // Store length of content + fill so if the new content // is shorter than the old content the next overwrite // will work. if ( $ fill > 0 ) { $ this -> _lastWritten = $ newBytes + $ fill ; } }
Overwrite some already output text.

Useful for building progress bars, or when you want to replace
text already output to the screen with new text.

**Warning** You cannot overwrite text that contains newlines.

@param array|string $message The message to output.
@param int $newlines Number of newlines to append.
@param int|null $size The number of bytes to overwrite. Defaults to the
length of the last message output.
@return void
Overwrite some already output text .