-
-
Save dato/95345 to your computer and use it in GitHub Desktop.
This file contains 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 @items = Irssi::active_win->items; | |
if (! @items || $items[0]->{name} ne "#twitter") { | |
$item->default_handler($size_only, "", undef, 1); | |
return; | |
} | |
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