ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/confirm-paste
Revision: 1.4
Committed: Wed Mar 9 19:32:03 2011 UTC (13 years, 2 months ago) by sf-exg
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_15, rel-9_14, rel-9_12, rel-9_11
Changes since 1.3: +3 -2 lines
Log Message:
In confirm-paste, do not unnecessarily copy the whole data for preview
and 'special_encode' the preview string as required by $overlay->set.

File Contents

# Content
1 #! perl
2
3 sub msg {
4 my ($self, $msg) = @_;
5
6 $self->{overlay} = $self->overlay (0, -1, $self->ncol, 2, urxvt::OVERLAY_RSTYLE, 0);
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 my $preview = substr $self->locale_decode ($str), 0, $self->ncol;
20 $preview =~ s/\n/\\n/g;
21 $self->{overlay}->set (0, 1, $self->special_encode ($preview));
22 $self->enable (key_press => \&key_press);
23
24 1
25 }
26
27 sub leave {
28 my ($self) = @_;
29
30 $self->{paste} = undef;
31 delete $self->{overlay};
32 $self->disable ("key_press");
33 }
34
35 sub key_press {
36 my ($self, $event, $keysym, $string) = @_;
37
38 if ($keysym == 121) { # y
39 $self->tt_paste (${$self->{paste}});
40 $self->leave;
41 } elsif ($keysym == 110) { # n
42 $self->leave;
43 }
44
45 1
46 }