summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-27 16:35:35 -0400
committerJesse Luehrs <doy@tozt.net>2013-06-27 16:35:35 -0400
commit90ec7c86880fbd5ecc3ab09b111194a90c0ab06a (patch)
tree07654e3b503fcbf5a909f75b8986b305532a9299
parentb4ec08d4bd0c77aefc7b450afbeba510b2e533bd (diff)
downloadreply-90ec7c86880fbd5ecc3ab09b111194a90c0ab06a.tar.gz
reply-90ec7c86880fbd5ecc3ab09b111194a90c0ab06a.zip
turn this into a generic pub/sub mechanism
-rw-r--r--lib/Reply.pm6
-rw-r--r--lib/Reply/Plugin/ReadLine.pm6
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/Reply.pm b/lib/Reply.pm
index e1e31d2..57e9166 100644
--- a/lib/Reply.pm
+++ b/lib/Reply.pm
@@ -194,7 +194,7 @@ sub _load_plugin {
$plugin = $plugin->new(
%$opts,
- tab_handler => sub { $weakself->_tab_handler(@_) },
+ publisher => sub { $weakself->_publish(@_) },
);
}
@@ -261,10 +261,10 @@ sub _loop {
$self->_chained_plugin('loop', 1);
}
-sub _tab_handler {
+sub _publish {
my $self = shift;
- $self->_concatenate_plugin('tab_handler', @_);
+ $self->_concatenate_plugin(@_);
}
sub _wrapped_plugin {
diff --git a/lib/Reply/Plugin/ReadLine.pm b/lib/Reply/Plugin/ReadLine.pm
index f4ef2cd..757ea53 100644
--- a/lib/Reply/Plugin/ReadLine.pm
+++ b/lib/Reply/Plugin/ReadLine.pm
@@ -37,7 +37,7 @@ sub new {
my $self = $class->SUPER::new(@_);
$self->{term} = Term::ReadLine->new('Reply');
- $self->{tab_handler} = $opts{tab_handler};
+ $self->{publisher} = $opts{publisher};
my $history = $opts{history_file} || '.reply_history';
$self->{history_file} = File::Spec->catfile(
(File::Spec->file_name_is_absolute($history)
@@ -91,7 +91,7 @@ sub _register_tab_complete {
my $self = shift;
my $term = $self->{term};
- my $completion_handler = $self->{tab_handler};
+ my $publisher = $self->{publisher};
if ($term->ReadLine eq 'Term::ReadLine::Gnu') {
$term->Attribs->{attempted_completion_function} = sub {
@@ -100,7 +100,7 @@ sub _register_tab_complete {
# discard everything after the cursor for completion purposes
substr($line, $end) = '';
- my @matches = $completion_handler->($line);
+ my @matches = $publisher->('tab_handler', $line);
my $match_index = 0;
return $term->completion_matches($text, sub {