From: Mischa POSLAWSKY Date: Tue, 2 May 2017 19:39:55 +0000 (+0200) Subject: termcol: optional preset for xcolors include X-Git-Tag: v1.10~30 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/42dac653b12a2d5ff5455c2bccd126e97dcf0ed5 termcol: optional preset for xcolors include Avoid load unless needed. --- diff --git a/termcol.inc.pl b/termcol.inc.pl index bf0001b..6e3b6d6 100644 --- a/termcol.inc.pl +++ b/termcol.inc.pl @@ -7,6 +7,12 @@ use Shiar_Sheet::Colour 1.05; ansi => [qw( cga putty xterm tango app html cgarne )], legacy => [qw( c64 msx mac2 risc arnegame dawnbringer cpc cpcboy shiar32 ppu 64 )], + xcolors => sub { + my $pals = do 'termcol-xcolor.inc.pl' or die $! || $@; + $_[0]->{$_} = $pals->{$_} for keys %{$pals}; + return 'xcolor'; + }, + html => { title => 'HTML keywords (inherited by CSS≥2.1 and SVG), mostly identical to X11', href => 'http://www.w3.org/TR/css3-color/#html4', diff --git a/termcol.plp b/termcol.plp index bd9fd53..26a5c70 100644 --- a/termcol.plp +++ b/termcol.plp @@ -46,8 +46,6 @@ use POSIX qw( ceil ); my $palettes = do 'termcol.inc.pl'; die "Cannot open palette data: $_\n" for $@ || $! || (); -my $more = do 'termcol-xcolor.inc.pl' || {}; -$palettes = {%$palettes, %$more}; sub colcell { my $name = shift // return "\n"; @@ -108,6 +106,12 @@ sub coltable { if (ref $info eq 'ARRAY') { coltable($_) for @{$info}; + return; + } + + if (ref $info eq 'CODE') { + coltable($_) for $info->($palettes); + return; } ref $info eq 'HASH' or return;