Commit 3c1a0ca2 authored by Nei's avatar Nei Committed by Sébastien Helleu

chatters.pl 0.4: add focus info

parent 24ad7813
......@@ -39,12 +39,14 @@
# Version 0.3: missing return value for callbacks fixed
# version check added
# improved option handling
# 2013-02-07, Ailin Nemui <anti.teamidiot.de>
# Version 0.4: add focus info
#
use strict;
use warnings;
my $version = "0.3";
my $version = "0.4";
my $script_name = "chatters";
my $weechat_version = "";
......@@ -88,8 +90,12 @@ weechat::hook_timer(60000, 0, 0, "cleanup_chatters", 0);
# On config change
weechat::hook_config("plugins.var.perl.${script_name}.*", "config_change_cb", "");
weechat::bar_item_new($chatters_bar_item_name, "chatters_bar_cb", "");
# For mouse support
weechat::hook_focus($chatters_bar_item_name, "chatters_focus_cb", "") if $weechat_version >= 0x00030600;
###############################################################################
# Buffer update callback
sub chatters_bar_cb
......@@ -131,7 +137,7 @@ sub buffer_close_cb
{
delete $chatter_groups{$channel};
}
return weechat::WEECHAT_RC_OK;
return weechat::WEECHAT_RC_OK;
}
###############################################################################
......@@ -202,7 +208,22 @@ sub config_change_cb
{
cleanup_chatters();
}
return weechat::WEECHAT_RC_OK;
return weechat::WEECHAT_RC_OK;
}
###############################################################################
# Adds nick info to focus hashtable
sub chatters_focus_cb
{
my $channel = buf_to_channel_key($_[1]{_buffer});
if ($channel and $chatter_groups{$channel} and
$_[1]{_bar_item_line} > 0 and $_[1]{_bar_item_line} <= keys %{ $chatter_groups{$channel} })
{
+{ nick => (sort {uc($a) cmp uc($b)} keys %{ $chatter_groups{$channel} })[$_[1]{_bar_item_line}-1] }
}
else {
$_[1]
}
}
###############################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment