4 my $source = "Table.Codes";
9 # Syntax -----------------------------------------------------------------------
16 # The dotted names have to be unique. Conceptually, they form a tree.
19 # Data Model ------------------------------------------------------------------
21 # This is currently pretty wierd.
23 # Empirically, we have
25 # NAME.head <Title Line>
26 # NAME.attr { lots ... }
28 # NAME.code <Typ>|<Ide>|<Parm>
30 # <text with some special tricks>
32 # <"|"-separated head line>
33 # <"|"-separated data rows>
39 # - .XPS, used for instructions with subcodes
40 # Subcode|Emulation|Scope|Operation|Parameter|Meaning
42 # -----------------------------------------------------------------------------
43 # -----------------------------------------------------------------------------
44 # Analyze Source --------------------------------------------------------------
45 # -----------------------------------------------------------------------------
46 # -----------------------------------------------------------------------------
57 { my ($expect,$lineno,$line) = @_;
58 if ($state != $expect)
60 print STDERR
"$source($lineno): line unexpected in state $state. : $line\n";
66 $all->{$name} = $value;
71 open(CODES
, $source) || die "cannot open file '" . $source . "'.";
74 chop; # strip record separator
75 my @Fld = split(' ', $_);
79 reduce
() if $state != 0;
81 elsif (substr($_, 0, 1) eq '#')
85 elsif (substr($_, 0, 1) eq ' ')
87 $value .= ($value eq "" ?
"" : "\n") . $_; #FIXME: unchop
91 reduce
() if $state != 0;
99 $value = join ' ', @Fld[1..$#Fld];
104 reduce
() if ($state == 1);
110 # -----------------------------------------------------------------------------
111 # -----------------------------------------------------------------------------
112 # Html Layout -----------------------------------------------------------------
113 # -----------------------------------------------------------------------------
114 # -----------------------------------------------------------------------------
121 print "<tr><td width=10%%><td><td><td><td><td><td width=40%%>\n";
133 my $color1 = " bgcolor=\"#D0D0D0\""; # table head // section head
134 my $color2 = " bgcolor=\"#5BA5B2\""; # table body (even)
135 my $color3 = " bgcolor=\"#5188B2\""; # table body (odd)
136 my $color4 = ""; # code, default
137 my $color5 = ""; # text
145 s/\\ref:([A-Z0-9]+)/<a href=#$1>$1<\/a>/g
;
146 s/\n \.\n/\n <p>\n/g;
151 { my ($Name, $Head, $Code, $Doku, $Dflt, $Attr) = @_;
155 print "<tr><td><p></td></tr>\n";
157 print "<tr><td $color1><a name=$Name>$Name</a>\n";
160 print " <td $color1 colspan=6><b>$Head</b>\n";
164 print " <td colspan=5 $color1><b>$Head</b>\n";
165 print " <td $color1>$Attr\n";
170 my @Part = split('\|',$Code);
172 my $Indi = $#Part > 0 ?
$Part[1] : "";
173 my $Parm = $#Part > 1 ?
$Part[2] : "";
174 $Code = $Parm if $Type eq 'PRN';
175 $Code = $Indi if $Type eq 'CTL';
176 $Code = "ESC $Indi" if $Type eq 'ESC';
177 $Code = "0x7f" if $Type eq 'DEL';
178 $Code = "ESC # $Indi" if $Type eq 'HSH';
179 $Code = "ESC $Parm" if $Type eq 'SCS';
180 $Code = "ESC Y $Parm" if $Type eq 'VT5';
181 $Code = "ESC [ $Parm $Indi" if $Type eq 'CSI';
182 $Code = "ESC [ ? $Parm $Indi" if $Type eq 'PRI';
183 print "<tr><td><p></td>\n";
185 print " <td colspan=5 $color4>", codeToHtml
($Code), "\n";
186 print " <td $color4>Default: $Dflt\n" if ($Dflt ne '');
189 print "<tr><td><p></td>\n";
190 print "<tr><td></td>\n";
194 # s/\\ref:([A-Z0-9]+)/<a href=#$1>$1<\/a>/g;
195 # s/\n \.\n/\n <p>\n/g;
196 print " <td $color5 colspan=6>";
197 print txt2Html
($Doku);
202 print "NAME: $Name\n";
203 print "TEXT: $Head\n";
204 print "CODE: $Code\n";
205 print "ATTR: $Attr\n";
206 print "DFLT: $Dflt\n";
207 # print "DOCU: $Doku\n";
214 foreach (split(' ', $code))
216 /^\{(.*)\}$/ && do { $res .= " <em>$1</em>"; next; };
217 /^<$/ && do { $res .= ' <b><</b>'; next; };
218 /^>$/ && do { $res .= ' <b>></b>'; next; };
219 $res .= " <b>$_</b>";
221 return $res . '</code>';
224 # -----------------------------------------------------------------------------
229 print "<table width=100%>\n";
230 print "<tr><td align=center bgcolor=#d0d0d0></td></tr>\n";
231 print "<tr><td align=center bgcolor=#d0d0d0>$Title</td></tr>\n";
232 print "<tr><td align=center bgcolor=#d0d0d0></td></tr>\n";
238 { my ($Name, $Head, $Code) = @_;
239 my @Part = split('\|',$Code);
240 my $Type = $#Part > -1 ?
$Part[0] : "";
241 my $Indi = $#Part > 0 ?
$Part[1] : "";
242 my $Parm = $#Part > 1 ?
$Part[2] : "";
246 s/0x00/@/; s/0x01/A/; s/0x02/B/; s/0x03/C/;
247 s/0x04/D/; s/0x05/E/; s/0x06/F/; s/0x07/G/;
248 s/0x08/H/; s/0x09/I/; s/0x0a/J/; s/0x0b/K/;
249 s/0x0c/L/; s/0x0d/M/; s/0x0e/N/; s/0x0f/O/;
250 s/0x10/P/; s/0x11/Q/; s/0x12/R/; s/0x13/S/;
251 s/0x14/T/; s/0x15/U/; s/0x16/V/; s/0x17/W/;
252 s/0x18/X/; s/0x19/Y/; s/0x1a/Z/; s/0x1b/[/;
253 s/0x1c/\\/; s/0x1d/]/; s/0x1e/^/; s/0x1f/_/;
257 print "<td $color1><a href=#$Name>$Name</a>\n";
258 print "<td $color1>$Type\n";
259 print "<td $color1>$Indi\n";
260 print "<td $color1>$Parm\n";
261 print "<td $color1>$Head\n";
266 my ($Head, $t, $Include) = @_;
268 print "<tr><td colspan=5><h3>$Head</h3>\n";
269 foreach $p (sort keys %$t)
271 my @Fld = split('\.', $p);
272 if ($#Fld == 1 && $Fld[1] eq 'head')
276 my $attr = exists $t->{"$name.sect"}?
$t->{"$name.sect"}:"";
277 if ($attr =~ /$Include/)
279 layout2
( $name, $head, exists $t->{"$name.code"}?
$t->{"$name.code"}:"");
292 foreach $p (keys %$t)
294 my @Fld = split('\.', $p);
295 if ($#Fld == 1 && $Fld[1] eq 'head')
298 if (exists $t->{"$name.code"})
300 $s->{$t->{"$name.code"}} = $name;
305 foreach $p (sort keys %$s)
308 my @Fld = split('\|', $p);
309 if ($Fld[0] ne $curr)
311 print "<tr><td colspan=5><h3>$Fld[0] codes</h3>\n";
314 layout2
($name,$t->{"$name.head"},$p);
322 $_ = $all->{"$h.html"};
323 s/\n \.\n/\n <p>\n/g;
327 # -----------------------------------------------------------------------------
328 # -----------------------------------------------------------------------------
329 # MAIN ------------------------------------------------------------------------
330 # -----------------------------------------------------------------------------
331 # -----------------------------------------------------------------------------
337 # -------------------------------
338 htmlsect
("Introduction");
339 # -------------------------------
340 secthead
("Control Sequences");
341 htmlsect
("Sequences");
342 # -------------------------------
343 secthead
("Host to Terminal (Instructions by Code)");
345 # -------------------------------
346 secthead
("Host to Terminal (Instructions by Group)");
347 htmlsect
("Operations");
349 layoutTable
("Commands (Character Display Operation)",$t,"Command\.Display");
350 layoutTable
("Commands (Rendition related status)",$t,"Command\.RenderMode");
351 layoutTable
("Commands (Cursor)",$t,"Command\.Cursor");
352 layoutTable
("Commands (Cursor related status)",$t,"Command\.CursMode");
353 layoutTable
("Commands (Edit)",$t,"Command\.Erase|Command\.Insert|Command.\Delete");
354 layoutTable
("Commands (Miscellaneous)",$t,"Command[^.]|Command\$");
355 layoutTable
("Commands (General mode setting)",$t,"Command\.SetMode");
356 layoutTable
("Commands (Miscellaneous status)",$t,"Command\.Mode");
357 layoutTable
("Commands (VT52)",$t,"Command\.VT52");
358 layoutTable
("Commands (Not implemented)",$t,"Command\.NoImp");
359 layoutTable
("Commands (Ignored)",$t,"Command\.Ignored");
360 layoutTable
("Commands (Requests)",$t,"Command\.Request");
362 # -------------------------------
363 secthead
("Terminal to Host");
365 layoutTable
("Replies",$t,"Reply");
366 layoutTable
("Events",$t,"Event");
367 # -------------------------------
371 layoutTable
("Modes",$t,"Mode");
372 #print "<h3>Other Codes</h3>\n";
374 # -------------------------------
375 secthead
("Appendix A - Notion Details");
376 htmlsect
("ConceptDB");
377 # -------------------------------
380 foreach $p (sort keys %$t)
382 my @Fld = split('\.', $p);
383 if ($#Fld == 1 && $Fld[1] eq 'head')
385 # print "</table>\n" if ($table);
388 layout
( $name, $head,
389 exists $t->{"$name.code"}?
$t->{"$name.code"}:"",
390 exists $t->{"$name.text"}?
$t->{"$name.text"}:"",
391 exists $t->{"$name.dflt"}?
$t->{"$name.dflt"}:"",
392 exists $t->{"$name.emus"}?
$t->{"$name.emus"}:"" );
395 if ($html && $#Fld == 2 && $Fld[1] eq 'table')
397 my $lines = $t->{$p};
402 print "<tr><td><p></td></tr>\n";
403 # print "<tr><td $color1>$Fld[2]</td><td $color1>Meaning</td></tr>\n";
404 foreach $line (split('\n', $lines))
407 @fldspan = split('\|',$line) if ($ln == 0);
410 foreach $field (split('\|',$line))
414 my @Parts = split(":",$field);
416 $fldspan[$fn] = ($#Parts > 0) ?
$Parts[1] : 1;
419 printf(" colspan=%s",$fldspan[$fn]);
420 print " $color1" if ($ln == 0);
421 print " $color2" if ($ln > 0 && $ln % 2 == 0);
422 print " $color3" if ($ln > 0 && $ln % 2 == 1);
424 print txt2Html
($field);