termcol: move colour values into data hashes
[sheet.git] / termcol.plp
index 686316cf8f8f1cb9b3cb6734913147991c001f9b..44ee75bcd53179846ee0f15233cb42509ea5f33a 100644 (file)
@@ -75,7 +75,8 @@ if ($get{v}) {
 my @termlist = qw( cga xterm tango app html xkcd );
 push @termlist, qw( c64 msx2 mac2 risc arnegame ) if exists $get{v};
 for my $term (@termlist) {
 my @termlist = qw( cga xterm tango app html xkcd );
 push @termlist, qw( c64 msx2 mac2 risc arnegame ) if exists $get{v};
 for my $term (@termlist) {
-       my ($info, @index) = @{ $palettes->{$term} };
+       my $info = $palettes->{$term};
+       ref $info eq 'HASH' or next;
        my $caption = $info->{name} // $term;
        $caption = sprintf('<%s %s>%s</%1$s>',
                $info->{href} ? 'a' : 'span',
        my $caption = $info->{name} // $term;
        $caption = sprintf('<%s %s>%s</%1$s>',
                $info->{href} ? 'a' : 'span',
@@ -87,15 +88,17 @@ for my $term (@termlist) {
                $caption,
        ) if $info->{href} or $info->{title};
 
                $caption,
        ) if $info->{href} or $info->{title};
 
-       print '<table>', "\n";
-       printf "<caption>%s</caption>\n", $caption;
-       for my $num (0 .. $#index) {
-               my ($rgb, $name) = split /:/, $index[$num], 3;
-               $name ||= $num;
-               $name = [ $name, ['#333'] ] if $term eq 'xkcd';
-               print '<tr>', colcell($name, $rgb);
+       if (my $colours = $info->{list}) {
+               print '<table>', "\n";
+               printf "<caption>%s</caption>\n", $caption;
+               for my $num (0 .. $#{$colours}) {
+                       my ($rgb, $name) = split /:/, $colours->[$num], 3;
+                       $name ||= $num;
+                       $name = [ $name, ['#333'] ] if $term eq 'xkcd';
+                       print '<tr>', colcell($name, $rgb);
+               }
+               print "</table>\n\n";
        }
        }
-       print "</table>\n\n";
 }
 
 if (exists $get{v}) {
 }
 
 if (exists $get{v}) {