Skip to content

Commit

Permalink
align server tags
Browse files Browse the repository at this point in the history
  • Loading branch information
handlename committed Mar 19, 2013
1 parent 1382b3c commit 9a8d296
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions channel-socket.pl
Expand Up @@ -34,11 +34,28 @@
},
);

my @window_params_list;
my $max_length = 0;

for my $window (Irssi::windows()) {
my $name = $window->{active} ? $window->{active}{name} : $window->{name};
my $server_tag = $window->{active} ? ' - '$window->{active}{server}{tag} : '';
$h->push_write("$name$server_tag\n") if $h;
my $name = $window->{active} ? $window->{active}{name} : $window->{name};
my $server_tag = $window->{active} ? $window->{active}{server}{tag} : '';
my $length = length $name;

push @window_params_list, {
name => $name,
server_tag => $server_tag,
length => length $name,
};

$max_length = $length if $max_length < $length;
}

for my $params (@window_params_list) {
my $padding = $params->{server_tag} ? ' ' x ($max_length - $params->{length} + 1) : '';
$h->push_write("${$params}{name}$padding${$params}{server_tag}\n") if $h;
}

$h->on_drain(sub { undef $h }) if $h;
};

Expand Down

0 comments on commit 9a8d296

Please sign in to comment.