]> hydra-www.ietfng.org Git - instirc/commitdiff
Improve instance punt,unpunt code
authornwf <nwf@cs.jhu.edu>
Sun, 2 Aug 2009 07:19:24 +0000 (03:19 -0400)
committernwf <nwf@cs.jhu.edu>
Sun, 2 Aug 2009 07:19:24 +0000 (03:19 -0400)
Ignore-this: d265788540f1e08500ad459f04905057

darcs-hash:20090802071924-4d648-f033f3c5b9dc8a802abe5296de88be2eb680997d.gz

IrssiInstancer.pl
README

index 0faaed0f617d72141c51d4905e9bff14b0d02f8a..ddec1ef89560557e59385d89edf4a4704d481e82 100644 (file)
@@ -439,12 +439,30 @@ sub cmd_punt {
   my ($inst, $server, $witem) = @_;
   return if not cmd_common_startup($server,$witem);
   punt_inst($witem,$inst);
+  $witem->print("Punted instance $inst");
 }
 
 sub cmd_unpunt {
   my ($inst, $server, $witem) = @_;
   return if not cmd_common_startup($server,$witem);
-  unroute_inst($witem,$inst);
+
+  if ($inst eq "") {
+    # Special handling to unpunt all punted instances on $witem.
+    # We don't unroute instances here.
+
+    # If there's nothing here, do nothing.
+    return if not exists $$routes{$$witem{'_irssi'}};
+
+    foreach $inst (keys %{$$routes{$$witem{'_irssi'}}}) {
+      if (not defined $$routes{$$witem{'_irssi'}}{$inst}) {
+        unroute_inst($witem,$inst)
+      }
+    }
+    $witem->print("Unpunted all punted instances...");
+  } else {
+    unroute_inst($witem,$inst);
+    $witem->print("Unpunted instance $inst");
+  }
 } 
 
 sub cmd_inst_say {
@@ -487,6 +505,23 @@ sub cmd_debug_routes {
   Irssi::print (Dumper($routes_invmap));
 }
 
+sub cmd_inst_list {
+  my ($args, $server, $witem) = @_;
+
+  if (not exists $$routes{$$witem{'_irssi'}}) {
+    $witem->print("No instances are specially handled here.");
+    return;
+  }
+
+  foreach my $inst (keys %{$$routes{$$witem{'_irssi'}}}) {
+    if (defined $$routes{$$witem{'_irssi'}}{$inst}) {
+        $witem->print("$inst is routed."); # XXX Be more descriptive?
+    } else {
+        $witem->print("$inst is punted.");
+    }
+  }
+}
+
 #################################################################
 
 Irssi::settings_set_str("ctcp_version_reply",
@@ -501,9 +536,12 @@ Irssi::signal_add_first('message own_private', 'inst_filter_in_own_private');
 Irssi::signal_add_first('send text', 'inst_filter_out');
 Irssi::command_bind('instance', 'cmd_instance');
 Irssi::command_bind('instsay', 'cmd_inst_say');
-Irssi::command_bind('punt', 'cmd_punt');
-Irssi::command_bind('debugroutes', 'cmd_debug_routes');
-Irssi::command_bind('unpunt', 'cmd_unpunt');
+Irssi::command_bind('instpunt', 'cmd_punt');
+Irssi::command_bind('instunpunt', 'cmd_unpunt');
+#Irssi::command_bind('instsplit', 'cmd_isplit');
+
+Irssi::command_bind('instlist', 'cmd_inst_list');
+Irssi::command_bind('instdbgr', 'cmd_debug_routes');
 
     # Set to recieve warnings about initial TLV streams
     # (older protocol)
diff --git a/README b/README
index 32e385116326022b634249e29d48f0541c9abf3e..5a54d7ea409002d90a68af3ee80b1c39a95f902f 100644 (file)
--- a/README
+++ b/README
@@ -18,13 +18,24 @@ The UI is currently rather spartan, defining the following commands:
     /instsay label message sends the message with the given instance label
                            but does not set or alter the default.
 
-    /punt   label     Causes the current window to not display messages
-                      tagged with instance "label".
+    /instpunt    label     Causes the current window to not display messages
+                           tagged with instance "label".
 
-    /unpunt label     Undoes the action of the punt command.
+    /instunpunt label      Undoes the action of the punt command.
+
+    /instlist              Lists punted (and routed) instances in the current
+                           window.
 
     /say    message   [Not defined by this script]
                       will send the message to the current window without
                       an instance label, even if a default is set.
 
+We suggest that you alias commands to more convenient forms:
+
+/alias i instance
+/alias il instlist
+/alias ip instpunt
+/alias is instsay
+/alias iu instunpunt
+
 See TODO for things if you want to help out.