… | |
… | |
9 | () |
9 | () |
10 | } |
10 | } |
11 | |
11 | |
12 | # "find interetsing things"-patterns |
12 | # "find interetsing things"-patterns |
13 | my @mark_patterns = ( |
13 | my @mark_patterns = ( |
14 | qr{([[:alnum:]]+)}, |
14 | qr{([[:word:]]+)}, |
15 | |
15 | |
16 | # common "parentheses" |
16 | # common "parentheses" |
17 | qr{(?:^|\s) ‘ ([^‘’]+?) ’ (?:\s|\)|$)}x, |
17 | qr{(?:^|\s) ‘ ([^‘’]+?) ’ (?:\s|\)|$)}x, |
18 | qr{(?:^|\s) ` ([^`']+?) ' (?:\s|\)|$)}x, |
18 | qr{(?:^|\s) ` ([^`']+?) ' (?:\s|\)|$)}x, |
19 | qr{ \{ ([^{}]+?) \} }x, |
19 | qr{ \{ ([^{}]+?) \} }x, |
20 | qr{ \[ ([^{}]+?) \] }x, |
20 | qr{ \[ ([^{}]+?) \] }x, |
|
|
21 | qr{ \( ([^()]+?) \) }x, |
21 | |
22 | |
22 | # urls, just a heuristic |
23 | # urls, just a heuristic |
23 | qr{( |
24 | qr{( |
24 | (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ |
25 | (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ |
25 | [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) |
26 | [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) |
… | |
… | |
41 | qr{^"([^\\"'\ \t|&;<>()*?]+)"$}, # "simple" => simple |
42 | qr{^"([^\\"'\ \t|&;<>()*?]+)"$}, # "simple" => simple |
42 | qr{^(.*)[,\-]$}, # strip off trailing , and - |
43 | qr{^(.*)[,\-]$}, # strip off trailing , and - |
43 | ); |
44 | ); |
44 | |
45 | |
45 | sub on_sel_extend { |
46 | sub on_sel_extend { |
46 | my ($self) = @_; |
47 | my ($self, $time) = @_; |
47 | |
48 | |
48 | my ($row, $col) = $self->selection_mark; |
49 | my ($row, $col) = $self->selection_mark; |
49 | my $line = $self->line ($row); |
50 | my $line = $self->line ($row); |
50 | my $text = $line->t; |
51 | my $text = $line->t; |
51 | my $markofs = $line->offset_of ($row, $col); |
52 | my $markofs = $line->offset_of ($row, $col); |
… | |
… | |
72 | push @matches, [$ofs, length $match]; |
73 | push @matches, [$ofs, length $match]; |
73 | } |
74 | } |
74 | } |
75 | } |
75 | } |
76 | } |
76 | |
77 | |
|
|
78 | # whole line |
|
|
79 | push @matches, [0, ($line->end - $line->beg + 1) * $self->ncol]; |
|
|
80 | |
77 | for (sort { $a->[1] <=> $b->[1] or $b->[0] <=> $a->[0] } @matches) { |
81 | for (sort { $a->[1] <=> $b->[1] or $b->[0] <=> $a->[0] } @matches) { |
78 | my ($ofs, $len) = @$_; |
82 | my ($ofs, $len) = @$_; |
79 | |
83 | |
80 | next if $len <= $curlen; |
84 | next if $len <= $curlen; |
81 | |
85 | |
82 | $self->selection_beg ($line->coord_of ($ofs)); |
86 | $self->selection_beg ($line->coord_of ($ofs)); |
83 | $self->selection_end ($line->coord_of ($ofs + $len)); |
87 | $self->selection_end ($line->coord_of ($ofs + $len)); |
84 | return 1; |
88 | return 1; |
85 | } |
89 | } |
86 | |
90 | |
87 | # whole line |
91 | () |
88 | $self->selection_beg ($line->beg, 0); |
|
|
89 | $self->selection_end ($line->end, $self->ncol); |
|
|
90 | |
|
|
91 | return 1; |
|
|
92 | } |
92 | } |