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.32 by root, Wed Jun 23 12:45:30 2021 UTC

2 2
3#:META:RESOURCE:url-launcher:string:shell command to use 3#:META:RESOURCE:url-launcher:string:shell command to use
4 4
5=head1 NAME 5=head1 NAME
6 6
7selection-popup (enabled by default) 7selection-popup - selection management pop-up
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
36sub msg { 37sub msg {
37 my ($self, $msg) = @_; 38 my ($self, $msg) = @_;
38 39
39 my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1); 40 my $overlay = $self->overlay (0, 0, $self->strwidth ($msg), 1);
40 $overlay->set (0, 0, $msg); 41 $overlay->set (0, 0, $msg);
41 my $iow; $iow = urxvt::timer->new->after (1)->cb (sub { 42 $self->{timer} = urxvt::timer->new->after (1)->cb (sub {
43 delete $self->{timer};
42 undef $overlay; 44 undef $overlay;
43 undef $iow;
44 }); 45 });
45} 46}
46 47
47sub on_start { 48sub on_start {
48 my ($self) = @_; 49 my ($self) = @_;
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