aboutsummaryrefslogtreecommitdiffstats
path: root/feature-tests/local_input_capture.pl
blob: 847ff0701ed42e8b9523017dd5d8efaecd36bfa0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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;
}