72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
|
<?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);
|
||
|
}
|
||
|
}
|