From: Loïc Gomez Date: Thu, 1 Dec 2022 12:22:05 +0000 (+0900) Subject: Add /cubes_text to show colors applied to the text, not the background X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=e3f1f30c932b8a81d743632a6e6eb3c83814bbef;p=irssi-scripts.irssi.org.git Add /cubes_text to show colors applied to the text, not the background --- diff --git a/scripts/cubes.pl b/scripts/cubes.pl index 6c1c11e..58d0c71 100644 --- a/scripts/cubes.pl +++ b/scripts/cubes.pl @@ -2,7 +2,7 @@ use strict; use warnings; use Irssi 20140603; -our $VERSION = '1.0'; +our $VERSION = '1.1'; our %IRSSI = ( authors => 'Irssi staff', contact => 'staff@irssi.org', @@ -12,39 +12,44 @@ our %IRSSI = ( license => 'Public Domain', ); -Irssi::command_bind 'cubes' => sub { +sub cubes { + my $t = $_[0]; my $w = Irssi::active_win; my $C = MSGLEVEL_CLIENTCRAP; my $N = MSGLEVEL_NEVER | $C; + my $T = $t ? "X" : "x"; + my $M = $t ? "" : "99,"; my $P = sub { $w->print(@_) }; $P->("%_bases", $C); $P->( do { - join '', map { "%x0${_}0$_" } '0' .. '9', 'A' .. 'F' + join '', map { "%${T}0${_}0$_" } '0' .. '9', 'A' .. 'F' }, $N); $P->("%_cubes", $C); $P->( do { my $y = $_*6; join '', map { my $x = $_; - map { "%x$x$_$x$_" } @{['0' .. '9', 'A' .. 'Z']}[$y .. $y+5] + map { "%${T}$x$_$x$_" } @{['0' .. '9', 'A' .. 'Z']}[$y .. $y+5] } 1 .. 6 }, $N) for 0 .. 5; $P->("%_grays", $C); $P->( do { - join '', map { "%x7${_}7$_" } 'A' .. 'X' + join '', map { "%${T}7${_}7$_" } 'A' .. 'X' }, $N); $P->("%_mIRC extended colours", $C); my $x; - $x .= sprintf "\cC99,%02d%02d", $_, $_ + $x .= sprintf "\cC$M%02d%02d", $_, $_ for 0 .. 15; $P->($x, $N); for my $z (0 .. 6) { my $x; - $x .= sprintf "\cC99,%02d%02d", $_, $_ + $x .= sprintf "\cC$M%02d%02d", $_, $_ for 16 + ($z * 12) .. 16 + ($z * 12) + 11; $P->($x, $N); } -}; +} +Irssi::command_bind 'cubes' => sub { cubes(0); }; +Irssi::command_bind 'cubes_text' => sub { cubes(1); };