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.15 by root, Sun Jan 8 01:30:32 2006 UTC vs.
Revision 1.17 by root, Sun Jan 8 05:50:27 2006 UTC

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
9 () 9 ()
10} 10}
11 11
12# "find interetsing things"-patterns
12my @mark_patterns = ( 13my @mark_patterns = (
13 # urls, just a heuristic 14 # urls, just a heuristic
14 qr{( 15 qr{(
15 (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ 16 (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
16 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often 17 [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~] # do not include a trailing dot, its wrong too often
17 )}x, 18 )}x,
18 19
19 # common forms of quoting 20 # common "parentheses"
20 qr{(?:^|\s) [`] ([^‘`']+) ['] (?:\s|$)}x, 21 qr{(?:^|\s) ‘ ([^‘’]+?) ’ (?:\s|$)}x,
22 qr{(?:^|\s) ` ([^`']+?) ' (?:\s|$)}x,
23 qr{ \{ ([^{}]+?) \} }x,
24 qr{ \[ ([^{}]+?) \] }x,
21 25
22 # shell-like argument quoting 26 # shell-like argument quoting, basically always matches
23 qr{\G [\ \t|&;<>()] *( 27 qr{\G [\ \t|&;<>()] *(
24 (?: 28 (?:
25 [^\\"'\ \t|&;<>()]+ 29 [^\\"'\ \t|&;<>()]+
26 | \\. 30 | \\.
27 | " (?: [^\\"]+ | \\. )* " 31 | " (?: [^\\"]+ | \\. )* "
28 | ' [^']* ' 32 | ' [^']* '
29 )+ 33 )+
30 )}x, 34 )}x,
31); 35);
32 36
37# "correct obvious? crap"-patterns
33my @simplify_patterns = ( 38my @simplify_patterns = (
34 qr{^"([^\\"'\ \t|&;<>()*?]+)"$}, # "simple" => simple 39 qr{^"([^\\"'\ \t|&;<>()*?]+)"$}, # "simple" => simple
35 qr{^(.*)[,\-]$}, 40 qr{^(.*)[,\-]$}, # strip off trailing , and -
36); 41);
37 42
38sub on_sel_extend { 43sub on_sel_extend {
39 my ($self) = @_; 44 my ($self) = @_;
40 45
44 my $text = $line->t; 49 my $text = $line->t;
45 50
46 for my $regex (@mark_patterns) { 51 for my $regex (@mark_patterns) {
47 while ($text =~ /$regex/g) { 52 while ($text =~ /$regex/g) {
48 if ($-[1] <= $offset and $offset <= $+[1]) { 53 if ($-[1] <= $offset and $offset <= $+[1]) {
54 my $ofs = $-[1];
49 my $match = $1; 55 my $match = $1;
50 my ($ofs1, $ofs2) = ($-[1], $+[1]);
51 56
52 for my $regex (@simplify_patterns) { 57 for my $regex (@simplify_patterns) {
53 if ($match =~ $regex) { 58 if ($match =~ $regex) {
54 $match = $1; 59 $match = $1;
55 $ofs1 += $-[1]; 60 $ofs += $-[1];
56 $ofs2 = $ofs1 + length $match;
57 } 61 }
58 } 62 }
59 63
60 $self->selection_beg ($line->coord_of ($ofs1)); 64 $self->selection_beg ($line->coord_of ($ofs));
61 $self->selection_end ($line->coord_of ($ofs2)); 65 $self->selection_end ($line->coord_of ($ofs + length $match));
62 return 1; 66 return 1;
63 } 67 }
64 } 68 }
65 } 69 }
66 70

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines