X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/8b8c77dbf30f70a1e8ade679a62f08e130f959a2..d7efdac99433a38f91de80792fc037351798b267:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 446b9c5..9411ba4 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,111 +1,192 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; -use List::Util 'min'; +<(common.inc.plp)><: + +Html({ + title => 'terminal colour cheat sheet', + version => '1.0', + description => [ + "Index of all terminal/console colour codes,", + "with an example result of various environments.", + ], + keywords => [qw' + color code terminal console escape table xterm rxvt + '], + data => ['termcol.inc.pl'], + stylesheet => [qw'light dark'], +}); + +:> +

Terminal colours

-our $VERSION = 'v1.0'; +

+ANSI (VT100, ISO-6429) 16-colour text palette +as implemented by various systems and programs. +<: +print + !exists $get{v} ? 'Also see 8-bit legacy hardware palettes.' : + 'Also included are 8-bit legacy hardware palettes.'; +:> +

-$header{content_type} = 'text/html; charset=utf-8'; +
+<: +use Shiar_Sheet::Colour '1.03'; +use List::Util qw( min max ); -:> - +my $palettes = do 'termcol.inc.pl'; +die "Cannot open palette data: $_\n" for $@ || $! || (); - -terminal colour cheat sheet - - - +sub colcell { + my $name = shift // return "\n"; + my $col = Shiar_Sheet::Colour->new(@_); + my $minhex = $col->rgb24; + my $css = '#' . $col->rgb48; + my $inverse = '#' . sprintf('%X', $col->luminance/255 < .3 ? 12 : 0) x 3; - -

Terminal colours

+ my $sample = [ qw(#000 #FFF) ]; + ($name, $sample) = @$name if ref $name eq 'ARRAY'; - +:>

-

88-colour space

+if ($ENV{PATH_INFO} =~ /256/) { + print "

256-colour space

\n"; + print "\n"; + print coltable_hsv(6, + sub { + $_[2] + 6 * ($_[1] + 6 * $_[0]) + 16, + map { $_ && $_*40 + 55 } @_ + }, + [ map { $_ * 10 + 8 } 0 .. 23 ], + ); + print "
\n"; +} +:> +