Skip to content

Instantly share code, notes, and snippets.

Created April 14, 2009 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/95312 to your computer and use it in GitHub Desktop.
Save anonymous/95312 to your computer and use it in GitHub Desktop.
use Irssi;
use Irssi::TextUI;
use strict;
our %IRSSI = (
authors => 'Decklin Foster',
contact => 'decklin@red-bean.com',
name => 'tweetlen',
description => 'Update length of tweet in statusbar',
license => 'ISC',
);
Irssi::statusbar_item_register('tweetlen', undef, 'tweetlen_sb');
Irssi::signal_add_last('gui key pressed', 'key_pressed');
sub key_pressed {
Irssi::statusbar_items_redraw('tweetlen');
}
sub tweetlen_sb {
my ($item, $size_only) = @_;
my $chars = 140 - length(Irssi::parse_special("\$L"));
if ($chars < 10) {
$chars = "%R$chars%n";
} elsif ($chars < 20) {
$chars = "%M$chars%n";
}
$item->default_handler($size_only, "{sb $chars}", undef, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment