]> git.madduck.net Git - code/irssi/scripts-bc-bd.git/blobdiff - chanact.pl

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

simplify level assignment
[code/irssi/scripts-bc-bd.git] / chanact.pl
index 1444248c514117e2d966bef40bc607bbc192f345..44b071af02d874d7e0732a7b90a90b3f05b1ba9a 100644 (file)
@@ -4,7 +4,7 @@ use Irssi::TextUI;
 
 use vars qw($VERSION %IRSSI);
 
 
 use vars qw($VERSION %IRSSI);
 
-$VERSION = "0.5.10";
+$VERSION = "0.5.11";
 %IRSSI = (
     authors     => 'BC-bd, Veli',
     contact     => 'bd@bc-bd.org, veli@piipiip.net',
 %IRSSI = (
     authors     => 'BC-bd, Veli',
     contact     => 'bd@bc-bd.org, veli@piipiip.net',
@@ -30,6 +30,7 @@ $VERSION = "0.5.10";
 # qrczak@knm.org.pl  chanact_abbreviate_names
 # qerub@home.se      Extra chanact_show_mode and chanact_chop_status
 # madduck@madduck.net Better channel aliasing (case-sensitive, cross-network)
 # qrczak@knm.org.pl  chanact_abbreviate_names
 # qerub@home.se      Extra chanact_show_mode and chanact_chop_status
 # madduck@madduck.net Better channel aliasing (case-sensitive, cross-network)
+#                     chanact_filter_windowlist
 # Jan 'jast' Krueger <jast@heapsort.de>, 2004-06-22
 # Ivo Timmermans <ivo@o2w.nl>  win->{hilight} patch
 # 
 # Jan 'jast' Krueger <jast@heapsort.de>, 2004-06-22
 # Ivo Timmermans <ivo@o2w.nl>  win->{hilight} patch
 # 
@@ -160,6 +161,18 @@ $VERSION = "0.5.10";
 #              * 3 : hide channels with text messages
 #              * 4 : hide all channels (now why would you want to do that)
 #
 #              * 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.
+#                              The special string @QUERIES matches all queries.
+#
+# /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
 #########
 #########
 # HINTS
 #########
@@ -214,6 +227,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 $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}) }
 
        if (Irssi::settings_get_bool('chanact_sort_by_activity')) {
                @windows = sort { ($b->{last_line} <=> $a->{last_line}) }
@@ -233,9 +247,25 @@ sub remake() {
                !ref($active) && next;
 
                my $name = $win->get_active_name;
                !ref($active) && next;
 
                my $name = $win->get_active_name;
+               my $type = $active->{type};
+
+               # determine whether we have a match with the windowlist
+               my @windowlist = split ' ', $windowlist;
+               my $match_windowlist = grep { $_ eq $name } @windowlist;
+               if ($type eq 'QUERY') {
+                       # if this is a query, also try to match @QUERIES
+                       $match_windowlist ||= grep { $_ eq '@QUERIES' } @windowlist;
+               }
+
+               # choose filter_level according to whether the window is in
+               # the windowlist
+               my $filter_level = $match_windowlist
+                       ? Irssi::settings_get_int('chanact_filter_windowlist_level')
+                       : Irssi::settings_get_int('chanact_filter');
 
 
-               # skip windows that have only activity below the filter setting
-               next if (Irssi::settings_get_int('chanact_filter') > $win->{data_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
 
                # (status) is an awfull long name, so make it short to 'S'
                # some people don't like it, so make it configurable
@@ -246,7 +276,7 @@ sub remake() {
        
                # check if we should show the mode
                $mode = "";
        
                # check if we should show the mode
                $mode = "";
-               if ($active->{type} eq "CHANNEL") {
+               if ($type eq "CHANNEL") {
                        my $server = $win->{active_server};
                        !ref($server) && next;
 
                        my $server = $win->{active_server};
                        !ref($server) && next;
 
@@ -439,6 +469,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_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');
 
 # register the statusbar item
 Irssi::statusbar_item_register('chanact', '$0', 'chanact');
@@ -464,7 +497,13 @@ Irssi::signal_add_last('window refnum changed', 'refnum_changed');
 ###
 #
 # Changelog
 ###
 #
 # 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. You can use @QUERIES to match all queries
+#        (madduck@madduck.net).
+#
 # 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
 # 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