repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 8398508cc93b63f6a9235795105a5c3e6f6ca460: path_to: revision_to:
commit 8398508cc93b63f6a9235795105a5c3e6f6ca460 Author: Emanuele GiaquintaDate: Sat Jul 24 13:04:27 2010 +0000 Add confirm-paste script. diff --git a/Changes b/Changes
--- a/Changes +++ b/Changes @@ -21,6 +21,7 @@ TODO: perl-shell-window? perl-unix-socket? TODO: - upgrade to libev-4.00. + - new perl extension "confirm-paste" (Emanuele Giaquinta). - new on_tt_paste perl hook and tt_paste perl binding (Emanuele Giaquinta). - fix utmpx detection on upcoming FreeBSD 9. - Use COMPOUND_TEXT encoding for WM_NAME/WM_ICON_NAME value when it diff --git a/MANIFEST b/MANIFEST
--- a/MANIFEST
+++ b/MANIFEST
@@ -165,6 +165,7 @@ src/perl/digital-clock
src/perl/macosx-clipboard
src/perl/macosx-clipboard-native
src/perl/overlay-osc
+src/perl/confirm-paste
libev/ev.h
libev/ev++.h
diff --git a/src/perl/confirm-paste b/src/perl/confirm-paste
new file mode 100644
index 0000000000000000000000000000000000000000..2b8771ec5928927c1f46d2bea68e5d559dd0459f
--- /dev/null
+++ b/src/perl/confirm-paste
@@ -0,0 +1,43 @@
+#! perl
+
+sub msg {
+ my ($self, $msg) = @_;
+
+ $self->{overlay} = $self->overlay (0, -1, $self->strwidth ($msg), 1);
+ $self->{overlay}->set (0, 0, $msg);
+}
+
+sub on_tt_paste {
+ my ($self, $str) = @_;
+
+ my $count = ($str =~ tr/\012\015//);
+
+ return unless $count;
+
+ $self->{paste} = \$str;
+ $self->msg ("Paste of $count lines, continue? (y/n)");
+ $self->enable (key_press => \&key_press);
+
+ 1
+}
+
+sub leave {
+ my ($self) = @_;
+
+ $self->{paste} = undef;
+ delete $self->{overlay};
+ $self->disable ("key_press");
+}
+
+sub key_press {
+ my ($self, $event, $keysym, $string) = @_;
+
+ if ($keysym == 121) { # y
+ $self->tt_paste (${$self->{paste}});
+ $self->leave;
+ } elsif ($keysym == 110) { # n
+ $self->leave;
+ }
+
+ 1
+}
diff --git a/src/urxvt.pm b/src/urxvt.pm
--- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -395,6 +395,11 @@ Displays a very simple digital clock in the upper right corner of the window. Illustrates overwriting the refresh callbacks to create your own overlays or changes. +=item confirm-paste + +Displays a confirmation dialog when a paste containing at least a full +line is detected. + =back =head1 API DOCUMENTATION
-----END OF PAGE-----