$1<\/a>/g;
s/\n \.\n/\n \n/g;
return $_;
}
sub layout
{ my ($Name, $Head, $Code, $Doku, $Dflt, $Attr) = @_;
if ($html)
{
print "
|
\n";
print "| $Name\n";
if ($Attr eq '')
{
print " | $Head\n";
}
else
{
print " | $Head\n";
print " | $Attr\n";
}
if ($Code ne '')
{
my @Part = split('\|',$Code);
my $Type = $Part[0];
my $Indi = $#Part > 0 ? $Part[1] : "";
my $Parm = $#Part > 1 ? $Part[2] : "";
$Code = $Parm if $Type eq 'PRN';
$Code = $Indi if $Type eq 'CTL';
$Code = "ESC $Indi" if $Type eq 'ESC';
$Code = "0x7f" if $Type eq 'DEL';
$Code = "ESC # $Indi" if $Type eq 'HSH';
$Code = "ESC $Parm" if $Type eq 'SCS';
$Code = "ESC Y $Parm" if $Type eq 'VT5';
$Code = "ESC [ $Parm $Indi" if $Type eq 'CSI';
$Code = "ESC [ ? $Parm $Indi" if $Type eq 'PRI';
print " |
| \n";
print "
| \n";
print " | ", codeToHtml($Code), "\n";
print " | Default: $Dflt\n" if ($Dflt ne '');
}
print " |
| \n";
print "
| \n";
# $_ = $Doku;
# s/</g;
# s/>/>/g;
# s/\\ref:([A-Z0-9]+)/$1<\/a>/g;
# s/\n \.\n/\n \n/g;
print "
";
print txt2Html($Doku);
print "\n";
}
if ($test)
{
print "NAME: $Name\n";
print "TEXT: $Head\n";
print "CODE: $Code\n";
print "ATTR: $Attr\n";
print "DFLT: $Dflt\n";
# print "DOCU: $Doku\n";
}
}
sub codeToHtml
{ my ($code) = @_;
my $res = '';
foreach (split(' ', $code))
{
/^\{(.*)\}$/ && do { $res .= " $1"; next; };
/^<$/ && do { $res .= ' <'; next; };
/^>$/ && do { $res .= ' >'; next; };
$res .= " $_";
}
return $res . '';
}
# -----------------------------------------------------------------------------
sub secthead
{ my ($Title) = @_;
print "\n";
print "\n";
print " | \n";
print "| $Title | \n";
print " | \n";
print " \n";
print "\n";
}
sub layout2
{ my ($Name, $Head, $Code) = @_;
my @Part = split('\|',$Code);
my $Type = $#Part > -1 ? $Part[0] : "";
my $Indi = $#Part > 0 ? $Part[1] : "";
my $Parm = $#Part > 1 ? $Part[2] : "";
if ($Type eq 'CTL')
{
$_ = $Indi;
s/0x00/@/; s/0x01/A/; s/0x02/B/; s/0x03/C/;
s/0x04/D/; s/0x05/E/; s/0x06/F/; s/0x07/G/;
s/0x08/H/; s/0x09/I/; s/0x0a/J/; s/0x0b/K/;
s/0x0c/L/; s/0x0d/M/; s/0x0e/N/; s/0x0f/O/;
s/0x10/P/; s/0x11/Q/; s/0x12/R/; s/0x13/S/;
s/0x14/T/; s/0x15/U/; s/0x16/V/; s/0x17/W/;
s/0x18/X/; s/0x19/Y/; s/0x1a/Z/; s/0x1b/[/;
s/0x1c/\\/; s/0x1d/]/; s/0x1e/^/; s/0x1f/_/;
$Indi = $_;
}
print " |
\n";
print "| $Name\n";
print " | $Type\n";
print " | $Indi\n";
print " | $Parm\n";
print " | $Head\n";
}
sub layoutTable
{
my ($Head, $t, $Include) = @_;
my $p;
print " |
$Head\n";
foreach $p (sort keys %$t)
{
my @Fld = split('\.', $p);
if ($#Fld == 1 && $Fld[1] eq 'head')
{
my $name = $Fld[0];
my $head = $t->{$p};
my $attr = exists $t->{"$name.sect"}?$t->{"$name.sect"}:"";
if ($attr =~ /$Include/)
{
layout2( $name, $head, exists $t->{"$name.code"}?$t->{"$name.code"}:"");
}
}
}
}
sub sortTest
{
my ($t) = @_;
my $p;
my $s = {};
my $n = {};
my $curr = "";
foreach $p (keys %$t)
{
my @Fld = split('\.', $p);
if ($#Fld == 1 && $Fld[1] eq 'head')
{
my $name = $Fld[0];
if (exists $t->{"$name.code"})
{
$s->{$t->{"$name.code"}} = $name;
}
}
}
print "\n";
foreach $p (sort keys %$s)
{
my $name = $s->{$p};
my @Fld = split('\|', $p);
if ($Fld[0] ne $curr)
{
print "$Fld[0] codes\n";
}
$curr = $Fld[0];
layout2($name,$t->{"$name.head"},$p);
}
print " | \n";
}
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# MAIN ------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
my $t = parse();
my $p;
my $table = 0;
# -------------------------------
secthead("Host to Terminal (Instructions by Group)");
print "\n";
layoutTable("Commands (Character Display Operation)",$t,"Command\.Display");
layoutTable("Commands (Rendition related status)",$t,"Command\.RenderMode");
layoutTable("Commands (Cursor)",$t,"Command\.Cursor");
layoutTable("Commands (Cursor related status)",$t,"Command\.CursMode");
layoutTable("Commands (Edit)",$t,"Command\.Erase|Command\.Insert|Command.\Delete");
layoutTable("Commands (Miscellaneous)",$t,"Command[^.]|Command\$");
layoutTable("Commands (General mode setting)",$t,"Command\.SetMode");
layoutTable("Commands (Miscellaneous status)",$t,"Command\.Mode");
layoutTable("Commands (VT52)",$t,"Command\.VT52");
layoutTable("Commands (Not implemented)",$t,"Command\.NoImp");
layoutTable("Commands (Ignored)",$t,"Command\.Ignored");
layoutTable("Commands (Requests)",$t,"Command\.Request");
print " \n";
# -------------------------------
secthead("Host to Terminal (Instructions by Code)");
sortTest($t);
# -------------------------------
secthead("Terminal to Host");
print "\n";
layoutTable("Replies",$t,"Reply");
layoutTable("Events",$t,"Event");
# -------------------------------
print " \n";
secthead("Modes");
print "\n";
layoutTable("Modes",$t,"Mode");
#print "Other Codes\n";
print " \n";
# -------------------------------
secthead("Appendix A - Notion Details");
# -------------------------------
head();
foreach $p (sort keys %$t)
{
my @Fld = split('\.', $p);
if ($#Fld == 1 && $Fld[1] eq 'head')
{
# print "\n" if ($table);
my $name = $Fld[0];
my $head = $t->{$p};
layout( $name, $head,
exists $t->{"$name.code"}?$t->{"$name.code"}:"",
exists $t->{"$name.text"}?$t->{"$name.text"}:"",
exists $t->{"$name.dflt"}?$t->{"$name.dflt"}:"",
exists $t->{"$name.emus"}?$t->{"$name.emus"}:"" );
$table = 0;
}
if ($html && $#Fld == 2 && $Fld[1] eq 'table')
{
my $lines = $t->{$p};
my $line;
my $field;
my @fldspan = ();
my $ln = 0;
print " |
|
\n";
# print "| $Fld[2] | Meaning |
\n";
foreach $line (split('\n', $lines))
{
my $fn = 0;
@fldspan = split('\|',$line) if ($ln == 0);
print "\n";
print " | \n";
foreach $field (split('\|',$line))
{
if ($ln == 0)
{
my @Parts = split(":",$field);
$field = $Parts[0];
$fldspan[$fn] = ($#Parts > 0) ? $Parts[1] : 1;
}
print " 0 && $ln % 2 == 0);
print " $color3" if ($ln > 0 && $ln % 2 == 1);
print ">";
print txt2Html($field);
print " | ";
$fn += 1;
}
print "
\n";
$ln += 1;
}
$table = 1;
}
}
tail();