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.13 by root, Wed Jan 18 11:05:09 2006 UTC vs.
Revision 1.25 by root, Wed Jun 6 15:06:41 2012 UTC

1#! perl 1#! perl
2
3#:META:X_RESOURCE:url-launcher:string:shell command to use
2 4
3sub msg { 5sub msg {
4 my ($self, $msg) = @_; 6 my ($self, $msg) = @_;
5 7
6 my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1); 8 my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1);
12} 14}
13 15
14sub on_start { 16sub on_start {
15 my ($self) = @_; 17 my ($self) = @_;
16 18
17 $self->{browser} = $self->x_resource ("urlLauncher") || "x-www-browser"; 19 $self->{browser} = $self->x_resource ("url-launcher") || "sensible-browser";
18 20
19 $self->grab_button (3, urxvt::ControlMask); 21 $self->grab_button (3, urxvt::ControlMask);
20 22
21 () 23 ()
22} 24}
23
24our @hook;
25 25
26sub on_button_press { 26sub on_button_press {
27 my ($self, $event) = @_; 27 my ($self, $event) = @_;
28 28
29 if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) { 29 if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) {
56 } 56 }
57 }); 57 });
58 }; 58 };
59 59
60 for ($text) { 60 for ($text) {
61 $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ }); 61 /\n/
62 $add_button->("eval perl expression" => sub { no warnings; $_ = eval $_ }); 62 and $add_button->("newlines to spaces" => sub { y/\n/ / });
63 63
64 /./
65 and $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ });
66
67 /./
68 and $add_button->("eval perl expression" => sub { my $self = $self; no warnings; $_ = eval $_; $_ = "$@" if $@ });
69
70 /./
71 and $add_button->((sprintf "to unicode hex index (%x)", ord) => sub { $_ = sprintf "%x", ord });
72
64 /^(\S+):(\d+):?$/ 73 /(\S+):(\d+):?/
65 and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ }); 74 and $add_button->("vi-commands to load '$1'" => sub { s/^(\S+):(\d+):?$/\x1b:e $1\x0d:$2\x0d/ });
66 75
67 /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/ 76 /%[0-9a-fA-F]{2}/ && !/%[^0-9a-fA-F]/ && !/%.[^0-9a-fA-F]/
68 and $add_button->("uri unescape" => sub { s/%([0-9a-fA-F]{2})/chr hex $1/ge }); 77 and $add_button->("uri unescape" => sub { s/%([0-9a-fA-F]{2})/chr hex $1/ge });
69 78
70 /[\\"'\ \t|&;<>()]/ 79 /[\\"'\ \t|&;<>()]/
71 and $add_button->("shell quote" => sub { $_ = "\Q$_" }); 80 and $add_button->("shell quote" => sub { $_ = "\Q$_" });
72 81
73 /^(http|ftp|telnet|irc|news):\// 82 /^(https?|ftp|telnet|irc|news):\//
74 and $add_button->("run $self->{browser}" => sub { urxvt::exec_async $self->{browser}, $_ }); 83 and $add_button->("run $self->{browser}" => sub { $self->exec_async ($self->{browser}, $_) });
75 84
76 for my $hook (@hook) { 85 for my $hook (@{ $self->{term}{selection_popup_hook} || [] }) {
77 if (my ($title, $cb) = $hook->($popup)) { 86 if (my ($title, $cb) = $hook->($popup)) {
78 $add_button->($title, $cb); 87 $add_button->($title, $cb);
79 } 88 }
80 } 89 }
81 90

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines