diff options
| author | Trevor Slocum | 2016-09-11 15:19:57 -0700 | 
|---|---|---|
| committer | Trevor Slocum | 2016-09-13 20:09:42 -0700 | 
| commit | dad794ef0ffc1f10212f82e41dd91abf071731e3 (patch) | |
| tree | 86c36076ee51be93b110ede4fdae102dfe2c35ae /scripts | |
| parent | 1b036a570d39dde77905ae8f11f4c48e36b95130 (diff) | |
| download | scripts.irssi.org-dad794ef0ffc1f10212f82e41dd91abf071731e3.tar.bz2 | |
Improve anames nick prefix sorting
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/anames.pl | 42 | 
1 files changed, 27 insertions, 15 deletions
| diff --git a/scripts/anames.pl b/scripts/anames.pl index 385ffe6..b3af564 100644 --- a/scripts/anames.pl +++ b/scripts/anames.pl @@ -23,6 +23,8 @@  # Thanks to Dirm and Chris62vw for the Perl help and coekie for writing the  # evil code to sort the nicklist by the alphabet and rank in nicklist.pl  # +# 1.7   - Improved nick prefix sorting (tslocum) +#  # 1.6   - optional support for unicode nicknames, realnames script,  #         formattable summary line (default away colour changed!) (Nei)  # @@ -60,7 +62,7 @@ use List::Util qw(min max);  use vars qw($VERSION %IRSSI); -$VERSION = '1.6'; # 6eb152135b1bc6d +$VERSION = '1.7';  %IRSSI = (    authors     => 'Matt "f0rked" Sparks, Miklos Vajna',    contact     => 'ms+irssi@quadpoint.org', @@ -199,6 +201,27 @@ sub cmd_anames    }  } +sub prefix_index +{ +  my ($nick) = @_; +  my $index = 999; +  my $prefixes = Irssi::server_find_tag($tmp_server)->get_nick_flags(); +  if (!$prefixes) { +    $prefixes = "~&@%+"; +  } + +  my $prefix_index; +  foreach my $prefix (split("", $nick->{'prefixes'})) { +    if ($prefix) { +      $prefix_index = index($prefixes, $prefix); +      if ($prefix_index > -1) { +        $index = min($prefix_index, $index); +      } +    } +  } + +  return $index; +}  sub print_anames  { @@ -224,22 +247,11 @@ sub print_anames          my $nick = shift;          $prefer_real && length $nick->{'realname'} ? $nick->{'realname'} : $nick->{'nick'}      }; -    # sorting from nicklist.pl -    foreach my $nick (sort {($a->{'op'}?'1':$a->{'halfop'}?'2':$a->{'voice'}?'3':$a->{'other'}>32?'0':'4').lc($_real->($a)) -        cmp ($b->{'op'}?'1':$b->{'halfop'}?'2':$b->{'voice'}?'3':$b->{'other'}>32?'0':'4').lc($_real->($b))} $channel->nicks()) { +    foreach my $nick (sort {prefix_index($a) <=> prefix_index($b) || lc($a->{'nick'}) cmp lc($b->{'nick'})} $channel->nicks()) {        my $realnick = $_real->($nick);        my $gone = $nick->{'gone'}; - -      my $prefix; -      if ($nick->{'other'}) { -        $prefix = chr $nick->{'other'}; -      } elsif ($nick->{'op'}) { -        $prefix = "@"; -      } elsif ($nick->{'halfop'}) { -        $prefix = "%"; -      } elsif ($nick->{'voice'}) { -        $prefix = "+"; -      } else { +      my $prefix = substr($nick->{'prefixes'}, 0, 1); +      if (!$prefix) {          $prefix = " ";        } | 
