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.8 by root, Tue Jan 3 20:47:36 2006 UTC vs.
Revision 1.14 by root, Fri Jan 6 20:50:58 2006 UTC

8 8
9 () 9 ()
10} 10}
11 11
12my @patterns = ( 12my @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,
21
22 # shell-like argument quoting
23 qr{\G [\ \t|&;<>()] *(
24 (?:
25 [^\\"'\ \t|&;<>()]+
26 | \\.
27 | " (?: [^\\"]+ | \\. )* "
28 | ' [^']* '
29 )+
30 )}x,
15); 31);
32
33my $x = "‘hallole’";
16 34
17sub on_sel_extend { 35sub on_sel_extend {
18 my ($self) = @_; 36 my ($self) = @_;
19 37
20 my ($row, $col) = $self->selection_mark; 38 my ($row, $col) = $self->selection_mark;
22 my $offset = $line->offset_of ($row, $col); 40 my $offset = $line->offset_of ($row, $col);
23 my $text = $line->t; 41 my $text = $line->t;
24 42
25 for my $regex (@patterns) { 43 for my $regex (@patterns) {
26 while ($text =~ /$regex/g) { 44 while ($text =~ /$regex/g) {
27 if ($-[0] <= $offset and $offset <= $+[0]) { 45 if ($-[1] <= $offset and $offset <= $+[1]) {
28 $self->selection_beg ($line->coord_of ($-[0])); 46 $self->selection_beg ($line->coord_of ($-[1]));
29 $self->selection_end ($line->coord_of ($+[0])); 47 $self->selection_end ($line->coord_of ($+[1]));
30 return 1; 48 return 1;
31 } 49 }
32 } 50 }
33 } 51 }
34 52

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines