X-Git-Url: https://git.madduck.net/code/irssi/scripts-bc-bd.git/blobdiff_plain/82252cc29ce711c0368f2bfc0646b4de04597448..70a7396bbef47c0c356c02c50c77ae216ff6c421:/chanact.pl diff --git a/chanact.pl b/chanact.pl index 1444248..e98348e 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 => '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) +# chanact_filter_windowlist # Jan 'jast' Krueger , 2004-06-22 # Ivo Timmermans win->{hilight} patch # @@ -160,6 +161,22 @@ $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 +# * : space-separated list of windows for which to use +# chanact_filter_windowlist_level instead of +# chanact_filter. +# Alternatively, an entry can be postfixed with +# a colon (':') and the level to use for that +# window. +# The special string @QUERIES matches all queries. +# +# /set chanact_filter_windowlist_level +# like chanact_filter for windows in chanact_filter_windowlist, which do not +# have a specific value. 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 ######### @@ -207,6 +224,18 @@ sub chanact { $item->default_handler($get_size_only, $actString, undef, 1); } +sub get_filterlevel { + my $windows = shift; + my $kwregexp = '(?:' . join('|', map quotemeta, @_) . ')'; + my $defaultlevel = Irssi::settings_get_int('chanact_filter_windowlist_level'); + foreach my $win (@$windows) { + return ($1 ? $1 : $defaultlevel) if $win =~ /^$kwregexp(?:\:(\d+))?$/; + } + return undef; +} + +use Data::Dumper; + # this is the real creation method sub remake() { my ($afternumber,$finish,$hilight,$mode,$number,$display,@windows); @@ -214,6 +243,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 = split ' ', Irssi::settings_get_str('chanact_filter_windowlist'); if (Irssi::settings_get_bool('chanact_sort_by_activity')) { @windows = sort { ($b->{last_line} <=> $a->{last_line}) } @@ -233,9 +263,27 @@ sub remake() { !ref($active) && next; 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 $type = $active->{type}; + + ## determine the filter_level to use to determine whether the + ## activity on the current window is worth the bother + # + my @matchlist; push @matchlist, $name; + # if this is a query, also try to match @QUERIES + push @matchlist, '@QUERIES' if ($type eq 'QUERY'); + # get_filterlevel matches all items in @matchlist against the + # @windowlist and returns the applicable filterlevel + my $filter_level = get_filterlevel(\@windowlist, @matchlist); + # if we don't have a match (undef), then use the + # chanact_filter value + $filter_level = Irssi::settings_get_int('chanact_filter') unless $filter_level; + + # now, skip windows with data of level lower than the + # filter level + next if ($win->{data_level} < $filter_level); + + # alright, the activity is important, let's show the window + my $level = $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 @@ -246,7 +294,7 @@ sub remake() { # 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; @@ -439,6 +487,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 +515,14 @@ 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. Each window can also have a specific level +# specified. 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