aboutsummaryrefslogtreecommitdiffstats
path: root/history-search/frog_reload.pl
diff options
context:
space:
mode:
authorTom Feist <shabble@cowu.be>2010-07-24 17:23:13 +0000
committerTom Feist <shabble@cowu.be>2010-07-24 17:23:13 +0000
commit91f126ae4c9ea90336bdeb24001fadca79439edc (patch)
treed21b72a82b67b0979aadfa3f6efbbc2586d962b1 /history-search/frog_reload.pl
parentupdated script info to add my url and to change contact details to me (diff)
downloadirssi-scripts-91f126ae4c9ea90336bdeb24001fadca79439edc.tar.gz
irssi-scripts-91f126ae4c9ea90336bdeb24001fadca79439edc.zip
moved most tests to feature-tests/
Diffstat (limited to 'history-search/frog_reload.pl')
-rw-r--r--history-search/frog_reload.pl99
1 files changed, 0 insertions, 99 deletions
diff --git a/history-search/frog_reload.pl b/history-search/frog_reload.pl
deleted file mode 100644
index 678c87d..0000000
--- a/history-search/frog_reload.pl
+++ /dev/null
@@ -1,99 +0,0 @@
-use strict;
-use warnings;
-
-use Irssi;
-use File::ChangeNotify();
-use File::Spec ();
-use File::Basename qw(basename);
-
-#my $THIS_SCRIPT = basename __FILE__;
-
-my $irssi_dir = Irssi::get_irssi_dir();
-my @watch_dirs = ($irssi_dir, $irssi_dir . '/scripts',
- $irssi_dir . '/scripts/autorun');
-
-my $watcher = File::ChangeNotify->instantiate_watcher
- (
- directories => \@watch_dirs,
- filter => qr/\.(?:pl|py)$/,
- );
-
-my @watchers = File::ChangeNotify->usable_classes();
-print "Started reloader watching: ", join(", ", @watch_dirs), " using $watchers[0]";
-
-my %action_for = (
- create => sub {
- my ($path) = @_;
- Irssi::print ("CREATE: Loading $path");
- load_script($path);
- },
-
- modify => sub {
- my ($path) = @_;
- Irssi::print ("MODIFY: reloading $path");
- reload($path);
- },
-
- delete => sub {
- my ($path) = @_;
- Irssi::print ("DELETE: Unloading $path");
- unload_script($path);
- },
-);
-
-#TODO: change me back.
-Irssi::timeout_add(3000, \&timer_sub, undef);
-
-sub timer_sub {
- print "Timer sub called";
- my @new_events = $watcher->new_events;
- for my $event (@new_events) {
-
- print "Handling event: ", $event->type, " path: ", $event->path;
-
- if (my $callback = $action_for{$event->type}) {
- $callback->($event->path);
- }
- }
-}
-
-sub reload {
- my ($path) = @_;
-
- unload_script($path);
- load_script($path);
-}
-
-sub unload_script {
- my ($script_path) = @_;
- my $name = filepath_to_script($script_path);
-
- if (script_is_loaded($name)) {
- Irssi::print ("unloading $name...");
- Irssi::command("script unload $name");
- }
-}
-
-sub load_script {
- my ($script_path) = @_;
- Irssi::command("script load \"$script_path\"");
-}
-
-sub filepath_to_script {
- my ($path) = @_;
-
- my $name = basename $path;
- $name =~ s/\.pl$//i;
-
- return $name;
-}
-
-sub script_is_loaded {
- my $name = shift;
- print "Checking if $name is loaded";
- no strict 'refs';
- my $retval = defined %{ "Irssi::Script::${name}::" };
- use strict 'refs';
-
- return $retval;
-}