reassign 530588 irssi-scripts
retitle 530588 chanact.pl: implement chanact_filter_windowlist
thanks

also sprach Wouter Coekaerts <[email protected]> [2009.05.26.1104 +0200]:
> The act bar included in irssi itself is a basic act bar, fitting
> the essential needs, and intentionally kept simple. More
> powerful/configurable act bar is provided by scripts (chanact.pl,
> adv_windowlist.pl). It is even only recent that actlist_names
> (showing names instead of numbers) got added into irssi itself,
> because it is a very common need. The chanact script can do
> anything the act bar in irssi can (and more), so there is no loss
> from not being in irssi itself.

I use chanact.

> I do agree that an activity_show_targets could be useful for some;
> but it seems so uncommon that we do not believe something like
> that belongs in irssi core (and if it would, all the
> chanact-features would too). I recommend this is added to the
> chanact script instead.

Okay, this is not a bad idea at all, and after a bit of time with
the code, it seems pretty simple to do. I attached the two patches
needed and submitted the code upstream.

-- 
 .''`.   martin f. krafft <[email protected]>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
 
"a woman does not want the truth; what is truth to women? from the
 beginning, nothing has been more alien, repugnant, and hostile to
 woman than the truth - her great art is the lie, her highest
 concern is mere appearance and beauty."
                                              -- friedrich nietzsche
From 65dd097eed81f10a2d9beec746030d67b4586f55 Mon Sep 17 00:00:00 2001
From: martin f. krafft <[email protected]>
Date: Tue, 26 May 2009 11:41:55 +0200
Subject: [PATCH] skip filtered windows earlier

Signed-off-by: martin f. krafft <[email protected]>
---
 chanact.pl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/chanact.pl b/chanact.pl
index f9bb0e3..6edc152 100644
--- a/chanact.pl
+++ b/chanact.pl
@@ -234,6 +234,9 @@ sub remake() {
 
 		my $name = $win->get_active_name;
 
+		# skip windows that have only activity below the filter setting
+		next if (Irssi::settings_get_int('chanact_filter') > $win->{data_level});
+
 		# (status) is an awfull long name, so make it short to 'S'
 		# some people don't like it, so make it configurable
 		if (Irssi::settings_get_bool('chanact_chop_status')
@@ -262,8 +265,6 @@ sub remake() {
 			}
 		}
 
-		next if (Irssi::settings_get_int('chanact_filter') > $win->{data_level});
-
 		# in case we have a specific hilightcolor use it
 		if ($win->{hilight_color}) {
 			$hilight = "{sb_act_hilight_color $win->{hilight_color} ";
-- 
1.6.0.1

From cc46d08348744671720be08a8bb53433be998690 Mon Sep 17 00:00:00 2001
From: martin f. krafft <[email protected]>
Date: Tue, 26 May 2009 12:38:55 +0200
Subject: [PATCH] Add a way to use different chanact_filter for certain windows

I added a setting chanact_filter_windowlist, which is a space-separated
list of windows, for which to use (the new setting)
chanact_filter_windowlist_level instead of chanact_filter.

chanact_filter_windowlist defaults to ""
chanact_filter_windowlist_level defaults to (chanact_filter<4)?4:2

Signed-off-by: martin f. krafft <[email protected]>
---
 chanact.pl |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/chanact.pl b/chanact.pl
index 6edc152..7da1be0 100644
--- a/chanact.pl
+++ b/chanact.pl
@@ -4,7 +4,7 @@ use Irssi::TextUI;
 
 use vars qw($VERSION %IRSSI);
 
-$VERSION = "0.5.10";
+$VERSION = "0.5.11";
 %IRSSI = (
     authors     => 'BC-bd, Veli',
     contact     => '[email protected], [email protected]',
@@ -30,6 +30,7 @@ $VERSION = "0.5.10";
 # [email protected]  chanact_abbreviate_names
 # [email protected]      Extra chanact_show_mode and chanact_chop_status
 # [email protected] Better channel aliasing (case-sensitive, cross-network)
+#                     chanact_filter_windowlist
 # Jan 'jast' Krueger <[email protected]>, 2004-06-22
 # Ivo Timmermans <[email protected]>	win->{hilight} patch
 # 
@@ -160,6 +161,17 @@ $VERSION = "0.5.10";
 # 		* 3 : hide channels with text messages
 # 		* 4 : hide all channels (now why would you want to do that)
 #
+# /set chanact_filter_windowlist <string>
+#		* <string> : space-separated list of windows for which to use
+#				chanact_filter_windowlist_level instead of
+#				chanact_filter.
+#
+# /set chanact_filter_windowlist_level <int>
+#   like chanact_filter for windows in chanact_filter_windowlist. Defaults to
+#   chanact_filter<4 ? 4 : 2, making chanact_filter_windowlist a list of
+#   windows never to show if chanact_filter<4, and a list of windows to show
+#   when there is reasonable activity if all channels would be hidden.
+#
 #########
 # HINTS
 #########
@@ -214,6 +226,7 @@ sub remake() {
 	my $abbrev = Irssi::settings_get_int('chanact_abbreviate_names');
 	my $remove_prefix = Irssi::settings_get_str('chanact_remove_prefix');
 	my $remove_hash = Irssi::settings_get_bool('chanact_remove_hash');
+	my $windowlist = Irssi::settings_get_str('chanact_filter_windowlist');
 
  	if (Irssi::settings_get_bool('chanact_sort_by_activity')) {
 		@windows = sort { ($b->{last_line} <=> $a->{last_line}) }
@@ -234,8 +247,16 @@ sub remake() {
 
 		my $name = $win->get_active_name;
 
-		# skip windows that have only activity below the filter setting
-		next if (Irssi::settings_get_int('chanact_filter') > $win->{data_level});
+		my $filter_level = Irssi::settings_get_int('chanact_filter');
+		if (grep { $_ eq $name } split ' ', $windowlist) {
+			# window matches $windowlist, so use
+			# chanact_filter_windowlist_level to override
+			# chanact_filter
+			$filter_level = Irssi::settings_get_int('chanact_filter_windowlist_level');
+		}
+		# skip windows with data of level lower than the applicable
+		# filter setting
+		next if ($win->{data_level} < $filter_level);
 
 		# (status) is an awfull long name, so make it short to 'S'
 		# some people don't like it, so make it configurable
@@ -439,6 +460,9 @@ Irssi::settings_add_str('chanact', 'chanact_header', "Act: ");
 Irssi::settings_add_bool('chanact', 'chanact_chop_status', 1);
 Irssi::settings_add_bool('chanact', 'chanact_sort_by_activity', 1);
 Irssi::settings_add_int('chanact', 'chanact_filter', 0);
+Irssi::settings_add_str('chanact', 'chanact_filter_windowlist', "");
+Irssi::settings_add_int('chanact', 'chanact_filter_windowlist_level',
+	Irssi::settings_get_int('chanact_filter') < 4 ? 4 : 2);
 
 # register the statusbar item
 Irssi::statusbar_item_register('chanact', '$0', 'chanact');
@@ -464,7 +488,12 @@ Irssi::signal_add_last('window refnum changed', 'refnum_changed');
 ###
 #
 # Changelog
-# 
+#
+# 0.5.11
+#	- added chanact_filter_windowlist, which is a space-separated list of
+#	  windows for which to use chanact_filter_windowlist_level instead of
+#	  chanact_filter ([email protected]).
+#
 # 0.5.10
 # 	- fixed irssi crash when using Irssi::print from within remake()
 #       - added option to filter out some data levels, based on a patch by
-- 
1.6.0.1

Attachment: digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)

Reply via email to