X-Git-Url: http://git.vpit.fr/?p=perl%2Fscripts%2Fxchat.git;a=blobdiff_plain;f=Xchat%2FXPI%2FUtils.pm;h=c8994abd6b5e7ed616be2247390560e9c074a31f;hp=cbd9494ae1cd5a158d34dc78a32a2196eadd7ff8;hb=HEAD;hpb=532ed2d6f4e5597f1dd76e71f2bd9880c5d779bb diff --git a/Xchat/XPI/Utils.pm b/Xchat/XPI/Utils.pm index cbd9494..c8994ab 100644 --- a/Xchat/XPI/Utils.pm +++ b/Xchat/XPI/Utils.pm @@ -7,6 +7,14 @@ use Xchat qw<:all>; our $VERSION = '0.02'; +sub irc_lc { + my ($bytes) = @_; + + $bytes =~ y/A-Z[\\]^/a-z{|}~/; + + return $bytes; +} + my @rcolors; BEGIN { if (nickcmp(get_info('version'), '2.4.0') < 0) { @@ -43,9 +51,10 @@ sub local_context { return unless @_ >= 2; my $code = pop; my $new_cxt = (@_ == 1) ? $_[0] : find_context(@_); + return undef unless defined $new_cxt; my $cur_cxt = get_context; + my $guard = bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard'; if (set_context $new_cxt) { - my $guard = bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard'; return $code->(); } else { return undef; @@ -83,6 +92,7 @@ use base qw; our @EXPORT = (); our %EXPORT_TAGS = ('funcs' => [ qw< + irc_lc dye_nick gui save_context local_context