From cf4725793daaff890b295b5269d224dfd33b52c0 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 8 Nov 2016 02:15:47 +0100 Subject: [PATCH] termcol: scalar colour shorthand --- termcol.plp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/termcol.plp b/termcol.plp index 3d807a2..3f8befc 100644 --- a/termcol.plp +++ b/termcol.plp @@ -131,14 +131,18 @@ sub coltable { printf "%s\n", $caption; for my $row (@$table) { print ''; - 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 "", img_egapal(\@imgpal, @{$_}); } + } print "\n\n"; } -- 2.30.0