1 | #! perl |
1 | #! perl |
|
|
2 | |
|
|
3 | sub 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 | |
3 | sub on_start { |
16 | sub 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) { |
… | |
… | |
44 | 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/ }); |
45 | |
64 | |
46 | /%[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]/ |
47 | 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 }); |
48 | |
67 | |
|
|
68 | /[\\"'\ \t|&;<>()]/ |
|
|
69 | and $add_button->("shell quote" => sub { $_ = "\Q$_" }); |
|
|
70 | |
49 | /^(http|ftp|telnet|irc|news):\// |
71 | /^(http|ftp|telnet|irc|news):\// |
50 | 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 &" }); |
51 | } |
73 | } |
52 | |
74 | |
53 | $popup->show; |
75 | $popup->show; |