… | |
… | |
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 | my @patterns = ( |
|
|
13 | # urls, just a heuristic |
|
|
14 | qr{( |
|
|
15 | (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+ |
|
|
16 | [^.] # 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, |
|
|
28 | ); |
|
|
29 | |
12 | sub on_sel_extend { |
30 | sub on_sel_extend { |
13 | my ($self) = @_; |
31 | my ($self) = @_; |
14 | warn $self->selection; |
32 | |
|
|
33 | my ($row, $col) = $self->selection_mark; |
|
|
34 | my $line = $self->line ($row); |
|
|
35 | my $offset = $line->offset_of ($row, $col); |
|
|
36 | my $text = $line->t; |
|
|
37 | |
|
|
38 | for my $regex (@patterns) { |
|
|
39 | while ($text =~ /$regex/g) { |
|
|
40 | if ($-[1] <= $offset and $offset <= $+[1]) { |
|
|
41 | $self->selection_beg ($line->coord_of ($-[1])); |
|
|
42 | $self->selection_end ($line->coord_of ($+[1])); |
|
|
43 | return 1; |
|
|
44 | } |
|
|
45 | } |
|
|
46 | } |
|
|
47 | |
15 | () |
48 | () |
16 | } |
49 | } |