From: Mischa POSLAWSKY Date: Sun, 23 Oct 2016 04:48:35 +0000 (+0200) Subject: termcol: parse Xcolors.net checkout X-Git-Tag: v1.9~30 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/b10a1871f75e16efe0cf94f05f2f9585ef0a8ea9 termcol: parse Xcolors.net checkout Prepare a separate (optional) include with themes from the popular ansi palettes repository . --- diff --git a/Makefile b/Makefile index c13afc1..1750fd0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: digraphs.inc.pl unicode-cover.inc.pl countries.inc.pl data/browser/support.inc.pl +all: digraphs.inc.pl unicode-cover.inc.pl countries.inc.pl data/browser/support.inc.pl termcol-xcolor.inc.pl more: all data/digraphs-xorg.inc.pl download: data/DerivedAge.txt data/rfc1345.txt data/xorg-compose data/countryInfo.txt data/caniuse.json @@ -37,6 +37,9 @@ unicode-char.inc.pl: tools/mkcharinfo data/digraphs-rfc.inc.pl data/digraphs-shi ttfsupport/%.inc.pl: tools/mkttfinfo data/font/%.ttf $< $(word 2,$^) $@ || true +termcol-xcolor.inc.pl: tools/mktermcol-xcolor + $< >$@ + .SECONDARY: data/font/%.ttf: find /usr/share/fonts/truetype/ ~/.fonts/ -iname "$(@F)" | head -1 | xargs -i ln -sf {} $@ diff --git a/termcol.plp b/termcol.plp index 8f8878b..3d807a2 100644 --- a/termcol.plp +++ b/termcol.plp @@ -42,6 +42,8 @@ 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"; diff --git a/tools/mktermcol-xcolor b/tools/mktermcol-xcolor new file mode 100755 index 0000000..2d007bc --- /dev/null +++ b/tools/mktermcol-xcolor @@ -0,0 +1,30 @@ +#!/usr/bin/env perl +use 5.010; + +say 'use strict;'; +say '+{'; +my @names; + +for my $path (glob 'data/xcolors/themes/*') { + open my $theme, '<', $path; + (my $name = $path) =~ s{.*/}{}; # basename + push @names, $name; + + my @pal; + while (readline $theme) { + m{ color(\d+) \h* : \h* ( \#(\S+) | rgb:(\S+) ) }x or next; + my ($idx, $val) = ($1, uc $+); + $idx < 16 or next; + $val =~ s/[^0-9A-F]//g; + $pal[$idx] = $val; + } + + say qq("$name" => {); + say qq(\ttitle => '$name',); + say qq(\tparent => 'cga',); + say qq(\tlist => [qw(@pal)],); + say qq(},); +} + +say 'xcolor => [', join(', ', map {"'$_'"} @names), '],'; +say '}';