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.29 by root, Sat May 17 13:38:23 2014 UTC vs.
Revision 1.30 by sf-exg, Fri May 23 20:51:15 2014 UTC

6 6
7selection-popup (enabled by default) 7selection-popup (enabled by default)
8 8
9=head1 DESCRIPTION 9=head1 DESCRIPTION
10 10
11Binds a popup menu to Ctrl-Button3 that lets you convert the selection 11Binds a popup menu to Ctrl-Button3 that lets you paste the X
12text into various other formats/action (such as uri unescaping, perl 12selections and either modify or use the internal selection text in
13various ways (such as uri unescaping, perl evaluation, web-browser
13evaluation, web-browser starting etc.), depending on content. 14starting etc.), depending on content.
14 15
15Other extensions can extend this popup menu by pushing a code reference 16Other extensions can extend this popup menu by pushing a code reference
16onto C<< @{ $term->{selection_popup_hook} } >>, which gets called whenever 17onto C<< @{ $term->{selection_popup_hook} } >>, which gets called whenever
17the popup is being displayed. 18the popup is being displayed.
18 19
59 60
60 if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) { 61 if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) {
61 my $popup = $self->popup ($event) 62 my $popup = $self->popup ($event)
62 or return 1; 63 or return 1;
63 64
64 $popup->add_title ("Convert Selection"); 65 $popup->add_title ("Selection");
65 66
66 my $text = $self->selection; 67 my $text = $self->selection;
67 68
68 my $title = $text; 69 my $title = $text;
69 $title =~ s/[\x00-\x1f\x80-\x9f]/·/g; 70 $title =~ s/[\x00-\x1f\x80-\x9f]/·/g;
88 }); 89 });
89 }; 90 };
90 91
91 for ($text) { 92 for ($text) {
92 /\n/ 93 /\n/
94 and $add_button->("paste primary selection" => sub { $self->selection_request (urxvt::CurrentTime, 1) });
95
96 /./
97 and $add_button->("paste clipboard selection" => sub { $self->selection_request (urxvt::CurrentTime, 3) });
98
99 /./
100 and $add_button->("copy selection to clipboard" => sub { $self->selection ($self->selection, 1);
101 $self->selection_grab (urxvt::CurrentTime, 1) });
102
103 /./
93 and $add_button->("newlines to spaces" => sub { y/\n/ / }); 104 and $add_button->("newlines to spaces" => sub { y/\n/ / });
94 105
95 /./ 106 /./
96 and $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ }); 107 and $add_button->("rot13" => sub { y/A-Za-z/N-ZA-Mn-za-m/ });
97 108

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines