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.3 by root, Mon Jan 9 02:06:43 2006 UTC vs.
Revision 1.4 by root, Mon Jan 9 04:19:36 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 $self->msg ("Selection replaced by", $_);
50 }
33 } 51 }
34 }); 52 });
35 }; 53 };
36 54
37 for ($text) { 55 for ($text) {
44 and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ }); 62 and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ });
45 63
46 /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/ 64 /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/
47 and $add_button->("uri unescape" => sub { s/%([0-9a-fA-F]{2})/chr hex $1/ge }); 65 and $add_button->("uri unescape" => sub { s/%([0-9a-fA-F]{2})/chr hex $1/ge });
48 66
67 /[\\"'\ \t|&;<>()]/
68 and $add_button->("shell quote" => sub { $_ = "\Q$_" });
69
49 /^(http|ftp|telnet|irc|news):\// 70 /^(http|ftp|telnet|irc|news):\//
50 and $add_button->("run x-www-browser" => sub { system "x-www-browser \Q$_\E &" }); 71 and $add_button->("run x-www-browser" => sub { system "x-www-browser \Q$_\E &" });
51 } 72 }
52 73
53 $popup->show; 74 $popup->show;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines