Enabled ANSI and Videotex servers and frames
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Server;
|
||||
|
||||
use App\Classes\Server as AbstractServer;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class VideoTex extends AbstractServer {
|
||||
|
||||
}
|
72
app/Classes/Server/Videotex.php
Normal file
72
app/Classes/Server/Videotex.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Server;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\Server as AbstractServer;
|
||||
use App\Models\Mode;
|
||||
|
||||
class Videotex extends AbstractServer {
|
||||
public function __construct(Mode $o)
|
||||
{
|
||||
define('ESC', chr(27));
|
||||
define('CON', chr(17)); // Cursor On
|
||||
define('COFF', chr(20)); // Cursor Off
|
||||
define('HOME', chr(30));
|
||||
define('LEFT', chr(8)); // Move Cursor
|
||||
define('RIGHT', chr(9)); // Move Cursor
|
||||
define('DOWN', chr(10)); // Move Cursor
|
||||
define('UP', chr(11)); // Move Cursor
|
||||
define('CR', chr(13));
|
||||
define('LF', chr(10));
|
||||
define('CLS', chr(12));
|
||||
define('HASH', '_'); // Enter
|
||||
define('STAR', '*'); // Star Entry
|
||||
define('SPACE', ''); // Space
|
||||
|
||||
// NOTE: This consts are effective output
|
||||
define('RED', ESC.'A');
|
||||
define('GREEN', ESC.'B');
|
||||
define('YELLOW', ESC.'C');
|
||||
define('BLUE', ESC.'D');
|
||||
define('MAGENTA', ESC.'E');
|
||||
define('CYAN', ESC.'F');
|
||||
define('WHITE', ESC.'G');
|
||||
define('NEWBG', ESC.']');
|
||||
|
||||
// Raw attributes - used when storing frames.
|
||||
define('R_RED', chr(1));
|
||||
define('R_GREEN', chr(2));
|
||||
define('R_YELLOW', chr(3));
|
||||
define('R_BLUE', chr(4));
|
||||
define('R_MAGENTA', chr(5));
|
||||
define('R_CYAN', chr(6));
|
||||
define('R_WHITE', chr(7));
|
||||
define('FLASH', chr(8));
|
||||
|
||||
parent::__construct($o);
|
||||
}
|
||||
|
||||
public function sendBaseline($client,$text,$reposition=FALSE) {
|
||||
$client->send(HOME.UP.$text.
|
||||
($this->blp > $this->strlenv($text)
|
||||
? str_repeat(' ',$this->blp-$this->strlenv($text)).
|
||||
($reposition ? HOME.UP.str_repeat(RIGHT,$this->strlenv($text)) : '')
|
||||
: '')
|
||||
);
|
||||
|
||||
$this->blp = $this->strlenv($text);
|
||||
}
|
||||
|
||||
// Abstract function
|
||||
public function strlenv($text):int {
|
||||
return strlen($text)-substr_count($text,ESC);
|
||||
}
|
||||
|
||||
// Abstract function
|
||||
public function testFrame()
|
||||
{
|
||||
return \App\Classes\Frame\Videotex::testFrame($this);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user