'address#', 'd'=>'%date', ]; // Position array of frame control chars protected $frame_data = []; // Position array of frame chars protected $frame_content = []; // Parsed frame, ready to send to client public $output = ''; public function __construct(string $content,int $width,int $startline=1) { $this->fields = collect(); $this->output = $this->parse($startline,$content,$width); } public function __toString(): string { return $this->output; } /** * Return the character at a specific position * * @param int $x * @param int $y * @return string */ public function char(int $x,int $y): string { $y += 1; return (isset($this->frame_content[$y]) AND isset($this->frame_content[$y][$x])) ? $this->frame_content[$y][$x] : ' '; } public function attr(int $x,int $y) { $y += 1; return (isset($this->frame_data[$y]) AND isset($this->frame_data[$y][$x])) ? implode(';',$this->frame_data[$y][$x]).'m' : '-'; } abstract protected function parse(int $startline,string $content,int $width): string; }