1
0
Fork 0

Add handling for backspace chars in BufferIO

pull/1313/merge
Jordi Boggiano 2012-11-11 15:05:27 +01:00
parent dc315cc768
commit b7fb60494d
1 changed files with 14 additions and 1 deletions

View File

@ -40,6 +40,19 @@ class BufferIO extends ConsoleIO
{ {
fseek($this->output->getStream(), 0); fseek($this->output->getStream(), 0);
return stream_get_contents($this->output->getStream()); $output = stream_get_contents($this->output->getStream());
$output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
$pre = strip_tags($matches[1]);
if (strlen($pre) === strlen($matches[2])) {
return '';
}
// TODO reverse parse the string, skipping span tags and \033\[([0-9;]+)m(.*?)\033\[0m style blobs
return rtrim($matches[1])."\n";
}, $output);
return $output;
} }
} }