… | |
… | |
3 | sub msg { |
3 | sub msg { |
4 | my ($self, $msg) = @_; |
4 | my ($self, $msg) = @_; |
5 | |
5 | |
6 | my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1); |
6 | my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1); |
7 | $overlay->set (0, 0, $msg); |
7 | $overlay->set (0, 0, $msg); |
8 | my $iow; $iow = urxvt::timer->new->start (urxvt::NOW + 1)->cb (sub { |
8 | my $iow; $iow = urxvt::timer->new->after (1)->cb (sub { |
9 | undef $overlay; |
9 | undef $overlay; |
10 | undef $iow; |
10 | undef $iow; |
11 | }); |
11 | }); |
12 | } |
12 | } |
13 | |
13 | |
… | |
… | |
18 | |
18 | |
19 | $self->grab_button (3, urxvt::ControlMask); |
19 | $self->grab_button (3, urxvt::ControlMask); |
20 | |
20 | |
21 | () |
21 | () |
22 | } |
22 | } |
23 | |
|
|
24 | our @hook; |
|
|
25 | |
23 | |
26 | sub on_button_press { |
24 | sub on_button_press { |
27 | my ($self, $event) = @_; |
25 | my ($self, $event) = @_; |
28 | |
26 | |
29 | if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) { |
27 | if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) { |
… | |
… | |
56 | } |
54 | } |
57 | }); |
55 | }); |
58 | }; |
56 | }; |
59 | |
57 | |
60 | for ($text) { |
58 | for ($text) { |
|
|
59 | /./ |
61 | $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ }); |
60 | and $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ }); |
|
|
61 | |
|
|
62 | /./ |
62 | $add_button->("eval perl expression" => sub { no warnings; $_ = eval $_ }); |
63 | and $add_button->("eval perl expression" => sub { no warnings; $_ = eval $_ }); |
|
|
64 | |
|
|
65 | /./ |
|
|
66 | and $add_button->((sprintf "to unicode hex index (%x)", ord) => sub { $_ = sprintf "%x", ord }); |
63 | |
67 | |
64 | /^(\S+):(\d+):?$/ |
68 | /^(\S+):(\d+):?$/ |
65 | and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ }); |
69 | and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ }); |
66 | |
70 | |
67 | /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/ |
71 | /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/ |
… | |
… | |
69 | |
73 | |
70 | /[\\"'\ \t|&;<>()]/ |
74 | /[\\"'\ \t|&;<>()]/ |
71 | and $add_button->("shell quote" => sub { $_ = "\Q$_" }); |
75 | and $add_button->("shell quote" => sub { $_ = "\Q$_" }); |
72 | |
76 | |
73 | /^(http|ftp|telnet|irc|news):\// |
77 | /^(http|ftp|telnet|irc|news):\// |
74 | and $add_button->("run $self->{browser}" => sub { urxvt::exec_async $self->{browser}, $_ }); |
78 | and $add_button->("run $self->{browser}" => sub { $self->exec_async ($self->{browser}, $_) }); |
75 | |
79 | |
76 | for my $hook (@hook) { |
80 | for my $hook (@{ $self->{term}{selection_popup_hook} || [] }) { |
77 | if (my ($title, $cb) = $hook->($popup)) { |
81 | if (my ($title, $cb) = $hook->($popup)) { |
78 | $add_button->($title, $cb); |
82 | $add_button->($title, $cb); |
79 | } |
83 | } |
80 | } |
84 | } |
81 | |
85 | |