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.9 by root, Tue Jan 3 21:08:39 2006 UTC vs.
Revision 1.15 by root, Sun Jan 8 01:30:32 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
12my @patterns = ( 12my @mark_patterns = (
13 # urls 13 # urls, just a heuristic
14 qr{ ([a-z0-9.+\-]+://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+) }x, 14 qr{(
15 (?: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 )}x,
18
19 # common forms of quoting
20 qr{(?:^|\s) [‘`] ([^‘`’']+) [’'] (?:\s|$)}x,
15 21
16 # shell-like argument quoting 22 # shell-like argument quoting
17 qr{\G\s*( 23 qr{\G [\ \t|&;<>()] *(
18 (?: 24 (?:
19 [^"'\\ \t]+ 25 [^\\"'\ \t|&;<>()]+
20 | \\. 26 | \\.
21 | " ([^\\"]+ | \\. )* " 27 | " (?: [^\\"]+ | \\. )* "
22 | ' [^']* ' 28 | ' [^']* '
23 )+ 29 )+
24 )}xs, 30 )}x,
31);
32
33my @simplify_patterns = (
34 qr{^"([^\\"'\ \t|&;<>()*?]+)"$}, # "simple" => simple
35 qr{^(.*)[,\-]$},
25); 36);
26 37
27sub on_sel_extend { 38sub on_sel_extend {
28 my ($self) = @_; 39 my ($self) = @_;
29 40
30 my ($row, $col) = $self->selection_mark; 41 my ($row, $col) = $self->selection_mark;
31 my $line = $self->line ($row); 42 my $line = $self->line ($row);
32 my $offset = $line->offset_of ($row, $col); 43 my $offset = $line->offset_of ($row, $col);
33 my $text = $line->t; 44 my $text = $line->t;
34 45
35 for my $regex (@patterns) { 46 for my $regex (@mark_patterns) {
36 while ($text =~ /$regex/g) { 47 while ($text =~ /$regex/g) {
37 if ($-[1] <= $offset and $offset <= $+[1]) { 48 if ($-[1] <= $offset and $offset <= $+[1]) {
49 my $match = $1;
50 my ($ofs1, $ofs2) = ($-[1], $+[1]);
51
52 for my $regex (@simplify_patterns) {
53 if ($match =~ $regex) {
54 $match = $1;
55 $ofs1 += $-[1];
56 $ofs2 = $ofs1 + length $match;
57 }
58 }
59
38 $self->selection_beg ($line->coord_of ($-[1])); 60 $self->selection_beg ($line->coord_of ($ofs1));
39 $self->selection_end ($line->coord_of ($+[1])); 61 $self->selection_end ($line->coord_of ($ofs2));
40 return 1; 62 return 1;
41 } 63 }
42 } 64 }
43 } 65 }
44 66

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines