aboutsummaryrefslogtreecommitdiffstats
path: root/weechat/perl
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-02-18 16:56:41 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2014-02-18 16:56:41 +0100
commit9c9e27b7bfc9c00acc02b91fdb8cb29c60fe546e (patch)
tree6e0486088938bbb8a88efe5c2639b807b0ddd23a /weechat/perl
parent7e7aa928072775240ff70ca61f2dd0e8a09242d8 (diff)
downloaddotfiles-9c9e27b7bfc9c00acc02b91fdb8cb29c60fe546e.tar.xz
Diffstat (limited to 'weechat/perl')
-rw-r--r--weechat/perl/buffers.pl349
-rw-r--r--weechat/perl/highmon.pl32
-rw-r--r--weechat/perl/iset.pl108
-rw-r--r--weechat/perl/yaurls.pl301
4 files changed, 363 insertions, 427 deletions
diff --git a/weechat/perl/buffers.pl b/weechat/perl/buffers.pl
index e315f80..d4d17c2 100644
--- a/weechat/perl/buffers.pl
+++ b/weechat/perl/buffers.pl
@@ -1,6 +1,6 @@
#
-# Copyright (C) 2008-2012 Sebastien Helleu <flashcode@flashtux.org>
-# Copyright (C) 2011-2012 Nils G <weechatter@arcor.de>
+# Copyright (C) 2008-2014 Sebastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2011-2013 Nils G <weechatter@arcor.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,6 +20,24 @@
#
# History:
#
+# 2014-01-01, Sebastien Helleu <flashcode@flashtux.org>:
+# v4.5: add option "mouse_move_buffer"
+# 2013-12-11, Sebastien Helleu <flashcode@flashtux.org>:
+# v4.4: fix buffer number on drag to the end of list when option
+# weechat.look.buffer_auto_renumber is off
+# 2013-12-10, nils_2@freenode.#weechat:
+# v4.3: add options "prefix_bufname" and "suffix_bufname (idea by silverd)
+# : fix hook_timer() for show_lag wasn't disabled
+# : improved signal handling (less updating of buffers list)
+# 2013-11-07, Sebastien Helleu <flashcode@flashtux.org>:
+# v4.2: use default filling "columns_vertical" when bar position is top/bottom
+# 2013-10-31, nils_2@freenode.#weechat:
+# v4.1: add option "detach_buffer_immediately" (idea by farn)
+# 2013-10-20, nils_2@freenode.#weechat:
+# v4.0: add options "detach_displayed_buffers", "detach_display_window_number"
+# 2013-09-27, nils_2@freenode.#weechat:
+# v3.9: add option "toggle_bar" and option "show_prefix_query" (idea by IvarB)
+# : fix problem with linefeed at end of list of buffers (reported by grawity)
# 2012-10-18, nils_2@freenode.#weechat:
# v3.8: add option "mark_inactive", to mark buffers you are not in (idea by xrdodrx)
# : add wildcard "*" for immune_detach_buffers (idea by StarWeaver)
@@ -134,7 +152,8 @@
use strict;
use Encode qw( decode encode );
# -------------------------------[ internal ]-------------------------------------
-my $version = "3.8";
+my $SCRIPT_NAME = "buffers";
+my $SCRIPT_VERSION = "4.5";
my $BUFFERS_CONFIG_FILE_NAME = "buffers";
my $buffers_config_file;
@@ -147,31 +166,46 @@ my %options;
my %hotlist_level = (0 => "low", 1 => "message", 2 => "private", 3 => "highlight");
my @whitelist_buffers = ();
my @immune_detach_buffers= ();
+my @detach_buffer_immediately= ();
my @buffers_focus = ();
my %buffers_timer = ();
my %Hooks = ();
# --------------------------------[ init ]--------------------------------------
-weechat::register("buffers", "Sebastien Helleu <flashcode\@flashtux.org>", $version,
- "GPL3", "Sidebar with list of buffers", "", "");
+weechat::register($SCRIPT_NAME, "Sebastien Helleu <flashcode\@flashtux.org>", $SCRIPT_VERSION,
+ "GPL3", "Sidebar with list of buffers", "shutdown_cb", "");
my $weechat_version = weechat::info_get("version_number", "") || 0;
buffers_config_init();
buffers_config_read();
-weechat::bar_item_new("buffers", "build_buffers", "");
-weechat::bar_new("buffers", "0", "0", "root", "", "left", "horizontal",
+weechat::bar_item_new($SCRIPT_NAME, "build_buffers", "");
+weechat::bar_new($SCRIPT_NAME, "0", "0", "root", "", "left", "columns_vertical",
"vertical", "0", "0", "default", "default", "default", "1",
- "buffers");
-weechat::hook_signal("buffer_*", "buffers_signal_buffer", "");
-weechat::hook_signal("window_switch", "buffers_signal_buffer", "");
-weechat::hook_signal("hotlist_*", "buffers_signal_hotlist", "");
+ $SCRIPT_NAME);
+
+if ( check_bar_item() == 0 )
+{
+ weechat::command("","/bar show " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 );
+}
+
+weechat::hook_signal("buffer_opened", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_closed", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_merged", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_unmerged", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_moved", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_renamed", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_switch", "buffers_signal_buffer", "");
+
weechat::hook_signal("window_switch", "buffers_signal_buffer", "");
+weechat::hook_signal("hotlist_changed", "buffers_signal_hotlist", "");
#weechat::hook_command_run("/input switch_active_*", "buffers_signal_buffer", "");
-weechat::bar_item_update("buffers");
+weechat::bar_item_update($SCRIPT_NAME);
+
+
if ($weechat_version >= 0x00030600)
{
- weechat::hook_focus("buffers", "buffers_focus_buffers", "");
+ weechat::hook_focus($SCRIPT_NAME, "buffers_focus_buffers", "");
weechat::hook_hsignal("buffers_mouse", "buffers_hsignal_mouse", "");
weechat::key_bind("mouse", \%mouse_keys);
}
@@ -206,10 +240,13 @@ weechat::hook_command( $cmd_buffers_detach,
if ($weechat_version >= 0x00030800)
{
weechat::hook_config("buffers.look.detach", "hook_timer_detach", "");
+ $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_hotlist", "") if ( weechat::config_integer( $options{"detach"}) > 0 );
}
weechat::hook_config("buffers.look.show_lag", "hook_timer_lag", "");
+ $Hooks{timer_lag} = weechat::hook_timer( weechat::config_integer(weechat::config_get("irc.network.lag_refresh_interval")) * 1000, 0, 0, "buffers_signal_hotlist", "") if ( weechat::config_boolean($options{"show_lag"}) );
+
# -------------------------------- [ command ] --------------------------------
sub buffers_cmd_whitelist
{
@@ -251,10 +288,11 @@ my ( $data, $buffer, $args ) = @_;
}
sub buffers_cmd_detach
{
-my ( $data, $buffer, $args ) = @_;
+ my ( $data, $buffer, $args ) = @_;
$args = lc($args);
my $immune_detach_buffers = weechat::config_string( weechat::config_get("buffers.look.immune_detach_buffers") );
return weechat::WEECHAT_RC_OK if ( $immune_detach_buffers eq "" and $args eq "del" or $immune_detach_buffers eq "" and $args eq "reset" );
+
my @buffers_list = split( /,/, $immune_detach_buffers );
# get buffers name
my $infolist = weechat::infolist_get("buffer", weechat::current_buffer(), "");
@@ -287,6 +325,7 @@ my ( $data, $buffer, $args ) = @_;
}
return weechat::WEECHAT_RC_OK;
}
+
sub create_whitelist
{
my @buffers_list = @{$_[0]};
@@ -311,16 +350,16 @@ sub hook_timer_detach
else
{
weechat::unhook($Hooks{timer_detach}) if $Hooks{timer_detach};
- $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_buffer", "");
+ $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_hotlist", "");
}
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
sub hook_timer_lag
{
my $lag = $_[2];
- if ( $lag eq 0 )
+ if ( $lag eq "off" )
{
weechat::unhook($Hooks{timer_lag}) if $Hooks{timer_lag};
$Hooks{timer_lag} = "";
@@ -330,7 +369,7 @@ sub hook_timer_lag
weechat::unhook($Hooks{timer_lag}) if $Hooks{timer_lag};
$Hooks{timer_lag} = weechat::hook_timer( weechat::config_integer(weechat::config_get("irc.network.lag_refresh_interval")) * 1000, 0, 0, "buffers_signal_hotlist", "");
}
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
@@ -353,64 +392,74 @@ sub buffers_config_init
return if ($buffers_config_file eq "");
my %default_options_color =
-("color_current_fg" => ["current_fg", "color", "foreground color for current buffer", "", 0, 0,"lightcyan", "lightcyan", 0, "", "","buffers_signal_config", "", "", ""],
- "color_current_bg" => ["current_bg", "color", "background color for current buffer", "", 0, 0,"red", "red", 0, "", "","buffers_signal_config", "", "", ""],
- "color_default_fg" => ["default_fg", "color", "default foreground color for buffer name", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_default_bg" => ["default_bg", "color", "default background color for buffer name", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_highlight_fg" => ["hotlist_highlight_fg", "color", "change foreground color of buffer name if a highlight messaged received","", 0, 0,"magenta", "magenta", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_highlight_bg" => ["hotlist_highlight_bg", "color", "change background color of buffer name if a highlight messaged received", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_low_fg" => ["hotlist_low_fg", "color", "change foreground color of buffer name if a low message received", "", 0, 0,"white", "white", 0, "", "","buffers_signal_config", "", "", ""],
+("color_current_fg" => ["current_fg", "color", "foreground color for current buffer", "", 0, 0, "lightcyan", "lightcyan", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_current_bg" => ["current_bg", "color", "background color for current buffer", "", 0, 0, "red", "red", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_default_fg" => ["default_fg", "color", "default foreground color for buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_default_bg" => ["default_bg", "color", "default background color for buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_highlight_fg" => ["hotlist_highlight_fg", "color", "change foreground color of buffer name if a highlight messaged received", "", 0, 0, "magenta", "magenta", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_highlight_bg" => ["hotlist_highlight_bg", "color", "change background color of buffer name if a highlight messaged received", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_low_fg" => ["hotlist_low_fg", "color", "change foreground color of buffer name if a low message received", "", 0, 0, "white", "white", 0, "", "", "buffers_signal_config", "", "", ""],
"color_hotlist_low_bg" => ["hotlist_low_bg", "color", "change background color of buffer name if a low message received", "", 0, 0,
- "default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_message_fg" => ["hotlist_message_fg", "color", "change foreground color of buffer name if a normal message received", "", 0, 0,"yellow", "yellow", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_message_bg" => ["hotlist_message_bg", "color", "change background color of buffer name if a normal message received", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_private_fg" => ["hotlist_private_fg", "color", "change foreground color of buffer name if a private message received", "", 0, 0,"lightgreen", "lightgreen", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_private_bg" => ["hotlist_private_bg", "color", "change background color of buffer name if a private message received", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_number" => ["number", "color", "color for buffer number", "", 0, 0,"lightgreen", "lightgreen", 0, "", "","buffers_signal_config", "", "", ""],
- "color_number_char" => ["number_char", "color", "color for buffer number char", "", 0, 0,"lightgreen", "lightgreen", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_default_fg" => ["whitelist_default_fg", "color", "default foreground color for whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_default_bg" => ["whitelist_default_bg", "color", "default background color for whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_low_fg" => ["whitelist_low_fg", "color", "low color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_low_bg" => ["whitelist_low_bg", "color", "low color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_message_fg" => ["whitelist_message_fg", "color", "message color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_message_bg" => ["whitelist_message_bg", "color", "message color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_private_fg" => ["whitelist_private_fg", "color", "private color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_private_bg" => ["whitelist_private_bg", "color", "private color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_highlight_fg" => ["whitelist_highlight_fg", "color", "highlight color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_highlight_bg" => ["whitelist_highlight_bg", "color", "highlight color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_none_channel_fg" => ["none_channel_fg", "color", "foreground color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_none_channel_bg" => ["none_channel_bg", "color", "background color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_default_fg" => ["queries_default_fg", "color", "foreground color for query buffer without message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_default_bg" => ["queries_default_bg", "color", "background color for query buffer without message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_message_fg" => ["queries_message_fg", "color", "foreground color for query buffer with unread message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_message_bg" => ["queries_message_bg", "color", "background color for query buffer with unread message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_highlight_fg" => ["queries_highlight_fg", "color", "foreground color for query buffer with unread highlight", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_highlight_bg" => ["queries_highlight_bg", "color", "background color for query buffer with unread highlight", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
+ "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_message_fg" => ["hotlist_message_fg", "color", "change foreground color of buffer name if a normal message received", "", 0, 0, "yellow", "yellow", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_message_bg" => ["hotlist_message_bg", "color", "change background color of buffer name if a normal message received", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_private_fg" => ["hotlist_private_fg", "color", "change foreground color of buffer name if a private message received", "", 0, 0, "lightgreen", "lightgreen", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_private_bg" => ["hotlist_private_bg", "color", "change background color of buffer name if a private message received", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_number" => ["number", "color", "color for buffer number", "", 0, 0, "lightgreen", "lightgreen", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_number_char" => ["number_char", "color", "color for buffer number char", "", 0, 0, "lightgreen", "lightgreen", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_default_fg" => ["whitelist_default_fg", "color", "default foreground color for whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_default_bg" => ["whitelist_default_bg", "color", "default background color for whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_low_fg" => ["whitelist_low_fg", "color", "low color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_low_bg" => ["whitelist_low_bg", "color", "low color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_message_fg" => ["whitelist_message_fg", "color", "message color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_message_bg" => ["whitelist_message_bg", "color", "message color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_private_fg" => ["whitelist_private_fg", "color", "private color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_private_bg" => ["whitelist_private_bg", "color", "private color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_highlight_fg" => ["whitelist_highlight_fg", "color", "highlight color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_highlight_bg" => ["whitelist_highlight_bg", "color", "highlight color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_none_channel_fg" => ["none_channel_fg", "color", "foreground color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_none_channel_bg" => ["none_channel_bg", "color", "background color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_default_fg" => ["queries_default_fg", "color", "foreground color for query buffer without message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_default_bg" => ["queries_default_bg", "color", "background color for query buffer without message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_message_fg" => ["queries_message_fg", "color", "foreground color for query buffer with unread message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_message_bg" => ["queries_message_bg", "color", "background color for query buffer with unread message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_highlight_fg" => ["queries_highlight_fg", "color", "foreground color for query buffer with unread highlight", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_highlight_bg" => ["queries_highlight_bg", "color", "background color for query buffer with unread highlight", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_prefix_bufname" => ["prefix_bufname", "color", "color for prefix of buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_suffix_bufname" => ["suffix_bufname", "color", "color for suffix of buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
);
my %default_options_look =
(
- "hotlist_counter" => ["hotlist_counter","boolean","show number of message for the buffer (this option needs WeeChat >= 0.3.5). The relevant option for notification is \"weechat.look.buffer_notify_default\"","",0,0,"off","off",0,"","","buffers_signal_config","","",""],
- "show_lag" => ["show_lag","boolean","show lag behind servername. This option is using \"irc.color.item_lag_finished\", \"irc.network.lag_min_show\" and \"irc.network.lag_refresh_interval\"","",0,0,"off","off",0,"","","buffers_signal_config","","",""],
- "look_whitelist_buffers" => ["whitelist_buffers", "string", "comma separated list of buffers for using a differnt color scheme (for example: freenode.#weechat,freenode.#weechat-fr)", "", 0, 0,"", "", 0, "", "", "buffers_signal_config_whitelist", "", "", ""],
- "hide_merged_buffers" => ["hide_merged_buffers", "integer", "hide merged buffers. The value determines which merged buffers should be hidden, keepserver meaning 'all except server buffers'. Other values correspondent to the buffer type.", "server|channel|private|keepserver|all|none", 0, 0,"none", "none", 0, "", "", "buffers_signal_config", "", "", ""],
- "indenting" => ["indenting", "integer", "use indenting for channel and query buffers. This option only takes effect if bar is left/right positioned", "off|on|under_name", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "indenting_number" => ["indenting_number", "boolean", "use indenting for numbers. This option only takes effect if bar is left/right positioned", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "short_names" => ["short_names", "boolean", "display short names (remove text before first \".\" in buffer name)", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_number" => ["show_number", "boolean", "display channel number in front of buffername", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_number_char" => ["number_char", "string", "display a char after channel number", "", 0, 0,".", ".", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_prefix" => ["prefix", "boolean", "show your prefix for channel", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_prefix_empty" => ["prefix_empty", "boolean", "use a placeholder for channels without prefix", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "sort" => ["sort", "integer", "sort buffer-list by \"number\" or \"name\"", "number|name", 0, 0,"number", "number", 0, "", "", "buffers_signal_config", "", "", ""],
- "core_to_front" => ["core_to_front", "boolean", "core buffer and buffers with free content will be listed first. Take only effect if buffer sort is by name", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "jump_prev_next_visited_buffer" => ["jump_prev_next_visited_buffer", "boolean", "jump to previously or next visited buffer if you click with left/right mouse button on currently visiting buffer", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "name_size_max" => ["name_size_max","integer","maximum size of buffer name. 0 means no limitation","",0,256,0,0,0, "", "", "buffers_signal_config", "", "", ""],
- "name_crop_suffix" => ["name_crop_suffix","string","contains an optional char(s) that is appended when buffer name is shortened","",0,0,"+","+",0,"","","buffers_signal_config", "", "", ""],
- "detach" => ["detach", "integer","detach channel from buffers list after a specific period of time (in seconds) without action (weechat ≥ 0.3.8 required)", "", 0, 31536000,0, "number", 0, "", "", "buffers_signal_config", "", "", ""],
- "immune_detach_buffers"=> ["immune_detach_buffers", "string", "Comma seperated list of buffers to NOT automatically detatch. Allows \"*\" wildcard. Ex: \"BitlBee,freenode.*\"", "", 0, 0,"", "", 0, "", "", "buffers_signal_config_immune_detach_buffers", "", "", ""],
- "detach_query" => ["detach_query", "boolean", "query buffer will be detachted", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "detach_free_content" => ["detach_free_content", "boolean", "buffers with free content will be detached (Ex: iset, chanmon)", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "mark_inactive" => ["mark_inactive", "boolean", "if option is \"on\", inactive buffers (those you are not in) will have parentesis around them. An inactive buffer will not be detached.", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "hotlist_counter" => ["hotlist_counter", "boolean", "show number of message for the buffer (this option needs WeeChat >= 0.3.5). The relevant option for notification is \"weechat.look.buffer_notify_default\"", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_lag" => ["show_lag", "boolean", "show lag behind servername. This option is using \"irc.color.item_lag_finished\", \"irc.network.lag_min_show\" and \"irc.network.lag_refresh_interval\"", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "look_whitelist_buffers" => ["whitelist_buffers", "string", "comma separated list of buffers for using a differnt color scheme (for example: freenode.#weechat,freenode.#weechat-fr)", "", 0, 0, "", "", 0, "", "", "buffers_signal_config_whitelist", "", "", ""],
+ "hide_merged_buffers" => ["hide_merged_buffers", "integer", "hide merged buffers. The value determines which merged buffers should be hidden, keepserver meaning 'all except server buffers'. Other values correspondent to the buffer type.", "server|channel|private|keepserver|all|none", 0, 0, "none", "none", 0, "", "", "buffers_signal_config", "", "", ""],
+ "indenting" => ["indenting", "integer", "use indenting for channel and query buffers. This option only takes effect if bar is left/right positioned", "off|on|under_name", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "indenting_number" => ["indenting_number", "boolean", "use indenting for numbers. This option only takes effect if bar is left/right positioned", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "short_names" => ["short_names", "boolean", "display short names (remove text before first \".\" in buffer name)", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_number" => ["show_number", "boolean", "display channel number in front of buffername", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_number_char" => ["number_char", "string", "display a char behind channel number", "", 0, 0, ".", ".", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix_bufname" => ["prefix_bufname", "string", "prefix displayed in front of buffername", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_suffix_bufname" => ["suffix_bufname", "string", "suffix displayed at end of buffername", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix" => ["prefix", "boolean", "displays your prefix for channel in front of buffername", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix_empty" => ["prefix_empty", "boolean", "use a placeholder for channels without prefix", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix_query" => ["prefix_for_query", "string", "prefix displayed in front of query buffer", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "sort" => ["sort", "integer", "sort buffer-list by \"number\" or \"name\"", "number|name", 0, 0, "number", "number", 0, "", "", "buffers_signal_config", "", "", ""],
+ "core_to_front" => ["core_to_front", "boolean", "core buffer and buffers with free content will be listed first. Take only effect if buffer sort is by name", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "jump_prev_next_visited_buffer" => ["jump_prev_next_visited_buffer", "boolean", "jump to previously or next visited buffer if you click with left/right mouse button on currently visiting buffer", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "name_size_max" => ["name_size_max", "integer", "maximum size of buffer name. 0 means no limitation", "", 0, 256, 0, 0, 0, "", "", "buffers_signal_config", "", "", ""],
+ "name_crop_suffix" => ["name_crop_suffix", "string", "contains an optional char(s) that is appended when buffer name is shortened", "", 0, 0, "+", "+", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach" => ["detach", "integer", "detach channel from buffers list after a specific period of time (in seconds) without action (weechat ≥ 0.3.8 required) (0 means \"off\")", "", 0, 31536000, 0, "number", 0, "", "", "buffers_signal_config", "", "", ""],
+ "immune_detach_buffers" => ["immune_detach_buffers", "string", "comma separated list of buffers to NOT automatically detatch. Allows \"*\" wildcard. Ex: \"BitlBee,freenode.*\"", "", 0, 0, "", "", 0, "", "", "buffers_signal_config_immune_detach_buffers", "", "", ""],
+ "detach_query" => ["detach_query", "boolean", "query buffer will be detachted", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach_buffer_immediately" => ["detach_buffer_immediately", "string", "comma separated list of buffers to detach immediately. A query and highlight message will attach buffer again. Allows \"*\" wildcard. Ex: \"BitlBee,freenode.*\"", "", 0, 0, "", "", 0, "", "", "buffers_signal_config_detach_buffer_immediately", "", "", ""],
+ "detach_free_content" => ["detach_free_content", "boolean", "buffers with free content will be detached (Ex: iset, chanmon)", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach_displayed_buffers" => ["detach_displayed_buffers", "boolean", "buffers displayed in a (split) window will be detached", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach_display_window_number" => ["detach_display_window_number", "boolean", "window number will be add, behind buffer name (this option takes only effect with \"detach_displayed_buffers\" option)", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "mark_inactive" => ["mark_inactive", "boolean", "if option is \"on\", inactive buffers (those you are not in) will have parentesis around them. An inactive buffer will not be detached.", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "toggle_bar" => ["toogle_bar", "boolean", "if option is \"on\", buffers bar will hide/show when script is (un)loaded.", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "mouse_move_buffer" => ["mouse_move_buffer", "boolean", "if option is \"on\", mouse gestures (drag & drop) can move buffers in list.", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
);
# section "color"
my $section_color = weechat::config_new_section($buffers_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", "");
@@ -443,7 +492,8 @@ my %default_options_look =
$default_options_look{$option}[3],$default_options_look{$option}[4],$default_options_look{$option}[5],
$default_options_look{$option}[6],$default_options_look{$option}[7],$default_options_look{$option}[8],
$default_options_look{$option}[9],$default_options_look{$option}[10],$default_options_look{$option}[11],
- $default_options_look{$option}[12],$default_options_look{$option}[13],$default_options_look{$option}[14]);
+ $default_options_look{$option}[12],$default_options_look{$option}[13],$default_options_look{$option}[14],
+ $default_options_look{$option}[15]);
}
}
@@ -515,6 +565,7 @@ sub build_buffers
$buffer->{"number"} = $number;
$buffer->{"active"} = $active;
$buffer->{"current_buffer"} = weechat::infolist_integer($infolist, "current_buffer");
+ $buffer->{"num_displayed"} = weechat::infolist_integer($infolist, "num_displayed");
$buffer->{"plugin_name"} = weechat::infolist_string($infolist, "plugin_name");
$buffer->{"name"} = weechat::infolist_string($infolist, "name");
$buffer->{"short_name"} = weechat::infolist_string($infolist, "short_name");
@@ -540,6 +591,11 @@ sub build_buffers
}
my $result = check_immune_detached_buffers($buffer->{"name"}); # checking for wildcard
+
+ next if ( check_detach_buffer_immediately($buffer->{"name"}) eq 1
+ and $buffer->{"current_buffer"} eq 0
+ and ( not exists $hotlist{$buffer->{"pointer"}} or $hotlist{$buffer->{"pointer"}} < 2) ); # checking for buffer to immediately detach
+
unless ($result)
{
my $detach_time = weechat::config_integer( $options{"detach"});
@@ -593,6 +649,31 @@ sub build_buffers
push(@current1, $buffer);
}
}
+ elsif ( $buffer->{"current_buffer"} eq 0
+ and not exists $hotlist{$buffer->{"pointer"}}
+# and $buffer->{"type"} eq "channel"
+ and exists $buffers_timer{$buffer->{"pointer"}}
+ and $detach_time > 0
+ and $weechat_version >= 0x00030800
+ and $current_time - $buffers_timer{$buffer->{"pointer"}} >= $detach_time)
+ { # check for option detach_displayed_buffers and if buffer is displayed in a split window
+ if ( $buffer->{"num_displayed"} eq 1
+ and weechat::config_boolean($options{"detach_displayed_buffers"}) eq 0 )
+ {
+ my $infolist_window = weechat::infolist_get("window","","");
+ while (weechat::infolist_next($infolist_window))
+ {
+ my $buffer_ptr = weechat::infolist_pointer($infolist_window, "buffer");
+ if ($buffer_ptr eq $buffer->{"pointer"})
+ {
+ $buffer->{"window"} = weechat::infolist_integer($infolist_window, "number");
+ }
+ }
+ weechat::infolist_free($infolist_window);
+
+ push(@current2, $buffer);
+ }
+ }
}
else # buffer in "immune_detach_buffers"
{
@@ -780,6 +861,14 @@ sub build_buffers
$color_bg = weechat::color(",".$bg) if ($bg ne "");
# create channel number for output
+ if ( weechat::config_string( $options{"show_prefix_bufname"} ) ne "" )
+ {
+ $str .= $color_bg .
+ weechat::color( weechat::config_color( $options{"color_prefix_bufname"} ) ).
+ weechat::config_string( $options{"show_prefix_bufname"} ).
+ weechat::color("default");
+ }
+
if ( weechat::config_boolean( $options{"show_number"} ) eq 1 ) # on
{
if (( weechat::config_boolean( $options{"indenting_number"} ) eq 1)
@@ -831,6 +920,9 @@ sub build_buffers
}
}
}
+
+ $str .= weechat::config_string( $options{"show_prefix_query"}) if (weechat::config_string( $options{"show_prefix_query"} ) ne "" and $buffer->{"type"} eq "private");
+
if (weechat::config_boolean( $options{"show_prefix"} ) eq 1)
{
my $nickname = weechat::buffer_get_string($buffer->{"pointer"}, "localvar_nick");
@@ -841,8 +933,6 @@ sub build_buffers
my $infolist_nick = weechat::infolist_get("nicklist", $buffer->{"pointer"}, "nick_".$nickname);
if ($infolist_nick ne "")
{
- my $version = weechat::info_get("version_number", "");
- $version = 0 if ($version eq "");
while (weechat::infolist_next($infolist_nick))
{
if ((weechat::infolist_string($infolist_nick, "type") eq "nick")
@@ -852,7 +942,7 @@ sub build_buffers
if (($prefix ne " ") or (weechat::config_boolean( $options{"show_prefix_empty"} ) eq 1))
{
# with version >= 0.3.5, it is now a color name (for older versions: option name with color)
- if (int($version) >= 0x00030500)
+ if (int($weechat_version) >= 0x00030500)
{
$str .= weechat::color(weechat::infolist_string($infolist_nick, "prefix_color"));
}
@@ -889,8 +979,6 @@ sub build_buffers
}
else
{
- #$str .= weechat::buffer_get_string($buffer->{"pointer"},"localvar_server");
- #$str .= "/";
$str .= $buffer->{"short_name"};
$str .= add_inactive_parentless($buffer->{"type"},$buffer->{"nicks_count"});
$str .= add_hotlist_count($buffer->{"pointer"},%hotlist);
@@ -926,10 +1014,30 @@ sub build_buffers
$str .= weechat::color("default") . " (" . weechat::color($color_lag) . $lag . weechat::color("default") . ")";
}
}
+ if (weechat::config_boolean($options{"detach_displayed_buffers"}) eq 0
+ and weechat::config_boolean($options{"detach_display_window_number"}) eq 1)
+ {
+ if ($buffer->{"window"})
+ {
+ $str .= weechat::color("default") . " (" . weechat::color(weechat::config_color( $options{"color_number"})) . $buffer->{"window"} . weechat::color("default") . ")";
+ }
+ }
+ $str .= weechat::color("default");
+
+ if ( weechat::config_string( $options{"show_suffix_bufname"} ) ne "" )
+ {
+ $str .= weechat::color( weechat::config_color( $options{"color_suffix_bufname"} ) ).
+ weechat::config_string( $options{"show_suffix_bufname"} ).
+ weechat::color("default");
+ }
+
$str .= "\n";
$old_number = $buffer->{"number"};
}
+ # remove spaces and/or linefeed at the end
+ $str =~ s/\s+$//;
+ chomp($str);
return $str;
}
@@ -1025,7 +1133,8 @@ return $str;
sub buffers_signal_buffer
{
-my ($data, $signal, $signal_data) = @_;
+ my ($data, $signal, $signal_data) = @_;
+
# check for buffer_switch and set or remove detach time
if ($weechat_version >= 0x00030800)
{
@@ -1052,14 +1161,13 @@ my ($data, $signal, $signal_data) = @_;
delete $buffers_timer{$signal_data};
}
}
-
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
sub buffers_signal_hotlist
{
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
@@ -1068,20 +1176,29 @@ sub buffers_signal_config_whitelist
{
@whitelist_buffers = ();
@whitelist_buffers = split( /,/, weechat::config_string( $options{"look_whitelist_buffers"} ) );
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
+
sub buffers_signal_config_immune_detach_buffers
{
@immune_detach_buffers = ();
@immune_detach_buffers = split( /,/, weechat::config_string( $options{"immune_detach_buffers"} ) );
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
+ return weechat::WEECHAT_RC_OK;
+}
+
+sub buffers_signal_config_detach_buffer_immediately
+{
+ @detach_buffer_immediately = ();
+ @detach_buffer_immediately = split( /,/, weechat::config_string( $options{"detach_buffer_immediately"} ) );
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
sub buffers_signal_config
{
- weechat::bar_item_update("buffers");
+ weechat::bar_item_update($SCRIPT_NAME);
return weechat::WEECHAT_RC_OK;
}
@@ -1092,7 +1209,7 @@ sub buffers_focus_buffers
my %info = %{$_[1]};
my $item_line = int($info{"_bar_item_line"});
undef my $hash;
- if (($info{"_bar_item_name"} eq "buffers") && ($item_line >= 0) && ($item_line <= $#buffers_focus))
+ if (($info{"_bar_item_name"} eq $SCRIPT_NAME) && ($item_line >= 0) && ($item_line <= $#buffers_focus))
{
$hash = $buffers_focus[$item_line];
}
@@ -1117,7 +1234,7 @@ sub buffers_hsignal_mouse
if ( $hash{"_key"} eq "button1" ) # left mouse button
{
- if ($hash{"number"} eq $hash{"number2"})
+ if ($hash{"number"} eq $hash{"number2"})
{
if ( weechat::config_integer($options{"jump_prev_next_visited_buffer"}) eq 1 )
{
@@ -1137,7 +1254,7 @@ sub buffers_hsignal_mouse
}
else
{
- move_buffer(%hash);
+ move_buffer(%hash) if (weechat::config_boolean($options{"mouse_move_buffer"}));
}
}
elsif ( ($hash{"_key"} eq "button2") && (weechat::config_integer($options{"jump_prev_next_visited_buffer"}) eq 1) )# right mouse button
@@ -1166,7 +1283,7 @@ sub buffers_hsignal_mouse
}
else
{
- move_buffer(%hash);
+ move_buffer(%hash) if (weechat::config_boolean($options{"mouse_move_buffer"}));
}
}
}
@@ -1179,8 +1296,20 @@ sub move_buffer
{
# if number 2 is not known (end of gesture outside buffers list), then set it
# according to mouse gesture
- $number2 = "999999";
- $number2 = "1" if (($hash{"_key"} =~ /gesture-left/) || ($hash{"_key"} =~ /gesture-up/));
+ $number2 = "1";
+ if (($hash{"_key"} =~ /gesture-right/) || ($hash{"_key"} =~ /gesture-down/))
+ {
+ $number2 = "999999";
+ if ($weechat_version >= 0x00030600)
+ {
+ my $hdata_buffer = weechat::hdata_get("buffer");
+ my $last_gui_buffer = weechat::hdata_get_list($hdata_buffer, "last_gui_buffer");
+ if ($last_gui_buffer)
+ {
+ $number2 = weechat::hdata_integer($hdata_buffer, $last_gui_buffer, "number") + 1;
+ }
+ }
+ }
}
my $ptrbuf = weechat::current_buffer();
weechat::command($hash{"pointer"}, "/buffer move ".$number2);
@@ -1198,3 +1327,43 @@ sub check_immune_detached_buffers
}
return 0;
}
+
+sub check_detach_buffer_immediately
+{
+ my ($buffername) = @_;
+ foreach ( @detach_buffer_immediately ){
+ my $detach_buffer = weechat::string_mask_to_regex($_);
+ if ($buffername =~ /^$detach_buffer$/i)
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+sub shutdown_cb
+{
+ weechat::command("","/bar hide " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 );
+ return weechat::WEECHAT_RC_OK
+}
+
+sub check_bar_item
+{
+ my $item = 0;
+ my $infolist = weechat::infolist_get("bar", "", "");
+ while (weechat::infolist_next($infolist))
+ {
+ my $bar_items = weechat::infolist_string($infolist, "items");
+ if (index($bar_items,$SCRIPT_NAME) != -1)
+ {
+ my $name = weechat::infolist_string($infolist, "name");
+ if ($name ne $SCRIPT_NAME)
+ {
+ $item = 1;
+ last;
+ }
+ }
+ }
+ weechat::infolist_free($infolist);
+ return $item;
+}
diff --git a/weechat/perl/highmon.pl b/weechat/perl/highmon.pl
index b7e0aae..2aeb1de 100644
--- a/weechat/perl/highmon.pl
+++ b/weechat/perl/highmon.pl
@@ -1,6 +1,6 @@
#
# highmon.pl - Highlight Monitoring for weechat 0.3.0
-# Version 2.3.2
+# Version 2.4
#
# Add 'Highlight Monitor' buffer/bar to log all highlights in one spot
#
@@ -66,6 +66,14 @@
# Bugs and feature requests at: https://github.com/KenjiE20/highmon
# History:
+# 2013-12-04, KenjiE20 <longbow@longbowslair.co.uk>:
+# v2.4: -add: Support for eval style colour codes in time format used for bar output
+# 2013-10-22, KenjiE20 <longbow@longbowslair.co.uk>:
+# v2.3.3.2: -fix: Typo in fix command
+# 2013-10-10, KenjiE20 <longbow@longbowslair.co.uk>:
+# v2.3.3.1: -fix: Typo in closed buffer warning
+# 2013-10-07, KenjiE20 <longbow@longbowslair.co.uk>:
+# v2.3.3: -add: Warning and fixer for accidental buffer closes
# 2013-01-15, KenjiE20 <longbow@longbowslair.co.uk>:
# v2.3.2: -fix: Let bar output use the string set in weechat's config option
# -add: github info
@@ -302,6 +310,11 @@ sub highmon_buffer_input
sub highmon_buffer_close
{
$highmon_buffer = "";
+ # If user hasn't changed output style warn user
+ if (weechat::config_get_plugin("output") eq "buffer")
+ {
+ weechat::print("", "\tHighmon buffer has been closed but output is still set to buffer, unusual results may occur. To recreate the buffer use ".weechat::color("bold")."/highmon fix".weechat::color("-bold"));
+ }
return weechat::WEECHAT_RC_OK;
}
@@ -342,6 +355,14 @@ sub highmon_command_cb
{
highmon_config_clean($data, $buffer, $arg);
}
+ # Fix closed buffer
+ elsif ($cmd eq "fix")
+ {
+ if (weechat::config_get_plugin("output") eq "buffer" && $highmon_buffer eq "")
+ {
+ highmon_buffer_open();
+ }
+ }
return weechat::WEECHAT_RC_OK;
}
@@ -833,13 +854,14 @@ sub highmon_print
use POSIX qw(strftime);
$time = strftime(weechat::config_string(weechat::config_get("weechat.look.buffer_time_format")), localtime);
# Colourise
- if ($time =~ /\$\{\w+\}/) # Coloured string
+ if ($time =~ /\$\{(?:color:)?[\w,]+\}/) # Coloured string
{
- while ($time =~ /\$\{(\w+)\}/)
+ while ($time =~ /\$\{(?:color:)?([\w,]+)\}/)
{
$color = weechat::color($1);
- $time =~ s/\$\{\w+\}/$color/;
+ $time =~ s/\$\{(?:color:)?[\w,]+\}/$color/;
}
+ $time .= weechat::color("reset");
}
else # Default string
{
@@ -1049,7 +1071,7 @@ sub format_buffer_name
}
# Check result of register, and attempt to behave in a sane manner
-if (!weechat::register("highmon", "KenjiE20", "2.3.2", "GPL3", "Highlight Monitor", "", ""))
+if (!weechat::register("highmon", "KenjiE20", "2.4", "GPL3", "Highlight Monitor", "", ""))
{
# Double load
weechat::print ("", "\tHighmon is already loaded");
diff --git a/weechat/perl/iset.pl b/weechat/perl/iset.pl
index d27ec92..4b922ee 100644
--- a/weechat/perl/iset.pl
+++ b/weechat/perl/iset.pl
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008-2012 Sebastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2008-2013 Sebastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2010-2012 Nils Görs <weechatter@arcor.de>
#
# This program is free software; you can redistribute it and/or modify
@@ -19,13 +19,24 @@
#
# History:
#
-# 2013-04-30, arza <arza@arza.us>:
+# 2014-01-30, stfn <stfnmd@gmail.com>:
+# version 3.4: add new options "color_value_diff" and "color_value_diff_selected"
+# 2014-01-16, luz <ne.tetewi@gmail.com>:
+# version 3.3: fix bug with column alignment in iset buffer when option
+# name contains unicode characters
+# 2013-08-03, Sebastien Helleu <flashcode@flashtux.org>:
+# version 3.2: allow "q" as input in iset buffer to close it
+# 2013-07-14, Sebastien Helleu <flashcode@flashtux.org>:
+# version 3.1: remove unneeded calls to iset_refresh() in mouse callback
+# (faster mouse actions when lot of options are displayed),
+# fix bug when clicking on a line after the last option displayed
+# 2013-04-30, arza <arza@arza.us>:
# version 3.0: simpler title, fix refresh on unset
-# 2012-12-16, nils_2 <weechatter@arcor.de>:
+# 2012-12-16, nils_2 <weechatter@arcor.de>:
# version 2.9: fix focus window with iset buffer on mouse click
-# 2012-08-25, nils_2 <weechatter@arcor.de>:
+# 2012-08-25, nils_2 <weechatter@arcor.de>:
# version 2.8: most important key and mouse bindings for iset buffer added to title-bar (idea The-Compiler)
-# 2012-07-31, nils_2 <weechatter@arcor.de>:
+# 2012-07-31, nils_2 <weechatter@arcor.de>:
# version 2.7: add combined option and value search (see /help iset)
# : add exact value search (see /help iset)
# : fix problem with metacharacter in value search
@@ -102,7 +113,7 @@
use strict;
my $PRGNAME = "iset";
-my $VERSION = "3.0";
+my $VERSION = "3.4";
my $DESCR = "Interactive Set for configuration options";
my $AUTHOR = "Sebastien Helleu <flashcode\@flashtux.org>";
my $LICENSE = "GPL3";
@@ -116,6 +127,7 @@ my @iset_focus = ();
my @options_names = ();
my @options_types = ();
my @options_values = ();
+my @options_default_values = ();
my @options_is_null = ();
my $option_max_length = 0;
my $current_line = 0;
@@ -211,6 +223,11 @@ sub iset_create_filter
sub iset_buffer_input
{
my ($data, $buffer, $string) = ($_[0], $_[1], $_[2]);
+ if ($string eq "q")
+ {
+ weechat::buffer_close($buffer);
+ return weechat::WEECHAT_RC_OK;
+ }
$search_value = "";
my @cmd_array = split(/ /,$string);
my $array_count = @cmd_array;
@@ -314,6 +331,7 @@ sub iset_get_options
@options_names = ();
@options_types = ();
@options_values = ();
+ @options_default_values = ();
@options_is_null = ();
$option_max_length = 0;
my %options_internal = ();
@@ -332,6 +350,7 @@ sub iset_get_options
next if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
my $type = weechat::infolist_string($infolist, "type");
my $value = weechat::infolist_string($infolist, "value");
+ my $default_value = weechat::infolist_string($infolist, "default_value");
my $is_null = weechat::infolist_integer($infolist, "value_is_null");
if ($search_mode == 3)
{
@@ -340,6 +359,7 @@ sub iset_get_options
{
$options_internal{$name}{"type"} = $type;
$options_internal{$name}{"value"} = $value;
+ $options_internal{$name}{"default_value"} = $default_value;
$options_internal{$name}{"is_null"} = $is_null;
$option_max_length = length($name) if (length($name) > $option_max_length);
$iset_struct{$key} = $options_internal{$name};
@@ -350,6 +370,7 @@ sub iset_get_options
{
$options_internal{$name}{"type"} = $type;
$options_internal{$name}{"value"} = $value;
+ $options_internal{$name}{"default_value"} = $default_value;
$options_internal{$name}{"is_null"} = $is_null;
$option_max_length = length($name) if (length($name) > $option_max_length);
$iset_struct{$key} = $options_internal{$name};
@@ -364,6 +385,7 @@ sub iset_get_options
push(@options_names, $name);
push(@options_types, $options_internal{$name}{"type"});
push(@options_values, $options_internal{$name}{"value"});
+ push(@options_default_values, $options_internal{$name}{"default_value"});
push(@options_is_null, $options_internal{$name}{"is_null"});
}
}
@@ -388,6 +410,7 @@ sub iset_search_values
@options_names = ();
@options_types = ();
@options_values = ();
+ @options_default_values = ();
@options_is_null = ();
$option_max_length = 0;
my %options_internal = ();
@@ -400,12 +423,14 @@ sub iset_search_values
my $type = weechat::infolist_string($infolist, "type");
my $is_null = weechat::infolist_integer($infolist, "value_is_null");
my $value = weechat::infolist_string($infolist, "value");
+ my $default_value = weechat::infolist_string($infolist, "default_value");
if ($search_mode)
{
if ( grep /\Q$var_value/,lc($value) )
{
$options_internal{$name}{"type"} = $type;
$options_internal{$name}{"value"} = $value;
+ $options_internal{$name}{"default_value"} = $default_value;
$options_internal{$name}{"is_null"} = $is_null;
$option_max_length = length($name) if (length($name) > $option_max_length);
}
@@ -417,6 +442,7 @@ sub iset_search_values
{
$options_internal{$name}{"type"} = $type;
$options_internal{$name}{"value"} = $value;
+ $options_internal{$name}{"default_value"} = $default_value;
$options_internal{$name}{"is_null"} = $is_null;
$option_max_length = length($name) if (length($name) > $option_max_length);
}
@@ -429,6 +455,7 @@ sub iset_search_values
push(@options_names, $name);
push(@options_types, $options_internal{$name}{"type"});
push(@options_values, $options_internal{$name}{"value"});
+ push(@options_default_values, $options_internal{$name}{"default_value"});
push(@options_is_null, $options_internal{$name}{"is_null"});
}
}
@@ -441,7 +468,16 @@ sub iset_refresh_line
if ($y <= $#options_names)
{
return if (! defined($options_types[$y]));
- my $format = sprintf("%%s%%-%ds %%s %%-7s %%s %%s%%s%%s", $option_max_length);
+ my $format = sprintf("%%s%%s%%s %%s %%-7s %%s %%s%%s%%s");
+ my $padding;
+ if ($wee_version_number >= 0x00040200)
+ {
+ $padding = " " x ($option_max_length - weechat::strlen_screen($options_names[$y]));
+ }
+ else
+ {
+ $padding = " " x ($option_max_length - length($options_names[$y]));
+ }
my $around = "";
$around = "\"" if ((!$options_is_null[$y]) && ($options_types[$y] eq "string"));
@@ -452,6 +488,10 @@ sub iset_refresh_line
{
$color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef"}));
}
+ elsif ($options_values[$y] ne $options_default_values[$y])
+ {
+ $color3 = weechat::color(weechat::config_color($options_iset{"color_value_diff"}));
+ }
else
{
$color3 = weechat::color(weechat::config_color($options_iset{"color_value"}));
@@ -464,6 +504,10 @@ sub iset_refresh_line
{
$color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
}
+ elsif ($options_values[$y] ne $options_default_values[$y])
+ {
+ $color3 = weechat::color(weechat::config_color($options_iset{"color_value_diff_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
+ }
else
{
$color3 = weechat::color(weechat::config_color($options_iset{"color_value_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
@@ -472,7 +516,7 @@ sub iset_refresh_line
my $value = $options_values[$y];
$value = "(undef)" if ($options_is_null[$y]);
my $strline = sprintf($format,
- $color1, $options_names[$y],
+ $color1, $options_names[$y], $padding,
$color2, $options_types[$y],
$color3, $around, $value, $around);
weechat::print_y($iset_buffer, $y, $strline);
@@ -537,14 +581,17 @@ sub iset_full_refresh
sub iset_set_current_line
{
my $new_current_line = $_[0];
- my $old_current_line = $current_line;
- $current_line = $new_current_line;
- $current_line = $#options_names if ($current_line > $#options_names);
- if ($old_current_line != $current_line)
+ if ($new_current_line >= 0)
{
- iset_refresh_line($old_current_line);
- iset_refresh_line($current_line);
- weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1);
+ my $old_current_line = $current_line;
+ $current_line = $new_current_line;
+ $current_line = $#options_names if ($current_line > $#options_names);
+ if ($old_current_line != $current_line)
+ {
+ iset_refresh_line($old_current_line);
+ iset_refresh_line($current_line);
+ weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1);
+ }
}
}
@@ -661,6 +708,7 @@ sub iset_config_cb
{
$options_types[$index] = weechat::infolist_string($infolist, "type");
$options_values[$index] = weechat::infolist_string($infolist, "value");
+ $options_default_values[$index] = weechat::infolist_string($infolist, "default_value");
$options_is_null[$index] = weechat::infolist_integer($infolist, "value_is_null");
iset_refresh_line($index);
iset_title() if ($option_name eq "iset.look.show_current_line");
@@ -1100,24 +1148,18 @@ sub iset_hsignal_mouse_cb
{
if ($hash{"_key"} eq "button1")
{
- $current_line = $hash{"_chat_line_y"};
- iset_refresh_line($current_line);
- iset_refresh();
+ iset_set_current_line($hash{"_chat_line_y"});
}
elsif ($hash{"_key"} eq "button2")
{
if ($options_types[$hash{"_chat_line_y"}] eq "boolean")
{
iset_set_option($options_names[$hash{"_chat_line_y"}], "toggle");
- $current_line = $hash{"_chat_line_y"};
- iset_refresh_line($current_line);
- iset_refresh();
+ iset_set_current_line($hash{"_chat_line_y"});
}
elsif ($options_types[$hash{"_chat_line_y"}] eq "string")
{
- $current_line = $hash{"_chat_line_y"};
- iset_refresh_line($current_line);
- iset_refresh();
+ iset_set_current_line($hash{"_chat_line_y"});
weechat::command("", "/$PRGNAME **set");
}
}
@@ -1125,20 +1167,16 @@ sub iset_hsignal_mouse_cb
{
if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
{
- $current_line = $hash{"_chat_line_y"};
- iset_refresh_line($current_line);
- iset_refresh();
+ iset_set_current_line($hash{"_chat_line_y"});
my $distance = distance($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
weechat::command("", "/repeat $distance /$PRGNAME **decr");
}
}
elsif ($hash{"_key"} eq "button2-gesture-right" or $hash{"_key"} eq "button2-gesture-right-long")
{
- if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
+ if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
{
- $current_line = $hash{"_chat_line_y"};
- iset_refresh_line($current_line);
- iset_refresh();
+ iset_set_current_line($hash{"_chat_line_y"});
my $distance = distance($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
weechat::command("", "/repeat $distance /$PRGNAME **incr");
}
@@ -1217,6 +1255,14 @@ sub iset_config_init
$iset_config_file, $section_color,
"value_selected", "color", "Color for selected option value", "", 0, 0,
"lightcyan", "lightcyan", 0, "", "", "full_refresh_cb", "", "", "");
+ $options_iset{"color_value_diff"} = weechat::config_new_option(
+ $iset_config_file, $section_color,
+ "value_diff", "color", "Color for option value different from default", "", 0, 0,
+ "magenta", "magenta", 0, "", "", "full_refresh_cb", "", "", "");
+ $options_iset{"color_value_diff_selected"} = weechat::config_new_option(
+ $iset_config_file, $section_color,
+ "value_diff_selected", "color", "Color for selected option value different from default", "", 0, 0,
+ "lightmagenta", "lightmagenta", 0, "", "", "full_refresh_cb", "", "", "");
$options_iset{"color_value_undef"} = weechat::config_new_option(
$iset_config_file, $section_color,
"value_undef", "color", "Color for option value undef", "", 0, 0,
diff --git a/weechat/perl/yaurls.pl b/weechat/perl/yaurls.pl
deleted file mode 100644
index caae3e2..0000000
--- a/weechat/perl/yaurls.pl
+++ /dev/null
@@ -1,301 +0,0 @@
-# Copyright (c) 2012 by R1cochet R1cochet@hushmail.com
-# All rights reserved
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-#
-# yaURLs, version 1.9, for weechat version 0.3.7 or later
-# will shorten URL's in channels
-#
-# Shorten URL's using any of the following services:
-# durl.me, is.gd, ln-s.net, lytn.it, metamark.net, sapo.pt, safe.mn, tinyURL.com
-#
-# Default color theme in 256color terminal
-# header: 46
-# prefix/suffix: *200
-# url: *190
-# domain: 196
-#
-#
-# Changelog:
-# 2012-09-21, R1cochet
-# version 1.9: Added more shortening services
-# 2012-03-09, Sebastien Helleu <flashcode@flashtux.org>
-# version 1.8: Fix reload of config file
-# 2012-03-08, R1cochet
-# version 1.7: Removed need for Regexp::Common and URI::Escape modules. Cleaned up some code
-# 2012-03-04, R1cochet
-# version 1.6: Fixed error with twitter links not being recognized. Added module URI::Escape to properly format URL's before shortening
-# 2012-02-28, R1cochet
-# version 1.5: Initial release
-
-use strict;
-use warnings;
-
-my $SCRIPT_NAME = "yaurls";
-my $SCRIPT_AUTHOR = "R1cochet";
-my $VERSION = "1.9";
-my $SCRIPT_LICENSE = "GPL3";
-my $SCRIPT_DESC = "yes, another URL shortener";
-
-# initialize global variables
-my $config_file; # config pointer
-my %config_section; # config section pointer
-my %config_options; # init config options
-my $incoming_nick = "";
-
-my %Unsafe = (RFC3986 => qr/[^A-Za-z0-9\-\._~]/,);
-my %escapes;
-for (0..255) {
- $escapes{chr($_)} = sprintf("%%%02X", $_);
-}
-
-weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $VERSION, $SCRIPT_LICENSE, $SCRIPT_DESC, "", "");
-
-### initial config
-sub init_config {
- $config_file = weechat::config_new("yaurls", "config_reload_cb", "");
- return if (!$config_file);
-
- # create new section in config file
- $config_section{'blacklists'} = weechat::config_new_section($config_file, "blacklists", 0, 0, "", "", "", "", "", "", "", "", "", "");
- if (!$config_section{'blacklists'}) {
- weechat::config_free($config_file);
- return;
- }
- # add the options to the section
- $config_options{'channel_blacklist'} = weechat::config_new_option($config_file, $config_section{'blacklists'}, "channel_blacklist", "string",
- "Comma seperated list of Channels to ignore", "", 0, 0, "", "", 1, "", "", "", "", "", "",);
- $config_options{'nick_blacklist'} = weechat::config_new_option($config_file, $config_section{'blacklists'}, "nick_blacklist", "string",
- "Comma seperated list of Nicks to ignore", "", 0, 0, "", "", 1, "", "", "", "", "", "",);
- $config_options{'server_blacklist'} = weechat::config_new_option($config_file, $config_section{'blacklists'}, "server_blacklist", "string",
- "Comma seperated list of Servers to ignore", "", 0, 0, "", "", 1, "", "", "", "", "", "",);
- $config_options{'string_blacklist'} = weechat::config_new_option($config_file, $config_section{'blacklists'}, "string_blacklist", "string",
- "Comma seperated list of Strings to ignore", "", 0, 0, "", "", 1, "", "", "", "", "", "",);
- $config_options{'url_blacklist'} = weechat::config_new_option($config_file, $config_section{'blacklists'}, "url_blacklist", "string",
- "Comma seperated list of URL's to ignore", "", 0, 0, "youtube.com", "youtube.com", 1, "", "", "", "", "", "",);
-
- $config_section{'colors'} = weechat::config_new_section($config_file, "colors", 0, 0, "", "", "", "", "", "", "", "", "", "");
- if (!$config_section{'colors'}) {
- weechat::config_free($config_file);
- return;
- }
- $config_options{'header_color'} = weechat::config_new_option($config_file, $config_section{'colors'}, "header_color", "color",
- "Set the color of the header", "", 0, 0, "green", "green", 0, "", "", "", "", "", "",);
- $config_options{'prefix_color'} = weechat::config_new_option($config_file, $config_section{'colors'}, "prefix_suffix_color", "color",
- "Set the color of the prefix and suffix", "", 0, 0, "magenta", "magenta", 0, "", "", "", "", "", "",);
- $config_options{'url_color'} = weechat::config_new_option($config_file, $config_section{'colors'}, "url_color", "color",
- "Set the color of the tinyURL link", "", 0, 0, "yellow", "yellow", 0, "", "", "", "", "", "",);
- $config_options{'domain_color'} = weechat::config_new_option($config_file, $config_section{'colors'}, "domain_color", "color",
- "Set the color of the domain name", "", 0, 0, "blue", "blue", 0, "", "", "", "", "", "",);
-
- $config_section{'engine'} = weechat::config_new_section($config_file, "engine", 0, 0, "", "", "", "", "", "", "", "", "", "");
- if (!$config_section{'engine'}) {
- weechat::config_free($config_file);
- return;
- }
- $config_options{'service'} = weechat::config_new_option($config_file, $config_section{'engine'}, "service", "integer",
- "Set which shortener service to use (durl = durl.me, is.gd = is.gd, ln-s = ln-s.net, lytn = lytn.it, ".
- "metamark = metamark.net, punyURL = sapo.pt, safe = safe.mn, tinyURL = tinyURL.com)",
- "durl|is.gd|ln-s|lytn|metamark|punyURL|safe|tinyURL", 0, 0, "tinyURL", "tinyURL", 0, "", "", "", "", "", "");
- $config_options{'convert_own'} = weechat::config_new_option($config_file, $config_section{'engine'}, "convert_own", "boolean",
- "Convert own links sent to buffer", "", 0, 0, "off", "off", 0, "", "", "", "", "", "",);
- $config_options{'maximum_length'} = weechat::config_new_option($config_file, $config_section{'engine'}, "maximum_length", "integer",
- "Set the maximum length of URL's to be converted (anything equal to or larger will be converted)", "", 20, 500, "35", "35", 0, "", "", "", "", "", "");
- $config_options{'timeout'} = weechat::config_new_option($config_file, $config_section{'engine'}, "timeout", "integer",
- "Set the maximum time limit for fetching the short URL (time in seconds)", "", 10, 120, "20", "20", 0, "", "", "", "", "", "");
-
- $config_section{'look'} = weechat::config_new_section($config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "");
- if (!$config_section{'look'}) {
- weechat::config_free($config_file);
- return;
- }
- $config_options{'header'} = weechat::config_new_option($config_file, $config_section{'look'}, "header", "string",
- "Set the header string", "", 0, 0, "yaURLs", "yaURLs", 1, "", "", "", "", "", "",);
- $config_options{'header_prefix'} = weechat::config_new_option($config_file, $config_section{'look'}, "header_prefix", "string",
- "Set the header prefix", "", 0, 0, "{", "{", 1, "", "", "", "", "", "",);
- $config_options{'header_suffix'} = weechat::config_new_option($config_file, $config_section{'look'}, "header_suffix", "string",
- "Set the header suffix", "", 0, 0, "}~>", "}~>", 1, "", "", "", "", "", "",);
- $config_options{'format'} = weechat::config_new_option($config_file, $config_section{'look'}, "format", "string",
- "Set the print format (%H = Header, %U = tinyURL, %D = Domain)", "", 0, 0, "%H %U %D", "%H %U %D", 0, "", "", "", "", "", "",);
-}
-# intit callbacks
-sub config_reload_cb { # reload config file
- return weechat::config_reload($config_file);
-}
-
-sub config_read { # read my config file
- return weechat::config_read($config_file);
-}
-
-sub config_write { # write to my config file
- return weechat::config_write($config_file);
-}
-
-init_config(); # load config
-config_read(); # get options if already in config file
-
-weechat::hook_print( "", "irc_privmsg", "://", 1, "print_hook_cb", ""); # Hook into print
-
-sub build_header {
- my $header = weechat::color(weechat::config_color($config_options{'header_color'})) . weechat::config_string($config_options{'header'}) . weechat::color("reset");
- $header = weechat::color(weechat::config_color($config_options{'prefix_color'})) . weechat::config_string($config_options{'header_prefix'}) . weechat::color("reset") . $header;
- $header = $header . weechat::color(weechat::config_color($config_options{'prefix_color'})) . weechat::config_string($config_options{'header_suffix'}) . weechat::color("reset");
- return $header;
-}
-
-sub black_list1 { # match url, string
- my ($string, $black_list) = @_;
- my @black_list = split ",", $black_list;
- foreach(@black_list) {
- return 1 if $string =~ /\Q$_\E/i;
- }
- return 0;
-}
-
-sub black_list2 { # match nick, server, channel; front to end
- my ($string, $black_list) = @_;
- my @black_list = split ",", $black_list;
- foreach(@black_list) {
- return 1 if $string =~ /^\Q$_\E\z/;
- }
- return 0;
-}
-
-sub uri_escape {
- my $url = shift;
- utf8::encode($url);
- $url =~ s/($Unsafe{RFC3986})/$escapes{$1}/ge;
- return $url;
-}
-
-sub service_url {
- my $url = shift;
- $url = uri_escape($url);
-
- if (weechat::config_string($config_options{'service'}) eq "durl") {
- $url = "http://durl.me/api/Create.do?longurl=$url";
- }
- elsif (weechat::config_string($config_options{'service'}) eq "is.gd") {
- $url = "http://is.gd/create.php?format=simple&url=$url";
- }
- elsif (weechat::config_string($config_options{'service'}) eq "ln-s") {
- $url = "http://ln-s.net/home/api.jsp?url=$url";
- }
- elsif (weechat::config_string($config_options{'service'}) eq "lytn") {
- $url = "http://lytn.it/api.php?rel=2&link=$url";
- }
- elsif (weechat::config_string($config_options{'service'}) eq "metamark") {
- $url = "http://metamark.net/api/rest/simple?long_url=$url";
- }
- elsif (weechat::config_string($config_options{'service'}) eq "punyURL") {
- $url = "http://services.sapo.pt/PunyURL/GetCompressedURLByURL?url=$url";
- }
- elsif (weechat::config_string($config_options{'service'}) eq "safe") {
- $url = "http://safe.mn/api/?format=text&url=$url";
- }
- else {
- $url = "http://tinyurl.com/api-create.php?url=$url";
- }
-
- return $url;
-}
-
-sub process_cb {
- my ($buffer_domain, $command, $return_code, $out, $err) = @_;
-
- if ($return_code != 0) { # weechat::WEECHAT_HOOK_PROCESS_ERROR
- weechat::print("", "Error with command: $command");
- weechat::print("", "An error occured: $err") if ($err ne "");
- weechat::print("", "ret code: $return_code");
- }
- elsif ($out) {
- my ($buffer, $domain) = split "_:_", $buffer_domain, 2;
- my $header = build_header();
- $domain = weechat::color(weechat::config_color($config_options{'domain_color'})) . "($domain)" . weechat::color("reset");
-
- if (weechat::config_string($config_options{'service'}) eq "durl") {
- ($out) = $out =~ m/(http:\/\/durl\.me\/\w+)/;
- }
- elsif (weechat::config_string($config_options{'service'}) eq "ln-s") {
- $out =~ s/^(\d{3}\s)|\n*$//g;
- }
- elsif (weechat::config_string($config_options{'service'}) eq "punyURL") {
- weechat::print("", "punyURL called");
- ($out) = $out =~ m/.+\<ascii\>(.+)\<\/ascii\>/;
- }
- elsif (weechat::config_string($config_options{'service'}) eq "safe") {
- $out =~ s/\n*//g;
- }
-
- my $short_url = weechat::color(weechat::config_color($config_options{'url_color'})) . $out . weechat::color("reset");
- my $tiny_url = weechat::config_string($config_options{'format'});
-
- $tiny_url =~ s/%H/$header/;
- $tiny_url =~ s/%U/$short_url/;
- $tiny_url =~ s/%D/$domain/;
- weechat::print($buffer, "$tiny_url");
- }
- return weechat::WEECHAT_RC_OK;
-}
-
-sub print_hook_cb {
- my ($data, $buffer, $date, $tags, $displayed, $highlight, $prefix, $msg) = @_;
- return weechat::WEECHAT_RC_OK if ($displayed != 1); # return if initial message wont be shown
-
- if ((weechat::config_string($config_options{'string_blacklist'})) ne "") { # check message against "string blacklist"
- return weechat::WEECHAT_RC_OK if (black_list1($msg, weechat::config_string($config_options{'string_blacklist'}))); # return if string is blacklisted
- }
-
- my $hdata = weechat::hdata_get("buffer");
- my $buffer_name = weechat::hdata_string($hdata, $buffer, "name");
- my ($server, $channel) = split /\./, $buffer_name; # can be done with a match
- $channel =~ s/#//;
-
- if ((weechat::config_string($config_options{'server_blacklist'})) ne "") { # check message against "server blacklist"
- return weechat::WEECHAT_RC_OK if (black_list2($server, weechat::config_string($config_options{'server_blacklist'}))); # return if server is blacklisted
- }
-
- if ((weechat::config_string($config_options{'channel_blacklist'})) ne "") { # check message against "channel blacklist"
- return weechat::WEECHAT_RC_OK if (black_list2($channel, weechat::config_string($config_options{'channel_blacklist'}))); # return if nick is blacklisted
- }
-
- ($incoming_nick = $tags) =~ s/.*nick_//i;
- $incoming_nick =~ s/,.*//i;
- my $own_nick = weechat::info_get("irc_nick", $server);
-
- if (!weechat::config_boolean($config_options{'convert_own'})) { # check if converting own
- return weechat::WEECHAT_RC_OK if $incoming_nick =~ /^\Q$own_nick\E\z/;
- }
-
- if ((weechat::config_string($config_options{'nick_blacklist'})) ne "") { # check message against "nick blacklist"
- return weechat::WEECHAT_RC_OK if (black_list2($incoming_nick, weechat::config_string($config_options{'nick_blacklist'}))); # return if nick is blacklisted
- }
-
- my @msg = split " ", $msg;
- foreach(@msg) {
- if ($_ =~ /^(ht|f)tp/ && $_ =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|) {
- next if (length($_) <= weechat::config_integer($config_options{'maximum_length'})); # skip if url shorter than max
-
- if (weechat::config_string($config_options{'url_blacklist'}) ne "") {
- next if (black_list1($_, weechat::config_string($config_options{'url_blacklist'}))); # skip if url is blacklisted
- }
- my $buffer_domain = $buffer."_:_$2";
- my $url = service_url($_);
-
- weechat::hook_process("url:$url", weechat::config_integer($config_options{'timeout'}) * 1000, "process_cb", $buffer_domain);
- }
- }
- return weechat::WEECHAT_RC_OK;
-}