ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/confirm-paste
(Generate patch)

Comparing rxvt-unicode/src/perl/confirm-paste (file contents):
Revision 1.1 by sf-exg, Sat Jul 24 13:04:27 2010 UTC vs.
Revision 1.7 by root, Tue Sep 4 22:41:11 2012 UTC

1#! perl 1#! perl
2
3=head1 NAME
4
5confirm-paste - ask for confirmation before pasting multiline text
6
7=head1 DESCRIPTION
8
9Displays a confirmation dialog when a paste containing at least a full
10line is detected.
11
12=cut
2 13
3sub msg { 14sub msg {
4 my ($self, $msg) = @_; 15 my ($self, $msg) = @_;
5 16
6 $self->{overlay} = $self->overlay (0, -1, $self->strwidth ($msg), 1); 17 $self->{overlay} = $self->overlay (0, -1, $self->ncol, 2, urxvt::OVERLAY_RSTYLE, 0);
7 $self->{overlay}->set (0, 0, $msg); 18 $self->{overlay}->set (0, 0, $msg);
8} 19}
9 20
10sub on_tt_paste { 21sub on_tt_paste {
11 my ($self, $str) = @_; 22 my ($self, $str) = @_;
14 25
15 return unless $count; 26 return unless $count;
16 27
17 $self->{paste} = \$str; 28 $self->{paste} = \$str;
18 $self->msg ("Paste of $count lines, continue? (y/n)"); 29 $self->msg ("Paste of $count lines, continue? (y/n)");
30 my $preview = substr $self->locale_decode ($str), 0, $self->ncol;
31 $preview =~ s/\n/\\n/g;
32 $self->{overlay}->set (0, 1, $self->special_encode ($preview));
19 $self->enable (key_press => \&key_press); 33 $self->enable (key_press => \&key_press);
20 34
21 1 35 1
22} 36}
23 37

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines