termcol: scalar colour shorthand
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 8 Nov 2016 01:15:47 +0000 (02:15 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 22 Mar 2017 21:28:04 +0000 (22:28 +0100)
termcol.plp

index 3d807a2..3f8befc 100644 (file)
@@ -131,14 +131,18 @@ sub coltable {
                printf "<caption>%s</caption>\n", $caption;
                for my $row (@$table) {
                        print '<tr>';
-                       print colcell(@$_) for @$row;
+                       print colcell(ref $_ ? @$_ : $_ ? reverse split /:/ : undef) for @$row;
                }
 
+       if (@draw) {
                my $width = scalar @{ $table->[0] };
-               my @imgpal = map { [ @{$_}[1 .. 3] ] } map { @{$_} } @{$table};
+               my @imgpal = map {
+                       [ ref $_ ? @{$_}[1 .. 3] : map {hex} /(..)(..)(..)/ ]
+               } map { @{$_} } @{$table};
                for (@draw) {
                        print "<tr><td colspan=$width>", img_egapal(\@imgpal, @{$_});
                }
+       }
                print "</table>\n\n";
        }