Internal rework pending editframe
This commit is contained in:
@@ -16,11 +16,11 @@ class Ansi extends AbstractParser {
|
||||
* @param int $start
|
||||
* @return bool|int
|
||||
*/
|
||||
private function findEOF(string $char,int $start)
|
||||
private function findEOF(string $char,int $start,string $content)
|
||||
{
|
||||
for ($c=$start;$c <= strlen($this->content);$c++)
|
||||
for ($c=$start;$c <= strlen($content);$c++)
|
||||
{
|
||||
if ($this->content{$c} != $char)
|
||||
if ($content{$c} != $char)
|
||||
return $c-$start;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Ansi extends AbstractParser {
|
||||
* @param int $offset
|
||||
* @return string
|
||||
*/
|
||||
protected function parse($startline): string
|
||||
protected function parse(int $startline,string $content,int $width): string
|
||||
{
|
||||
// Our starting coordinates
|
||||
$x = 1;
|
||||
@@ -40,10 +40,10 @@ class Ansi extends AbstractParser {
|
||||
$output = '';
|
||||
|
||||
// Scan the frame for a field start
|
||||
for ($c=0; $c<=strlen($this->content); $c++)
|
||||
for ($c=0; $c<=strlen($content); $c++)
|
||||
{
|
||||
// If the frame is not big enough, fill it with spaces.
|
||||
$byte = isset($this->content{$c}) ? $this->content{$c} : ' ';
|
||||
$byte = isset($content{$c}) ? $content{$c} : ' ';
|
||||
$advance = 0;
|
||||
|
||||
switch ($byte) {
|
||||
@@ -58,7 +58,7 @@ class Ansi extends AbstractParser {
|
||||
case ESC:
|
||||
$advance = 1;
|
||||
// Is the next byte something we know about
|
||||
$nextbyte = isset($this->content{$c+$advance}) ? $this->content{$c+$advance} : ' ';
|
||||
$nextbyte = isset($content{$c+$advance}) ? $content{$c+$advance} : ' ';
|
||||
|
||||
switch ($nextbyte) {
|
||||
case '[':
|
||||
@@ -68,7 +68,7 @@ class Ansi extends AbstractParser {
|
||||
// Find our end CSI param
|
||||
$matches = [];
|
||||
|
||||
$a = preg_match('/([0-9]+[;]?)+([a-zA-Z])/',$this->content,$matches,NULL,$c+$advance);
|
||||
$a = preg_match('/([0-9]+[;]?)+([a-zA-Z])/',$content,$matches,NULL,$c+$advance);
|
||||
|
||||
if (! $a)
|
||||
break;
|
||||
@@ -76,6 +76,13 @@ class Ansi extends AbstractParser {
|
||||
$advance += strlen($matches[0])-1;
|
||||
$chars .= $matches[0];
|
||||
|
||||
if (! isset($this->frame_data[$y][$x]))
|
||||
$this->frame_data[$y][$x] = '';
|
||||
else
|
||||
$this->frame_data[$y][$x] .= '|';
|
||||
|
||||
$this->frame_data[$y][$x] .= $matches[0];
|
||||
|
||||
switch ($matches[2]) {
|
||||
// We ignore 'm' they are color CSIs
|
||||
case 'm': break;
|
||||
@@ -96,10 +103,11 @@ class Ansi extends AbstractParser {
|
||||
break;
|
||||
|
||||
default:
|
||||
$c--; // Allow for the original ESC
|
||||
// Allow for the original ESC
|
||||
$c--;
|
||||
$advance++;
|
||||
$fieldtype = ord($nextbyte)%128; // @todo Do we need the %128 for ANSI?
|
||||
$fieldlength = $this->findEOF(chr($fieldtype),$c+2)+1;
|
||||
$fieldtype = ord($nextbyte);
|
||||
$fieldlength = $this->findEOF(chr($fieldtype),$c+2,$content)+1;
|
||||
|
||||
$byte = '';
|
||||
|
||||
@@ -122,6 +130,7 @@ class Ansi extends AbstractParser {
|
||||
$x++;
|
||||
}
|
||||
|
||||
$this->frame_content[$y][$x] = $byte;
|
||||
$output .= $byte;
|
||||
|
||||
if ($advance) {
|
||||
@@ -129,7 +138,7 @@ class Ansi extends AbstractParser {
|
||||
$c += $advance;
|
||||
}
|
||||
|
||||
if ($x > 80) {
|
||||
if ($x > $width) {
|
||||
$x = 1;
|
||||
$y++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user