X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/b10a1871f75e16efe0cf94f05f2f9585ef0a8ea9..29b407ddf91b653e6e8380f73e221628a392376f:/termcol.plp?ds=sidebyside diff --git a/termcol.plp b/termcol.plp index 3d807a2..571b296 100644 --- a/termcol.plp +++ b/termcol.plp @@ -2,7 +2,7 @@ Html({ title => 'terminal colour cheat sheet', - version => '1.0', + version => '1.1', description => [ "Index of all terminal/console colour codes,", "with an example result of various environments.", @@ -18,7 +18,7 @@ my @draw = map { [$_, s/\W+\z//] } grep { $_ } split m(/), $get{img} // exists $get{img} && 'indi.png'; my @termlist; -push @termlist, split /\W+/, $ENV{PATH_INFO} || 'default'; +push @termlist, split /\W+/, $Request || 'default'; :>

Terminal colours

@@ -35,14 +35,13 @@ print
<: -use 5.010; -use Shiar_Sheet::Colour '1.04'; +use Shiar_Sheet::Colour 1.04; use List::Util qw( min max ); use POSIX qw( ceil ); my $palettes = do 'termcol.inc.pl'; die "Cannot open palette data: $_\n" for $@ || $! || (); -my $more = do 'termcol-xcolor.inc.pl'; +my $more = do 'termcol-xcolor.inc.pl' || {}; $palettes = {%$palettes, %$more}; sub colcell { @@ -106,7 +105,7 @@ sub coltable { coltable($_) for @{$info}; } - ref $info eq 'HASH' or next; + ref $info eq 'HASH' or return; my $caption = $info->{name} // $term; $caption = sprintf('<%s %s>%s', @@ -120,26 +119,30 @@ sub coltable { ) if $info->{href} or $info->{title}; if (my $mapinfo = $info->{rgbmap}) { - print ''."\n"; - printf "\n", $caption; + say '
%s
'; + say sprintf '', $caption; print coltable_hsv(@{$mapinfo}); - print "
%s
\n\n"; + say "\n"; } if (my $table = $info->{table}) { - print ''."\n"; - printf "\n", $caption; + say '
%s
'; + say sprintf '', $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 "
%s
", img_egapal(\@imgpal, @{$_}); } - print "
\n\n"; + } + say "\n"; } if (my $palette = $info->{list}) { @@ -151,8 +154,8 @@ sub coltable { my $rows = 8; my $columns = ceil(@{$palette} / $rows); - print '', "\n"; - printf "\n", $caption; + say '
%s
'; + say sprintf '', $caption; for my $row (0 .. $rows - 1) { print ''; for my $col (0 .. $columns - 1) { @@ -171,7 +174,7 @@ sub coltable { ); print "
%s
", img_egapal($imgpal, @{$_}); } - print "
\n\n"; + say "\n"; } }