Author: nornagon
Date: 2004-12-29 23:52:22 -0500 (Wed, 29 Dec 2004)
New Revision: 471

Modified:
   trunk/clients/termvisual/termvisual.pl
Log:
Small updates to Term::Visual

Modified: trunk/clients/termvisual/termvisual.pl
===================================================================
--- trunk/clients/termvisual/termvisual.pl      2004-12-30 04:51:20 UTC (rev 
470)
+++ trunk/clients/termvisual/termvisual.pl      2004-12-30 04:52:22 UTC (rev 
471)
@@ -20,6 +20,12 @@
 
 my ($config, %ucommands, %scommands);
 
+my %palette = (
+    channel => 'bright blue on black',
+    nick    => 'white on black',
+    ncolor  => 'bright white on black',
+);
+
 POE::Session->create(
     inline_states => {
         _start      => \&handle_start,
@@ -54,6 +60,8 @@
 
     $heap->{vt} = Term::Visual->new( Alias => "user_interface" );
 
+    $heap->{vt}->set_palette(%palette);
+
     $heap->{window_id} = $heap->{vt}->create_window(
         Window_Name     => "foo",
         Status          => { 0 => { format => "Server: %s",
@@ -130,8 +138,7 @@
 sub handle_socket_error {
     my ($heap, $syscall, $errno, $error) = @_[HEAP, ARG0 .. ARG2];
     $error = "Normal disconnection" unless $errno;
-    $heap->{vt}->print($heap->{window_id}, "Encountered $syscall ".
-        "error $errno: $error");
+    vt_print($heap->{window_id}, "Encountered $syscall error $errno: $error");
 }
 
 sub handle_socket_input {
@@ -223,15 +230,23 @@
 
 sub server_msg {
     my ($cid, $user, $type, $msg) = @_;
+    $msg = '' if (!defined $msg);
     if ($type eq '"') { # Message
-        vt_print("$cid:<$user> $msg");
+        vt_print("\0(channel)$cid\0(ncolor):".
+                 "\0(nickdecs)<\0(nick)$user\0(nickdecs)> ".
+                 "\0(ncolor)$msg");
     } elsif ($type eq ':') { # Action
-        vt_print("$cid:* $user $msg");
+        vt_print("\0(channel)$cid\0(ncolor):* \0(nick)$user\0(ncolor) $msg");
+    } elsif ($type eq 'PING?') {
+
+    } else {
+        vt_print("Received odd message type '$type'");
     }
 }
 
 sub server_pmsg {
     my ($user, $msg) = @_;
+    $msg = '' if (!defined $msg);
     vt_print("<$user> $msg");
 }
 
@@ -248,6 +263,8 @@
     names   => \&command_names,
     me      => \&command_me,
     say     => \&command_say,
+    msg     => \&command_msg,
+    palette => \&command_palette,
 );
 
 sub command_quit {
@@ -323,6 +340,22 @@
     chan_msg('lobby', $msg);
 }
 
+sub command_msg {
+    my ($heap, $user, $msg) = (get_heap(), shift, join(" ", @_));
+    if (!defined $user) {
+        vt_print("Syntax: /msg <user> [msg]");
+        return;
+    }
+    $msg = '' if (!defined $msg);
+    $heap->{socket}->put(['PMSG', $user, $msg]);
+}
+
+sub command_palette {
+    my ($heap, $name, $color) = (get_heap(), shift, join(" ", @_));
+    $palette{$name} = $color;
+    $heap->{vt}->set_palette(%palette);
+}
+
 # Misc functions
 
 sub vt_print {


Reply via email to