#
use strict;
+use warnings;
+
use Irssi 20021105;
use Irssi::TextUI;
use vars qw($VERSION %IRSSI);
-$VERSION = '0.0.6';
+$VERSION = '0.1.0';
%IRSSI = (
authors => 'Marcus Rueckert',
contact => 'darix@irssi.org',
sbitems => 'inputlength',
license => 'BSD License or something more liberal',
url => 'http://www.irssi.de./',
- changed => '2021-01-11'
+ changed => '2026-08-15'
);
my $help = << "END";
%9Settings%9
/set inputlength_width 0
/set inputlength_padding_char
+ /set inputlength_max 0
END
sub beancounter {
my ( $sbItem, $get_size_only ) = @_;
- my ( $width, $padChar, $padNum, $length );
+ my ( $width, $padChar, $padNum, $maxLength, $txtLength, $length );
#
# getting settings
#
$width = Irssi::settings_get_int ( 'inputlength_width' );
$padChar = Irssi::settings_get_str ( 'inputlength_padding_char' );
+ $maxLength = Irssi::settings_get_int ( 'inputlength_max' );
+
+ $txtLength = Irssi::parse_special("\$\@L");
+
+ # count remaining instead of encountered characters
+ if ($maxLength > 0) {
+ $txtLength = $maxLength - $txtLength;
+ }
#
# only one char allowed
#
# getting formatted lengh
#
- $length = Irssi::parse_special ( "\$[-!$width$padChar]\@L" );
+ $length = Irssi::parse_special ( "\$[-!$width$padChar]0", "$txtLength" );
#
# did we have a number?
#
- $length =~ s/$padChar/$padNum/g if ( $padNum ne '' );
+ $length =~ s/$padChar/$padNum/g if ( defined $padNum && $padNum ne '' );
- $sbItem->default_handler ( $get_size_only, "{sb $length}", undef, 1 );
+ $sbItem->default_handler ( $get_size_only, "{sb $length}", "", 1 );
}
Irssi::statusbar_item_register ( 'inputlength', 0, 'beancounter' );
};
Irssi::settings_add_int ( 'inputlength', 'inputlength_width', 0 );
+Irssi::settings_add_int ( 'inputlength', 'inputlength_max', 0 );
#
# setting:
#