OSDN Git Service

added support for xchat color sequence, closes bug #4154
authormorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Sun, 13 Jan 2008 10:14:55 +0000 (10:14 +0000)
committermorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Sun, 13 Jan 2008 10:14:55 +0000 (10:14 +0000)
keitairc
lib/Keitairc/IrcBuffer.pm

index cc2e94c..8fef18c 100755 (executable)
--- 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 <morimoto@mrmt.net>
@@ -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;
index 63fe232..2e884fd 100644 (file)
@@ -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 <morimoto@mrmt.net>
@@ -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('</font><font color="%s">', $ct{0+$1})|e;
+               }else{
+                       s|\x03(\d{1,2})|sprintf('<font color="%s">', $ct{0+$1})|e;
+                       $colored = 1;
+               }
+       }while(m|\x03\d{1,2}|);
+
+       # s|\x03|</font>|g if $colored;
+       $_ .= '</font>' if $colored;
+
+       $_;
+}
+
 1;