From 42dac653b12a2d5ff5455c2bccd126e97dcf0ed5 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 2 May 2017 21:39:55 +0200 Subject: [PATCH 1/1] termcol: optional preset for xcolors include Avoid load unless needed. --- termcol.inc.pl | 6 ++++++ termcol.plp | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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; -- 2.30.0