1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
use Irssi::Irc;
# Usage:
# /script load go.pl
# If you are in #irssi you can type /go #irssi or /go irssi or even /go ir ...
# also try /go ir<tab> and /go <tab> (that's two spaces)
$VERSION = '1.00';
%IRSSI = (
authors => 'nohar',
contact => 'nohar@freenode',
name => 'go to window',
description => 'Implements /go command that activates a window given a name/partial name. It features a nice completion.',
license => 'GPLv2 or later',
changed => '08-17-04'
);
sub signal_complete_go {
my ($complist, $window, $word, $linestart, $want_space) = @_;
my $channel = $window->get_active_name();
my $k = Irssi::parse_special('$k');
return unless ($linestart =~ /^\Q${k}\Ego/i);
@$complist = ();
foreach my $w (Irssi::windows) {
my $name = $w->get_active_name();
if ($word ne "") {
if ($name =~ /\Q${word}\E/i) {
push(@$complist, $name)
}
} else {
push(@$complist, $name);
}
}
Irssi::signal_stop();
};
sub cmd_go
{
my($chan,$server,$witem) = @_;
$chan =~ s/ *//g;
foreach my $w (Irssi::windows) {
my $name = $w->get_active_name();
if ($name =~ /^#?\Q${chan}\E/) {
$w->set_active();
return;
}
}
}
Irssi::command_bind("go", "cmd_go");
Irssi::signal_add_first('complete word', 'signal_complete_go');
|