Skip to content

Commit 9861885

Browse files
committed
repo: streamline RGB struct using just one integer
1 parent dcf6d48 commit 9861885

5 files changed

Lines changed: 7157 additions & 7145 deletions

File tree

scripts/iterm2-color-schemes.pl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
for my $line (@lines) {
4747
if ($line =~ m!^[*][.](color\d+|foreground|background):\s*[#]([a-fA-F0-9]{6})!) {
4848
my ($k, $v) = ($1, $2);
49-
my ($r, $g, $b) = $v =~ m!(..)(..)(..)!;
50-
$spec->{$k} = [ map { hex } $r, $g, $b ];
49+
$spec->{$k} = "0x\U$v";
5150
}
5251
}
5352
my @undefined;
@@ -64,11 +63,11 @@
6463
$c_contents .= "// $file: $name -> $base\n";
6564
$c_contents .= "struct ansi_color_palette $real_var_name = {\n";
6665
$c_contents .= " \"$name\",\n";
67-
$c_contents .= sprintf " {0x%02X, 0x%02X, 0x%02X},\n", @{ $spec->{background} };
68-
$c_contents .= sprintf " {0x%02X, 0x%02X, 0x%02X},\n", @{ $spec->{foreground} };
66+
$c_contents .= sprintf " {.rgb = %s},\n", $spec->{background};
67+
$c_contents .= sprintf " {.rgb = %s},\n", $spec->{foreground};
6968
for (0..15) {
7069
$c_contents .= " {\n" if ($_ == 0);
71-
$c_contents .= sprintf " {0x%02X, 0x%02X, 0x%02X},\n", @{ $spec->{"color$_"} };
70+
$c_contents .= sprintf " {.rgb = %s},\n", $spec->{"color$_"};
7271
$c_contents .= " },\n" if ($_ == 7 || $_ == 15);
7372
$c_contents .= " {\n" if ($_ == 7);
7473
}

0 commit comments

Comments
 (0)