Enabled ANSI and Videotex servers and frames

This commit is contained in:
Deon George
2018-12-09 09:43:18 +11:00
parent 6c91c69bd9
commit 0eb71ef7c6
11 changed files with 429 additions and 243 deletions

View File

@@ -2,10 +2,72 @@
namespace App\Classes\Server;
use App\Classes\Server as AbstractServer;
use Illuminate\Support\Facades\Log;
class Ansi extends AbstractServer {
use App\Classes\Server as AbstractServer;
use App\Models\Mode;
class Ansi extends AbstractServer {
public function __construct(Mode $o)
{
define('ESC', chr(27));
define('CON', ESC.'[?25h'); // Cursor On
define('COFF', ESC.'[?25l'); // Cursor Off
define('HOME', ESC.'[0;0f');
define('LEFT', ESC.'[D'); // Move Cursor
define('RIGHT', ESC.'[C'); // Move Cursor
define('DOWN', chr(10)); // Move Cursor
define('UP', chr(11)); // Move Cursor
define('CR', chr(13));
define('LF', chr(10));
define('CLS', ESC.'[2J');
define('HASH', '#'); // Enter
define('STAR', '*'); // Star Entry
define('SPACE', ' '); // Space
// NOTE: This consts are effective output
define('RED', ESC.'[0;31m'.SPACE);
define('GREEN', ESC.'[0;32m'.SPACE);
define('YELLOW', ESC.'[1;33m'.SPACE);
define('BLUE', ESC.'[0;34m'.SPACE);
define('MAGENTA', ESC.'[0;35m'.SPACE);
define('CYAN', ESC.'[0;36m'.SPACE);
define('WHITE', ESC.'[1;37m'.SPACE);
define('NEWBG', '');
// Raw attributes - used when storing frames.
define('R_RED', RED);
define('R_GREEN', GREEN);
define('R_YELLOW', YELLOW);
define('R_BLUE', BLUE);
define('R_MAGENTA', MAGENTA);
define('R_CYAN', CYAN);
define('R_WHITE', WHITE);
//define('FLASH',chr(8));
parent::__construct($o);
}
// Abstract function
public function sendBaseline($client,$text,$reposition=FALSE) {
$client->send(ESC.'[24;0f'.$text.
($this->blp > $this->strlenv($text)
? str_repeat(' ',$this->blp-$this->strlenv($text)).
($reposition ? ESC.'[24;0f'.str_repeat(RIGHT,$this->strlenv($text)) : '')
: '')
);
$this->blp = $this->strlenv($text);
}
// Abstract function
public function strlenv($text):int {
return strlen($text ? preg_replace('/'.ESC.'\[[0-9;?]+[a-zA-Z]/','',$text) : $text);
}
// Abstract function
public function testFrame()
{
return \App\Classes\Frame\Ansi::testFrame($this);
}
}