charset: compare classes legend
[sheet.git] / charset.plp
index 309139e940fa46ec54b39e1a2c039768cfe698a2..79ebd96deb2ff338c4bdf494ca7425fa94e785a1 100644 (file)
@@ -137,18 +137,21 @@ sub tabinput {
 
                my @parents = @{ $INHERIT->{$input} || [] };
 
-               if (my ($parent, $part) = pairfirst { $visible->{$a} } @parents) {
+               if (my ($parent, $part) = pairfirst { defined $visible->{$a} } @parents) {
                        $row{parent} = $parent;
                        $params = $part;
+                       $params = 128 unless $visible->{$parent}
+                               or ($input eq 'MacCroatian' and defined $visible->{MacRomanian});
                }
-               elsif ($visible->{ascii}) {
-                       $row{parent} = $parents[0] || 'ascii';
+               elsif (defined $visible->{ascii}) {
+                       $row{parent} = $parents[0];
                        $params = $parents[1] || 128;
                        $params = 128 if $params >= 128;  # ascii offset at most
                }
                elsif (@parents) {
                        $row{parent} = $parents[0];
                }
+               $visible->{$_} //= 0 for $row{parent};
        }
 
        if (defined $params and $params =~ m/^ (\d+) (-\d+)? /x) {
@@ -320,6 +323,20 @@ for my $row (@request) {
                                next;
                        }
 
+                       if (exists $get{compare}) {
+                               state $visible = {};
+                               my $cp = $offset + $row->{offset};
+                               printf '<td class="%s" title="%3$s">%2$s',
+                                       $cp == ord $glyph ? 'l4' :
+                                       $row->{parent} && $glyph eq
+                                               Encode::decode($row->{parent}, pack 'C', $cp) ? 'l3' :
+                                       $visible->{$glyph} ? 'l2' :
+                                       'l1',
+                                       $glyphs->glyph_html($glyph);
+                               $visible->{$glyph}++;
+                               next;
+                       }
+
                        print "\n".$glyphs->glyph_cell($glyph);
                }
                continue {
@@ -334,7 +351,13 @@ for my $row (@request) {
 <hr>
 
 <div class="legend">
-       <table class="glyphs"><tr>
+       <table class="glyphs"><tr><: if (exists $get{compare}) { :>
+       <td class="X l4">unicode
+       <td class="X l3">inherited
+       <td class="X l2">existing
+       <td class="X l1">original
+       <td class="">unassigned
+<: } else { :>
        <td class="X Cc">control
        <td class="X Zs"><span>whitespace</span>
        <td class="X Mn">diacritic<table class="glyphs"><tr>
@@ -371,6 +394,6 @@ for my $row (@request) {
        <td class="X Xd">deprecated
        <td class="">unassigned
        <td class="X Xi">invalid
-       </table>
+<: } :>        </table>
 </div>