From: Ailin Nemui Date: Wed, 1 May 2019 15:10:23 +0000 (+0200) Subject: [adv_windowlist] update to 1.8 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=063ac0e28e52eef26a29c185c2dd508c9c8ee4ed;p=irssi-scripts.irssi.org.git [adv_windowlist] update to 1.8 - use string_width in Irssi 1.2.0 --- diff --git a/scripts/adv_windowlist.pl b/scripts/adv_windowlist.pl index c3bf7fa..e652ae7 100644 --- a/scripts/adv_windowlist.pl +++ b/scripts/adv_windowlist.pl @@ -1,7 +1,7 @@ use strict; use warnings; -our $VERSION = '1.7'; # 9926bc6b1f9d094 +our $VERSION = '1.8'; # 63feb35d8b0a8b6 our %IRSSI = ( authors => 'Nei', contact => 'Nei @ anti@conference.jabber.teamidiot.de', @@ -647,22 +647,27 @@ sub sb_format_expand { # Irssi::current_theme->format_expand wrapper } { my $term_type = Irssi::version > 20040819 ? 'term_charset' : 'term_type'; - local $@; - eval { require Text::CharWidth; }; - unless ($@) { - *screen_length = sub { Text::CharWidth::mbswidth($_[0]) }; + if (Irssi->can('string_width')) { + *screen_length = sub { Irssi::string_width($_[0]) }; } else { - my $err = $@; chomp $err; $err =~ s/\sat .* line \d+\.$//; - #Irssi::print("%_$IRSSI{name}: warning:%_ Text::CharWidth module failed to load. Length calculation may be off! Error was:"); - print "%_$IRSSI{name}:%_ $err"; - *screen_length = sub { - my $temp = shift; - if (lc Irssi::settings_get_str($term_type) eq 'utf-8') { - Encode::_utf8_on($temp); - } - length($temp) - }; + local $@; + eval { require Text::CharWidth; }; + unless ($@) { + *screen_length = sub { Text::CharWidth::mbswidth($_[0]) }; + } + else { + my $err = $@; chomp $err; $err =~ s/\sat .* line \d+\.$//; + #Irssi::print("%_$IRSSI{name}: warning:%_ Text::CharWidth module failed to load. Length calculation may be off! Error was:"); + print "%_$IRSSI{name}:%_ $err"; + *screen_length = sub { + my $temp = shift; + if (lc Irssi::settings_get_str($term_type) eq 'utf-8') { + Encode::_utf8_on($temp); + } + length($temp) + }; + } } sub as_uni { no warnings 'utf8'; @@ -2734,6 +2739,9 @@ UNITCHECK # Changelog # ========= +# 1.8 +# - use string_width in Irssi 1.2.0 +# # 1.7 # - fix crash on invalid /set awl_sort, introduced in 1.6, reported by # tpetazzoni