From 4ca7f9714d9870162eb26f3274a8339455335866 Mon Sep 17 00:00:00 2001 From: dissimulo Date: Tue, 21 Apr 2026 09:27:03 -0700 Subject: [PATCH] rainbow-dark: drop rainbow dashes, add rainbow-timestamp.pl - rainbow-dark.theme: revert line_start back to the stock '-!-' pattern. - .irssi/scripts/autorun/rainbow-timestamp.pl: new autorun script that hooks 'print text', matches a leading HH:MM[:SS], and reruns it through rainbow.pl's make_colors (same palette [4,8,9,11,12,13], same 2-char stride, same phase-advance on each line). The result is that every successive timestamp is a 5-character rainbow gradient that also shifts starting colour line-to-line. --- .irssi/rainbow-dark.theme | 7 +-- .irssi/scripts/autorun/rainbow-timestamp.pl | 67 +++++++++++++++++++++ 2 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 .irssi/scripts/autorun/rainbow-timestamp.pl diff --git a/.irssi/rainbow-dark.theme b/.irssi/rainbow-dark.theme index 3bd3c412..a6ea3010 100644 --- a/.irssi/rainbow-dark.theme +++ b/.irssi/rainbow-dark.theme @@ -62,11 +62,8 @@ abstracts = { ## generic ## - # text to insert at the beginning of each non-message line — ROYGBIV dashes - # R = bright red, O = dark yellow/brown (closest ANSI orange), - # Y = bright yellow, G = bright green, B = bright blue, - # I = dark blue (closest ANSI indigo), V = bright magenta (violet). - line_start = "%R-%y-%Y-%G-%B-%b-%M-%n "; + # text to insert at the beginning of each non-message line (default) + line_start = "%B-%n!%B-%n "; # timestamp styling, nothing by default timestamp = "$*"; diff --git a/.irssi/scripts/autorun/rainbow-timestamp.pl b/.irssi/scripts/autorun/rainbow-timestamp.pl new file mode 100644 index 00000000..8bec123f --- /dev/null +++ b/.irssi/scripts/autorun/rainbow-timestamp.pl @@ -0,0 +1,67 @@ +# +# rainbow-timestamp.pl — paint each printed line's leading timestamp with +# the rotating rainbow palette from rainbow.pl, so every successive line +# advances the colour phase. Each individual timestamp is itself a +# gradient across its own characters (HH:MM -> five different colours). +# +# Drops into ~/.irssi/scripts/autorun/; loads automatically on irssi start. +# + +use strict; +use warnings; +use vars qw($VERSION %IRSSI); +use Irssi; + +$VERSION = '0.1'; +%IRSSI = ( + authors => 'dissimulo', + contact => 'connect+gitea@dustin-williams.com', + name => 'rainbow-timestamp', + description => 'Rotating-rainbow timestamps (same palette/logic as rainbow.pl).', + license => 'GNU GPLv2 or later', +); + +# mIRC colour palette — identical to rainbow.pl: +# 4 = light red, 8 = yellow, 9 = light green, +# 11 = light cyan, 12 = light blue, 13 = light magenta +my @colors = ('4', '8', '9', '11', '12', '13'); +my $last_color = 0; +my $colorrep = 2; # how many chars share each colour before advancing + +sub make_colors { + my ($string) = @_; + my $out = ''; + my $last = $last_color; + for (my $c = 0; $c < length($string); $c++) { + my $char = substr($string, $c, 1); + $last++; + my $color = int($last / $colorrep) % scalar(@colors); + $out .= "\003" . sprintf('%02d', $colors[$color]); + $out .= ($char eq ',') ? "\," : $char; + } + $last_color += 2; # advance phase so the next call starts shifted + return $out; +} + +# Hook 'print text' — fires once per window line, with the fully-rendered +# text (including the leading timestamp if info_eol is off, which is the +# default). We match a leading HH:MM or HH:MM:SS, recolour it, and pass +# the line back through signal_continue with the rest of the text intact. +Irssi::signal_add('print text', sub { + my ($dest, $text, $stripped) = @_; + return unless defined $text; + + # Strip any existing colour codes from just the prefix to find the + # raw timestamp (irssi's theme abstract may have wrapped it). + # Match (optional colour prefix) + HH:MM[:SS] + (optional colour suffix) + space + if ($text =~ /^((?:\003\d{1,2}(?:,\d{1,2})?)*)(\d{2}:\d{2}(?::\d{2})?)((?:\017|\003)?)(\s)/) { + my $pre = $1; # existing colour codes before the timestamp + my $ts = $2; # the timestamp itself + my $post = $3; # colour reset (if any) + my $sep = $4; # whitespace between ts and rest + my $rest = substr($text, length($pre) + length($ts) + length($post) + length($sep)); + + my $coloured = make_colors($ts) . "\017"; # \017 = reset colour + Irssi::signal_continue($dest, $coloured . $sep . $rest, $stripped); + } +});