diff options
| author | David Leadbeater | 2015-04-16 16:01:59 +0100 | 
|---|---|---|
| committer | David Leadbeater | 2015-04-16 16:01:59 +0100 | 
| commit | 302f88999f8e931363326b981a1eead10f790317 (patch) | |
| tree | b3ce2dcb9fa42b24665cd42abfb5d2a7f8c9dde4 /scripts/act.pl | |
| parent | 3ace4555457e7e82fda452676b78b9c3eb8c4a94 (diff) | |
| download | scripts.irssi.org-302f88999f8e931363326b981a1eead10f790317.tar.bz2 | |
Simplify act.pl to make it cleaner
Diffstat (limited to 'scripts/act.pl')
| -rw-r--r-- | scripts/act.pl | 53 | 
1 files changed, 11 insertions, 42 deletions
| diff --git a/scripts/act.pl b/scripts/act.pl index b14435f..f7a7528 100644 --- a/scripts/act.pl +++ b/scripts/act.pl @@ -8,7 +8,7 @@ use strict;  use vars qw($VERSION %IRSSI);  use Irssi 20020120; -$VERSION = "0.13"; +$VERSION = "0.14";  %IRSSI = (      authors	=> "c0ffee",      contact	=> "c0ffee\@penguin-breeder.org", @@ -16,11 +16,10 @@ $VERSION = "0.13";      description	=> "Reset window activity status. defines command /act",      license	=> "Public Domain",      url		=> "http://www.penguin-breeder.org/irssi/", -    changed	=> "Wed Jun 23 08:34:53 CEST 2004", +    changed	=> "Thu Apr 16 15:55:05 BST 2015",  );  #</scriptinfo> -  #  # /ACT [PUBLIC|ALL]  # @@ -30,46 +29,16 @@ $VERSION = "0.13";  # /ACT PUBLIC also removes those where no nick hilight was triggered  #  # /ACT ALL sets all windows as non-active -sub cmd_act { -    my ($data, $server, $channel) = @_; - -    my $level; - -    if ($data eq "") { -      $level = 1; -    } elsif ($data =~ /^public$/i) { -      $level = 2; -    } elsif ($data =~ /^all$/i) { -      $level = 3; -    } else { -      Irssi::signal_emit("error command", -3, $data); -      return; -    } - -    foreach (Irssi::windows()) { - -      if ($_->{data_level} <= $level) { -        Irssi::signal_emit("window dehilight", $_); +Irssi::command_bind('act', sub { _act(1); }); +Irssi::command_bind('act public', sub { _act(2); }); +Irssi::command_bind('act all', sub { _act(3); }); -      } - -    } -} - -my @arguments = ('public', 'all'); -sub sig_complete { -    my ($list, $window, $word, $linestart, $want_space) = @_; -    return unless $linestart =~ /^.act/; -    foreach my $arg (@arguments) { -      if ($arg =~ /^$word/i) { -        $$want_space = 0; -        push @$list, $arg; -      } +sub _act { +  my($level) = @_; +  for (Irssi::windows()) { +    if ($_->{data_level} <= $level) { +      Irssi::signal_emit("window dehilight", $_);      } -    Irssi::signal_stop(); +  }  } - - -Irssi::command_bind("act", "cmd_act"); -Irssi::signal_add_first('complete word', \&sig_complete); | 
