From 35bc0c636e83aa9915f070cbc515e2c998e7b634 Mon Sep 17 00:00:00 2001 From: nwf Date: Sun, 2 Aug 2009 03:19:24 -0400 Subject: [PATCH] Improve instance punt,unpunt code Ignore-this: d265788540f1e08500ad459f04905057 darcs-hash:20090802071924-4d648-f033f3c5b9dc8a802abe5296de88be2eb680997d.gz --- IrssiInstancer.pl | 46 ++++++++++++++++++++++++++++++++++++++++++---- README | 17 ++++++++++++++--- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/IrssiInstancer.pl b/IrssiInstancer.pl index 0faaed0..ddec1ef 100644 --- a/IrssiInstancer.pl +++ b/IrssiInstancer.pl @@ -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 32e3851..5a54d7e 100644 --- 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. -- 2.50.1