]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
People in freenode #irssi have taken an interest, so get it to a public repository.
authorRocco Caputo <redacted>
Wed, 13 Oct 2010 21:31:44 +0000 (17:31 -0400)
committerbw1 <redacted>
Mon, 8 Jan 2018 17:18:10 +0000 (18:18 +0100)
scripts/ack.pl [new file with mode: 0644]

diff --git a/scripts/ack.pl b/scripts/ack.pl
new file mode 100644 (file)
index 0000000..ea2d278
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+# vim: ts=2 sw=2 expandtab
+
+# Ack: Jump to the next active window, with tiebreakers.
+
+use warnings;
+use strict;
+
+use Irssi;
+
+### Script header.
+
+our $VERSION = '1.000';
+
+use vars qw(%IRSSI);
+%IRSSI = (
+  name        => 'ack',
+  authors     => 'Rocco Caputo',
+  contact     => 'rcaputo@cpan.org',
+  url         => 'http://github.com/rcaputo/irssi-ack',
+  license     => 'Perl',
+  description => 'Jump to the next active window, with tiebreakers.',
+);
+
+# Jump to an active channel.
+
+sub cmd_ack {
+  my ($cmd, $server, $window) = @_;
+
+  # We sort the data_level in reverse order because higher numbers
+  # mean "more important".  If the data_level is equal between two
+  # windows, then we jump to the window that has been upbated least
+  # recently.
+  #
+  # Currently that's the window with the earliest (oldest) last line
+  # of text.
+
+  my @windows = sort {
+    ($b->{data_level} <=> $a->{data_level}) ||
+    ($a->{last_line}  <=> $b->{last_line} )
+  }
+  grep { $_->{data_level} }  # Must have some activity.
+  Irssi::windows();
+
+  # Jump to the first window.  How hard can it be?
+  $windows[0]->set_active() if @windows;
+}
+
+# Usage: /ack ... probably bind it to Meta-A or something.
+Irssi::command_bind("ack", "cmd_ack");
git clone https://git.99rst.org/PROJECT