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