summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-03-05 22:24:17 -0600
committerJesse Luehrs <doy@tozt.net>2012-03-05 22:24:17 -0600
commit35e015fd125c305380291b44086d4781d41a5e76 (patch)
treed6e6acb946f05f7f5b8ffd166a3eef5c14f6ba44
parentbff4ae8c083ad3747d31b013b37779f8ed73cfd0 (diff)
downloadterm-filter-35e015fd125c305380291b44086d4781d41a5e76.tar.gz
term-filter-35e015fd125c305380291b44086d4781d41a5e76.zip
add remove_input_handle method
-rw-r--r--lib/Term/Filter.pm26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/Term/Filter.pm b/lib/Term/Filter.pm
index e82c94e..3f161a1 100644
--- a/lib/Term/Filter.pm
+++ b/lib/Term/Filter.pm
@@ -77,15 +77,21 @@ sub _build_output { \*STDOUT }
=cut
+=method remove_input_handle
+
+=cut
+
has input_handles => (
traits => ['Array'],
isa => 'ArrayRef[FileHandle]',
lazy => 1,
init_arg => undef,
builder => '_build_input_handles',
+ writer => '_set_input_handles',
handles => {
- input_handles => 'elements',
- add_input_handle => 'push',
+ input_handles => 'elements',
+ add_input_handle => 'push',
+ _grep_input_handles => 'grep',
},
);
@@ -94,6 +100,15 @@ sub _build_input_handles {
[ $self->input, $self->pty ]
}
+sub remove_input_handle {
+ my $self = shift;
+ my ($fh) = @_;
+ $self->_set_input_handles(
+ [ $self->_grep_input_handles(sub { $_ != $fh }) ]
+ );
+ $self->_clear_select;
+}
+
=attr pty
=cut
@@ -108,10 +123,11 @@ has pty => (
sub _build_pty { IO::Pty::Easy->new(raw => 0) }
has _select => (
- is => 'ro',
- isa => 'IO::Select',
- lazy => 1,
+ is => 'ro',
+ isa => 'IO::Select',
+ lazy => 1,
builder => '_build_select',
+ clearer => '_clear_select',
);
sub _build_select {