AnyEvent-Mac-Pasteboard
view release on metacpan or search on metacpan
lib/AnyEvent/Mac/Pasteboard.pm view on Meta::CPAN
$on_change->($self->pbpaste());
$previous_content = $current_content;
$interval_idx = 0;
}
elsif ( $on_unchange && ref $on_unchange eq 'CODE' ) {
$on_unchange->($self->pbpaste());
}
};
if ( @interval == 1 ) {
$self->{timer} = AE::timer 0, $interval[0], $on_time_core;
}
else {
my $on_time; $on_time = sub {
$on_time_core->();
my $wait_sec = $interval_idx < @interval ? $interval[$interval_idx++] : $interval[-1];
$self->{timer} = AE::timer $wait_sec, 0, $on_time;
};
### On first initial run, hidden "on_unchange" callback.
### $on_unchange is lexical, so we can not "local"ize it.
my $on_unchange_stash = $on_unchange;
$on_unchange = undef;
$on_time->();
$on_unchange = $on_unchange_stash;
}
t/01_construct.t view on Meta::CPAN
my $content = shift;
#say "on_unchange execute";
#say qq(content is "$content");
},
on_error => sub {
#say "on_error execute. throw process.";
$cv->send;
},
], "interval arrayref that contains some digits version");
my $timeout = AE::timer $TIMEOUT_SEC, 0, sub { $cv->send(); };
$cv->recv;
t/02_changing.t view on Meta::CPAN
my $dictionary_idx = 0;
my $system_pbcopy_cb = sub {
my $word = encode('utf-8', $dictionary[ $dictionary_idx++ % @dictionary ]);
system(qq{printf "$word" | pbcopy});
};
$system_pbcopy_cb->(); # initialize at first.
sleep 1;
my $pbpaste_system_tick = AE::timer 0, 0.3, $system_pbcopy_cb;
my $error = $cv->recv();
if ( $error ) {
fail($error);
}
### revert pasteboard content.
if ( open my $fh, '<', $tmp_filename ) {
my $pb_content = do { local $/; <$fh>; };
( run in 1.107 second using v1.01-cache-2.11-cpan-49f99fa48dc )