Permalink
Browse files

align server tags

  • Loading branch information...
1 parent 1382b3c commit 9a8d296904d7e48f89f21f5e52265104ba274af1 @handlename handlename committed Mar 19, 2013
Showing with 20 additions and 3 deletions.
  1. +20 −3 channel-socket.pl
View
@@ -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;
};

0 comments on commit 9a8d296

Please sign in to comment.