Created
April 14, 2009 17:45
-
-
Save anonymous/95312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Irssi; | |
use Irssi::TextUI; | |
use strict; | |
our %IRSSI = ( | |
authors => 'Decklin Foster', | |
contact => '[email protected]', | |
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