1 |
#! perl |
2 |
|
3 |
sub msg { |
4 |
my ($self, $msg) = @_; |
5 |
|
6 |
$self->{overlay} = $self->overlay (0, -1, $self->strwidth ($msg), 1); |
7 |
$self->{overlay}->set (0, 0, $msg); |
8 |
} |
9 |
|
10 |
sub on_tt_paste { |
11 |
my ($self, $str) = @_; |
12 |
|
13 |
my $count = ($str =~ tr/\012\015//); |
14 |
|
15 |
return unless $count; |
16 |
|
17 |
$self->{paste} = \$str; |
18 |
$self->msg ("Paste of $count lines, continue? (y/n)"); |
19 |
$self->enable (key_press => \&key_press); |
20 |
|
21 |
1 |
22 |
} |
23 |
|
24 |
sub leave { |
25 |
my ($self) = @_; |
26 |
|
27 |
$self->{paste} = undef; |
28 |
delete $self->{overlay}; |
29 |
$self->disable ("key_press"); |
30 |
} |
31 |
|
32 |
sub key_press { |
33 |
my ($self, $event, $keysym, $string) = @_; |
34 |
|
35 |
if ($keysym == 121) { # y |
36 |
$self->tt_paste (${$self->{paste}}); |
37 |
$self->leave; |
38 |
} elsif ($keysym == 110) { # n |
39 |
$self->leave; |
40 |
} |
41 |
|
42 |
1 |
43 |
} |