From: morimoto Date: Sun, 13 Jan 2008 10:14:55 +0000 (+0000) Subject: added support for xchat color sequence, closes bug #4154 X-Git-Tag: tag20080719~80 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3ab4d3d3b9f5216d440b13bc13d19e4a3a1d1b5a;p=keitairc%2Fkeitairc.git added support for xchat color sequence, closes bug #4154 --- diff --git a/keitairc b/keitairc index cc2e94c..8fef18c 100755 --- a/keitairc +++ b/keitairc @@ -1,6 +1,6 @@ #!/usr/bin/perl # keitairc -# $Id: keitairc,v 1.37 2008-01-13 09:30:39 morimoto Exp $ +# $Id: keitairc,v 1.38 2008-01-13 10:14:55 morimoto Exp $ # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/keitairc,v $ # # Copyright (c) 2003-2008 Jun Morimoto @@ -326,6 +326,7 @@ sub render_line{ next unless length; $_ = $ib->simple_escape($_); + $_ = $ib->colorize($_); for my $name ($pl->list_replace_plugins()){ last if s/$pl->{plugins}->{$name}->{message_replace_regexp}/$pl->{plugins}->{$name}->{message_replace_imprementation}($session_id, $1, $2, $3, $4, $5, $6, $7, $8, $9)/eg; diff --git a/lib/Keitairc/IrcBuffer.pm b/lib/Keitairc/IrcBuffer.pm index 63fe232..2e884fd 100644 --- a/lib/Keitairc/IrcBuffer.pm +++ b/lib/Keitairc/IrcBuffer.pm @@ -1,6 +1,6 @@ # -*-perl-*- # Keitairc::IrcBuffer -# $Id: IrcBuffer.pm,v 1.4 2008-01-13 09:30:39 morimoto Exp $ +# $Id: IrcBuffer.pm,v 1.5 2008-01-13 10:14:55 morimoto Exp $ # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/IrcBuffer.pm,v $ # # Copyright (c) 2008 Jun Morimoto @@ -275,4 +275,43 @@ sub simple_escape{ $_; } +################################################################ +sub colorize{ + my $me = shift; + local($_) = shift; + + my %ct = ( + 1 => 'Black', + 2 => '#000080', # Navy Blue + 3 => 'Green', + 4 => 'Red', + 5 => 'Maroon', + 6 => 'Purple', + 7 => 'Olive', + 8 => 'Yellow', + 9 => '#32cd32', # Lime Green + 10 => 'Teal', + 11 => 'Aqua', + 12 => '#4169e1', # Royal Blue + 13 => '#ff69b4', # Hot Pink + 14 => '#a9a9a9', # Dark Gray + 15 => '#d3d3d3', # Light Gray + 16 => 'White'); + my $colored = 0; + + do{ + if($colored){ + s|\x03(\d{1,2})|sprintf('', $ct{0+$1})|e; + }else{ + s|\x03(\d{1,2})|sprintf('', $ct{0+$1})|e; + $colored = 1; + } + }while(m|\x03\d{1,2}|); + + # s|\x03||g if $colored; + $_ .= '' if $colored; + + $_; +} + 1;