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.1 by root, Mon Jan 9 00:34:36 2006 UTC vs.
Revision 1.5 by root, Mon Jan 9 06:29:47 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines