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

Comparing rxvt-unicode/src/perl/selection-popup (file contents):
Revision 1.2 by root, Mon Jan 9 01:21:43 2006 UTC vs.
Revision 1.7 by root, Mon Jan 9 19:25:57 2006 UTC

1#! perl 1#! perl
2
3sub msg {
4 my ($self, $msg) = @_;
5
6 my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1);
7 $overlay->set (0, 0, $msg);
8 my $iow; $iow = urxvt::timer->new->start (urxvt::NOW + 1)->cb (sub {
9 undef $overlay;
10 undef $iow;
11 });
12}
2 13
3sub on_start { 14sub on_start {
4 my ($self) = @_; 15 my ($self) = @_;
5 16
6 $self->grab_button (3, urxvt::ControlMask); 17 $self->grab_button (3, urxvt::ControlMask);
26 my $add_button = sub { 37 my $add_button = sub {
27 my ($title, $cb) = @_; 38 my ($title, $cb) = @_;
28 39
29 $popup->add_button ($title => sub { 40 $popup->add_button ($title => sub {
30 for ($text) { 41 for ($text) {
42 my $orig = $_;
31 $cb->(); 43 $cb->();
44
45 if ($orig ne $_) {
32 $self->selection ($_); 46 $self->selection ($_);
47 s/[\x00-\x1f\x80-\x9f]/ยท/g;
48 $self->msg ($self->special_encode ($_));
49 }
33 } 50 }
34 }); 51 });
35 }; 52 };
36 53
37 for ($text) { 54 for ($text) {
38 $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ }); 55 $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ });
39 56
57 urxvt::safe
58 and $add_button->("eval perl expression" => sub { no warnings; $_ = eval urxvt::untaint $_ });
59
40 /^(\S+):(\d+):?$/ 60 /^(\S+):(\d+):?$/
41 and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ }); 61 and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ });
42 62
43 /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/ 63 /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/
44 and $add_button->("uri unescape" => sub { s/%([0-9a-fA-F]{2})/chr hex $1/ge }); 64 and $add_button->("uri unescape" => sub { s/%([0-9a-fA-F]{2})/chr hex $1/ge });
65
66 /[\\"'\ \t|&;<>()]/
67 and $add_button->("shell quote" => sub { $_ = "\Q$_" });
45 68
46 /^(http|ftp|telnet|irc|news):\// 69 /^(http|ftp|telnet|irc|news):\//
47 and $add_button->("run x-www-browser" => sub { system "x-www-browser \Q$_\E &" }); 70 and $add_button->("run x-www-browser" => sub { system "x-www-browser \Q$_\E &" });
48 } 71 }
49 72

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines