interface iScreen {
// SETUP
static function Me() : self;
// CURSOR
function NewLine() : string;
// MARKS: formatting
function OpenFixed() : string;
function ShutFixed() : string;
// MARKS: graphical elements
function HorizLine() : string;
function LeftArrow() : string;
function RightArrow() : string;
// FORMATS: character
function BoldIt(?string $s) : string;
function ItalIt(?string $s) : string;
function SmallIt(?string $s) : string;
function UBarIt(?string $s) : string;
// FORMATS: colors
function GreenIt(string $s) : string;
function BlueIt(string $s) : string;
function YellowIt(string $s) : string;
// FORMATS: styles
function Styles() : StylesIface;
function ErrorIt(string $s) : string;
function WarnIt(string $s) : string;
function FaintIt(string $s) : string;
function TitleIt(string $s) : string;
function InfoIt(string $s) : string;
function XMLTagIt(string $s) : string;
// FORMATS: hypertext
function LinkIt(string $sText, string $sURL) : string;
// FORMATS: block
function BoxIt(string $s) : string;
function FixPitchIt(string $s) : string;
function NewLineIt(string $s) : string; // make sure "\n"s cause linebreaks
function HideDrop(string $sSummary, string $sContent) : string;
function NewTable() : TableIface;
function NewList() : ListIface;
function MakeList(string $s) : string; // convert CRLFs to list items
// MARKUP
function StripMarkup(string $s) : string;
function RenderHTML(string $ht) : string;
// for FerretMarks
const KS_FMT_CRLF = '<<crlf>>';
const KS_FMT_BOLD1 = '<<+b>>';
const KS_FMT_BOLD0 = '<<-b>>';
const KS_FMT_ITAL1 = '<<+i>>';
const KS_FMT_ITAL0 = '<<-i>>';
const KS_FMT_PRE1 = '<<+pre>>';
const KS_FMT_PRE0 = '<<-pre>>';
const KS_FMT_SMALL1 = '<<+sm>>';
const KS_FMT_SMALL0 = '<<-sm>>';
function RenderMarkup(string $ft) : string;
}
abstract class caScreen implements iScreen {
// ++ CLASSES ++ //
abstract protected function ElementClass() : string;
abstract protected function FallbackStyleClass() : string;
// -- CLASSES -- //
// ++ SETUP ++ //
static public function ActivateTextMode() {
require_once(__DIR__.'/Screen/Text.php');
new Screen\cText;
}
static public function ActivateWebMode() {
require_once(__DIR__.'/Screen/Web.php');
new Screen\cWeb;
}
static private $oMe = NULL;
public function __construct() { self::$oMe = $this; }
static public function Me() : iScreen { return self::$oMe; }
static private $osMe = NULL;
// -- SETUP -- //
// ++ OBJECTS ++ //
private $oStyles=NULL;
public function Styles() : StylesIface { return $this->oStyles ?? ($this->oStyles = StylesClass::AsNew()); }
private $oElem = NULL; public function Element() : ElemIface { return $this->oElem ?? ($this->oElem = new ($this->ElementClass())); }
public function NewTable() : TableIface { return ($this->Element()->NewTable()); }
public function NewList() : ListIface { return ($this->Element()->NewList()); }
// -- OBJECTS -- //
// ++ OUTPUT ++ //
public function WarnIt(string $s) : string { return $this->YellowIt($s); } // DEFAULT
public function RenderMarkup(string $ft) : string {
$sOut = str_replace(
[
self::KS_FMT_CRLF,
self::KS_FMT_BOLD1,
self::KS_FMT_BOLD0,
self::KS_FMT_ITAL1,
self::KS_FMT_ITAL0,
self::KS_FMT_PRE1,
self::KS_FMT_PRE0,
self::KS_FMT_SMALL1,
self::KS_FMT_SMALL0,
],
[
NEWLINE,
$this->MarkForBold(TRUE),
$this->MarkForBold(FALSE),
$this->MarkForItal(TRUE),
$this->MarkForItal(FALSE),
$this->OpenFixed(),
$this->ShutFixed(),
$this->MarkForSmall(TRUE),
$this->MarkForSmall(FALSE),
],
$ft
);
return $sOut;
}
// -- OUTPUT -- //
// ++ INTERNAL: markup ++ //
abstract protected function MarkForBold(bool $bOn) : string;
abstract protected function MarkForItal(bool $bOn) : string;
abstract protected function MarkForSmall(bool $bOn) : string;
// -- INTERNAL -- //
}