This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
vbbs/app/Classes/Frame/Ansi.php

53 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Classes\Frame;
2019-07-12 03:42:01 +00:00
use App\Classes\Parser;
use Illuminate\Support\Facades\Log;
2019-07-12 03:42:01 +00:00
use App\Classes\Frame;
use App\Classes\Parser\Ansi as AnsiParser;
2019-07-12 03:42:01 +00:00
use App\Models\Frame as FrameModel;
2019-07-12 03:42:01 +00:00
class Ansi extends Frame
{
public static $frame_length = 22;
public static $frame_width = 80;
public static $header_length = 58;
public static $pagenum_length = 11;
public static $cost_length = 7;
public static $cost_unit = 'u';
2018-12-11 12:31:44 +00:00
public static $if_filler = '.';
2019-07-12 03:42:01 +00:00
public function __construct(FrameModel $o,string $msg='')
{
parent::__construct($o);
// If we have a message to display on the bottom line.
if ($msg)
$this->output .= ESC.'[24;0f'.$msg.HOME;
}
2019-07-12 03:42:01 +00:00
protected function parser(int $startline): Parser
{
2019-07-12 03:42:01 +00:00
return new AnsiParser($this->fo->content,self::$frame_width,$startline);
}
2019-07-12 03:42:01 +00:00
public static function strlenv($text):int {
return strlen($text ? preg_replace('/'.ESC.'\[[0-9;?]+[a-zA-Z]/','',$text) : $text);
}
2019-07-31 12:19:41 +00:00
// @todo make abstract
/**
* This function returns the frame content, raw
*
* @return string
*/
public function raw(): string
{
// We need to convert any ESC's, not next to [ into a character, otherwise we are off by one
return preg_replace('/'.ESC.'([^\[])/',"|$1",$this->fo->content);
}
}