--- rxvt-unicode/src/perl/selection 2006/01/03 20:47:36 1.8 +++ rxvt-unicode/src/perl/selection 2006/01/03 21:36:15 1.10 @@ -10,8 +10,21 @@ } my @patterns = ( - # urls - qr{ ([a-z0-9.+\-]+://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+) }x, + # urls, just a heuristic + qr{( + (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+ + [^.] # do not include a trailing dot, its wrong too often + )}x, + + # shell-like argument quoting + qr{\G\s*( + (?: + [^"'\\ \t]+ + | \\. + | " ([^\\"]+ | \\. )* " + | ' [^']* ' + )+ + )}xs, ); sub on_sel_extend { @@ -24,9 +37,9 @@ for my $regex (@patterns) { while ($text =~ /$regex/g) { - if ($-[0] <= $offset and $offset <= $+[0]) { - $self->selection_beg ($line->coord_of ($-[0])); - $self->selection_end ($line->coord_of ($+[0])); + if ($-[1] <= $offset and $offset <= $+[1]) { + $self->selection_beg ($line->coord_of ($-[1])); + $self->selection_end ($line->coord_of ($+[1])); return 1; } }