ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/selection
(Generate patch)

Comparing rxvt-unicode/src/perl/selection (file contents):
Revision 1.34 by root, Mon Jan 23 23:13:03 2006 UTC vs.
Revision 1.38 by root, Sat May 20 18:17:38 2006 UTC

1#! perl 1#! perl
2 2
3sub on_keyboard_command { 3sub on_user_command {
4 my ($self, $cmd) = @_; 4 my ($self, $cmd) = @_;
5 5
6 $cmd eq "selection:rot13" 6 $cmd eq "selection:rot13"
7 and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection); 7 and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection);
8 8
10} 10}
11 11
12sub on_init { 12sub on_init {
13 my ($self) = @_; 13 my ($self) = @_;
14 14
15 if (defined (my $res = $self->resource ("cutchars"))) {
16 $res = $self->locale_decode ($res);
17 push @{ $self->{patterns} }, qr{\G [\Q$res\E[:space:]]* ([^\Q$res\E[:space:]]+) }x;
18 }
19
15 for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) { 20 for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) {
16 $res = $self->locale_decode ($res); 21 $res = $self->locale_decode ($res);
17 utf8::encode $res; 22 utf8::encode $res;
18 push @{ $self->{patterns} }, qr/$res/; 23 push @{ $self->{patterns} }, qr/$res/;
19 } 24 }
25
26 $self->{enabled} = 1;
27
28 push @{ $self->{term}{option_popup_hook} }, sub {
29 ("new selection" => $self->{enabled}, sub { $self->{enabled} = shift })
30 };
20 31
21 () 32 ()
22} 33}
23 34
24# "find interesting things"-patterns 35# "find interesting things"-patterns
33 qr{ \[ ([^{}[:space:]]+) \] }x, 44 qr{ \[ ([^{}[:space:]]+) \] }x,
34 qr{ \( ([^()[:space:]]+) \) }x, 45 qr{ \( ([^()[:space:]]+) \) }x,
35 46
36 # urls, just a heuristic 47 # urls, just a heuristic
37 qr{( 48 qr{(
38 (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ 49 (?:https?://|ftp://|news://|mailto:|file://)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
39 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) 50 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic)
40 )}x, 51 )}x,
41 52
42 # shell-like argument quoting, basically always matches 53 # shell-like argument quoting, basically always matches
43 qr{\G [\ \t|&;<>()]* ( 54 qr{\G [\ \t|&;<>()]* (
56 qr{^(.*)[,\-]$}, # strip off trailing , and - 67 qr{^(.*)[,\-]$}, # strip off trailing , and -
57); 68);
58 69
59sub on_sel_extend { 70sub on_sel_extend {
60 my ($self, $time) = @_; 71 my ($self, $time) = @_;
72
73 $self->{enabled}
74 or return;
61 75
62 my ($row, $col) = $self->selection_mark; 76 my ($row, $col) = $self->selection_mark;
63 my $line = $self->line ($row); 77 my $line = $self->line ($row);
64 my $text = $line->t; 78 my $text = $line->t;
65 my $markofs = $line->offset_of ($row, $col); 79 my $markofs = $line->offset_of ($row, $col);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines