From d285e7854dfc62c213bec4c101eaf080fa81ac46 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 12 Jan 2011 00:10:16 +0000 Subject: pipes: added an example feature test on how to use pipes for non-blocking IO. Hope to expand it to include network IO at some point. --- feature-tests/local_input_capture.pl | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 feature-tests/local_input_capture.pl (limited to 'feature-tests/local_input_capture.pl') diff --git a/feature-tests/local_input_capture.pl b/feature-tests/local_input_capture.pl new file mode 100644 index 0000000..847ff07 --- /dev/null +++ b/feature-tests/local_input_capture.pl @@ -0,0 +1,50 @@ +use strict; +use warnings; + + +use Irssi; +use Irssi::Irc; +use Irssi::TextUI; + +use Data::Dumper; + + +our $VERSION = '0.1'; +our %IRSSI = ( + authors => 'shabble', + contact => 'shabble+irssi@metavore.org', + name => '', + description => '', + license => 'Public Domain', + ); + +my $buffer = ''; +init(); + +sub init { + + Irssi::signal_add_first 'print text', 'sig_print_text'; + Irssi::command 'echo Hello there'; + Irssi::signal_remove 'print text', 'sig_print_text'; + Irssi::command_bind 'showbuf', 'cmd_showbuf'; +} + +sub cmd_showbuf { + my ($args, $server, $win_item) = @_; + my $win; + if (defined $win_item) { + $win = $win_item->window(); + } else { + $win = Irssi::active_win(); + } + + $win->print("buffer is: $buffer"); + $buffer = ''; +} + +sub sig_print_text { + my ($text_dest, $str, $stripped_str) = @_; + + $buffer .= $stripped_str; + Irssi::signal_stop; +} -- cgit v1.2.3