diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-03-06 01:07:07 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-03-06 01:08:20 -0600 |
commit | 0af0e74c701d229484c491af52dc20ae4b29e552 (patch) | |
tree | 73df4e23df7fc195f76361c842c7109486563db8 /lib/Term/Filter | |
parent | 5b5f95a7da3d31ba815d139f146ad2adebe71b58 (diff) | |
download | term-filter-0af0e74c701d229484c491af52dc20ae4b29e552.tar.gz term-filter-0af0e74c701d229484c491af52dc20ae4b29e552.zip |
documentation
Diffstat (limited to 'lib/Term/Filter')
-rw-r--r-- | lib/Term/Filter/Callback.pm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Term/Filter/Callback.pm b/lib/Term/Filter/Callback.pm index 4a32352..d5920a0 100644 --- a/lib/Term/Filter/Callback.pm +++ b/lib/Term/Filter/Callback.pm @@ -6,12 +6,43 @@ with 'Term::Filter'; =head1 SYNOPSIS + use Term::Filter::Callback; + + my $term = Term::Filter::Callback->new( + callbacks => { + munge_input => sub { + my $self = shift; + my ($got) = @_; + $got =~ s/\ce/E- Elbereth\n/g; + $got; + }, + munge_output => sub { + my $self = shift; + my ($got) = @_; + $got =~ s/(Elbereth)/\e[35m$1\e[m/g; + $got; + }, + }, + ); + + $term->run('nethack'); + =head1 DESCRIPTION +This module provides a callback-based API to L<Term::Filter>. The desired +callbacks can just be passed into the constructor of this class, rather than +requiring a new class to be manually defined. This class consumes the +L<Term::Filter> role, so the rest of the documentation in that module applies +here. + =cut =attr callbacks +A hashref of callbacks for L<Term::Filter>. The keys are +L<callback names|Term::Filter/CALLBACKS> and the values are coderefs to call +for those callbacks. + =cut has callbacks => ( |